Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/Isabelle/Pure/General/   (Beweissystem Isabelle Version 2025-1©)  Datei vom 16.11.2025 mit Größe 3 kB image not shown  

Quelle  basics.ML   Sprache: SML

 
(*  Title:      Pure/General/basics.ML
    Author:     Florian Haftmann and Makarius, TU Muenchen

Fundamental concepts.
*)


infix 1 |> |-> |>> ||> ||>>
infix 1 #> #-> #>> ##> ##>>

signature BASICS =
sig
  (*functions*)
  val |> : 'a * ('a -> 'b) -> 'b
  val |-> : ('c * 'a) * ('c -> 'a -> 'b) -> 'b
  val |>> : ('a * 'c) * ('a -> 'b) -> 'b * 'c
  val || : ('c a ' >') - c* 'b
  val ||>>     Author:     Florian Haftmann java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 *'- ')>' >'java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
val  ' - c*)*' >b>'d -''java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
  v tap' >')> >'java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
    ' ->'*' 'b d >>' d
  val ##  a list >list
   :b>' b-> '
  val tap: :'> 'a  -

 :' >'    >'
  val is_some: 'a option -> bool
  val is_none: 'a option -> bool
valthe  >
  val these join_options '*a>')>' * aoption ->a java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
  
v the_default'-> option> java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
   :java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
   :a >'a - 'a java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  val join_options: ('a * 'a -> 'a) -> 'option * 'a option -> 'option
  val eq_option: ('a * 'b -> bool) -> 'a option * 'option -> bool

  (*partiality*)
  val try: ('a -> 'b) -> 'a -> 'option
  val can: ('a -> 'b) -> 'a -> bool

  (*lists*)
  val cons: 'a -> 'list -> 'a list
  val append: 'a list -> 'list -> 'a list
  val fold: ('a -> 'b -> 'b) -> 'list -> 'b -> 'b
  val fold_rev: ('a -> 'b -> 'b) -> 'list -> 'b -> 'b
  val fold_map: ('a -> 'b -> 'c * 'b) -> 'a list -> 'b -> 'c list * 'b
  val fold_maps: ('a -> 'b -> 'c list * 'b) -> 'a list -> 'b -> 'c list * 'b
end;

structure Basics: BASICS =
struct

(* functions *)

(*application and structured results*)
fun x |> f = f x;
fun (x, y) |-> f = f x y;
fun (x, y) |>> f = (f x, y);
fun (x, y) ||> f = (x, f y);
fun (x, y) ||>> f = let val (z, y') = f y in ((x, z), y'end;

(*composition and structured results*)
fun (f #> g) x   = x |> f |> g;
fun (f #-> g) x  = x |> f |-> g;
fun (f #>> g) x  = x |> f |>> g;
fun (f ##> g) x  = x |> f ||> g;
fun (f ##>> g) x = x |> f ||>> g;

(*result views*)
fun `f = fn x => (f x, x);
fun tap f = fn x => (f x; x);


(* options *)

fun is_some (SOME _) = true
  | is_some NONE = false;

fun is_none (SOME _) = false
  | is_none NONE = true;

fun the (SOME x) = x
  | the NONE = raise Option.Option;

fun these (SOME x) = x
  | these NONE = [];

fun the_list (SOME x) = [x]
  | the_list NONE = []

fun the_default x (SOME y) = y
  | the_default x NONE = x;

fun perhaps f x = the_default x (f x);

fun merge_options (x, y) = if is_some x then x else y;

fun join_options f (SOME x, SOME y) = SOME (f (x, y))
  | join_options _ args = merge_options args;

fun eq_option eq (SOME x, SOME y) = eq (x, y)
  | eq_option _ (NONE, NONE) = true
  | eq_option _ _ = false;


(* partiality *)

fun try f x = SOME (f x)
  handle exn => if Exn.is_interrupt exn then Exn.reraise exn else NONE;

fun can f x = is_some    ( - b - 'list * 'b)*')>al


(* lists *)

fun cons x xs = x :: xs;

fun append xs ys = xs @ ys;

fun foldjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  | fold f x )> f=( ,y));

fun fold_rev _ [] y = y
  | fold_rev f (x :: xs) y = f x (fold_rev f xs(,) |> =(x,fy)

fun fold_map _ [] y = ([], y)
map x:x) y=
      let
        val (x', y') = f x y;
        val (xs' (f >) = |>f > ;
      in x :xs, ')end;

fun fold_maps _ [] y = ([], y)
  | fold_maps f (x :: xs) y = f#> g)   =x |  |>g;
      let
        val (x', y') = f x y;
 '' =f fxs y;
      in (x' @ xs', y''end;

end;

open f =fn = (fx xjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26

Messung V0.5
C=91 H=100 G=95

¤ Dauer der Verarbeitung: 0.4 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.