doc-src/Main/Docs/Main_Doc.thy
author wenzelm
Wed, 11 Mar 2009 20:11:06 +0100
changeset 30457 28b487cd9e15
parent 30436 src/HOL/Docs/Main_Doc.thy@1bc0638d554d
child 30988 b53800e3ee47
permissions -rw-r--r--
basic setup for "main" as generated Isabelle manual;
     1 (*<*)
     2 theory Main_Doc
     3 imports Main
     4 begin
     5 
     6 ML {*
     7 fun pretty_term_type_only ctxt (t, T) =
     8   (if fastype_of t = Sign.certify_typ (ProofContext.theory_of ctxt) T then ()
     9    else error "term_type_only: type mismatch";
    10    Syntax.pretty_typ ctxt T)
    11 
    12 val _ = ThyOutput.antiquotation "term_type_only" (Args.term -- Args.typ_abbrev)
    13   (fn {source, context, ...} => fn arg =>
    14     ThyOutput.output
    15       (ThyOutput.maybe_pretty_source (pretty_term_type_only context) source [arg]));
    16 *}
    17 (*>*)
    18 text{*
    19 
    20 \begin{abstract}
    21 This document lists the main types, functions and syntax provided by theory @{theory Main}. It is meant as a quick overview of what is available. The sophisticated class structure is only hinted at. For details see \url{http://isabelle.in.tum.de/dist/library/HOL/}.
    22 \end{abstract}
    23 
    24 \section{HOL}
    25 
    26 The basic logic: @{prop "x = y"}, @{const True}, @{const False}, @{prop"Not P"}, @{prop"P & Q"}, @{prop "P | Q"}, @{prop "P --> Q"}, @{prop"ALL x. P"}, @{prop"EX x. P"}, @{prop"EX! x. P"}, @{term"THE x. P"}.
    27 \smallskip
    28 
    29 \begin{tabular}{@ {} l @ {~::~} l @ {}}
    30 @{const HOL.undefined} & @{typeof HOL.undefined}\\
    31 @{const HOL.default} & @{typeof HOL.default}\\
    32 \end{tabular}
    33 
    34 \subsubsection*{Syntax}
    35 
    36 \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}}
    37 @{term"~(x = y)"} & @{term[source]"\<not> (x = y)"} & (\verb$~=$)\\
    38 @{term[source]"P \<longleftrightarrow> Q"} & @{term"P \<longleftrightarrow> Q"} \\
    39 @{term"If x y z"} & @{term[source]"If x y z"}\\
    40 @{term"Let e\<^isub>1 (%x. e\<^isub>2)"} & @{term[source]"Let e\<^isub>1 (\<lambda>x. e\<^isub>2)"}\\
    41 \end{supertabular}
    42 
    43 
    44 \section{Orderings}
    45 
    46 A collection of classes defining basic orderings:
    47 preorder, partial order, linear order, dense linear order and wellorder.
    48 \smallskip
    49 
    50 \begin{supertabular}{@ {} l @ {~::~} l l @ {}}
    51 @{const HOL.less_eq} & @{typeof HOL.less_eq} & (\verb$<=$)\\
    52 @{const HOL.less} & @{typeof HOL.less}\\
    53 @{const Orderings.Least} & @{typeof Orderings.Least}\\
    54 @{const Orderings.min} & @{typeof Orderings.min}\\
    55 @{const Orderings.max} & @{typeof Orderings.max}\\
    56 @{const[source] top} & @{typeof Orderings.top}\\
    57 @{const[source] bot} & @{typeof Orderings.bot}\\
    58 @{const Orderings.mono} & @{typeof Orderings.mono}\\
    59 @{const Orderings.strict_mono} & @{typeof Orderings.strict_mono}\\
    60 \end{supertabular}
    61 
    62 \subsubsection*{Syntax}
    63 
    64 \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}}
    65 @{term[source]"x \<ge> y"} & @{term"x \<ge> y"} & (\verb$>=$)\\
    66 @{term[source]"x > y"} & @{term"x > y"}\\
    67 @{term"ALL x<=y. P"} & @{term[source]"\<forall>x. x \<le> y \<longrightarrow> P"}\\
    68 @{term"EX x<=y. P"} & @{term[source]"\<exists>x. x \<le> y \<and> P"}\\
    69 \multicolumn{2}{@ {}l@ {}}{Similarly for $<$, $\ge$ and $>$}\\
    70 @{term"LEAST x. P"} & @{term[source]"Least (\<lambda>x. P)"}\\
    71 \end{supertabular}
    72 
    73 
    74 \section{Lattices}
    75 
    76 Classes semilattice, lattice, distributive lattice and complete lattice (the
    77 latter in theory @{theory Set}).
    78 
    79 \begin{tabular}{@ {} l @ {~::~} l @ {}}
    80 @{const Lattices.inf} & @{typeof Lattices.inf}\\
    81 @{const Lattices.sup} & @{typeof Lattices.sup}\\
    82 @{const Set.Inf} & @{term_type_only Set.Inf "'a set \<Rightarrow> 'a::complete_lattice"}\\
    83 @{const Set.Sup} & @{term_type_only Set.Sup "'a set \<Rightarrow> 'a::complete_lattice"}\\
    84 \end{tabular}
    85 
    86 \subsubsection*{Syntax}
    87 
    88 Available by loading theory @{text Lattice_Syntax} in directory @{text
    89 Library}.
    90 
    91 \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
    92 @{text[source]"x \<sqsubseteq> y"} & @{term"x \<le> y"}\\
    93 @{text[source]"x \<sqsubset> y"} & @{term"x < y"}\\
    94 @{text[source]"x \<sqinter> y"} & @{term"inf x y"}\\
    95 @{text[source]"x \<squnion> y"} & @{term"sup x y"}\\
    96 @{text[source]"\<Sqinter> A"} & @{term"Sup A"}\\
    97 @{text[source]"\<Squnion> A"} & @{term"Inf A"}\\
    98 @{text[source]"\<top>"} & @{term[source] top}\\
    99 @{text[source]"\<bottom>"} & @{term[source] bot}\\
   100 \end{supertabular}
   101 
   102 
   103 \section{Set}
   104 
   105 Sets are predicates: @{text[source]"'a set  =  'a \<Rightarrow> bool"}
   106 \bigskip
   107 
   108 \begin{supertabular}{@ {} l @ {~::~} l l @ {}}
   109 @{const Set.empty} & @{term_type_only "Set.empty" "'a set"}\\
   110 @{const insert} & @{term_type_only insert "'a\<Rightarrow>'a set\<Rightarrow>'a set"}\\
   111 @{const Collect} & @{term_type_only Collect "('a\<Rightarrow>bool)\<Rightarrow>'a set"}\\
   112 @{const "op :"} & @{term_type_only "op :" "'a\<Rightarrow>'a set\<Rightarrow>bool"} & (\texttt{:})\\
   113 @{const Set.Un} & @{term_type_only Set.Un "'a set\<Rightarrow>'a set \<Rightarrow> 'a set"} & (\texttt{Un})\\
   114 @{const Set.Int} & @{term_type_only Set.Int "'a set\<Rightarrow>'a set \<Rightarrow> 'a set"} & (\texttt{Int})\\
   115 @{const UNION} & @{term_type_only UNION "'a set\<Rightarrow>('a \<Rightarrow> 'b set) \<Rightarrow> 'b set"}\\
   116 @{const INTER} & @{term_type_only INTER "'a set\<Rightarrow>('a \<Rightarrow> 'b set) \<Rightarrow> 'b set"}\\
   117 @{const Union} & @{term_type_only Union "'a set set\<Rightarrow>'a set"}\\
   118 @{const Inter} & @{term_type_only Inter "'a set set\<Rightarrow>'a set"}\\
   119 @{const Pow} & @{term_type_only Pow "'a set \<Rightarrow>'a set set"}\\
   120 @{const UNIV} & @{term_type_only UNIV "'a set"}\\
   121 @{const image} & @{term_type_only image "('a\<Rightarrow>'b)\<Rightarrow>'a set\<Rightarrow>'b set"}\\
   122 @{const Ball} & @{term_type_only Ball "'a set\<Rightarrow>('a\<Rightarrow>bool)\<Rightarrow>bool"}\\
   123 @{const Bex} & @{term_type_only Bex "'a set\<Rightarrow>('a\<Rightarrow>bool)\<Rightarrow>bool"}\\
   124 \end{supertabular}
   125 
   126 \subsubsection*{Syntax}
   127 
   128 \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}}
   129 @{text"{x\<^isub>1,\<dots>,x\<^isub>n}"} & @{text"insert x\<^isub>1 (\<dots> (insert x\<^isub>n {})\<dots>)"}\\
   130 @{term"x ~: A"} & @{term[source]"\<not>(x \<in> A)"}\\
   131 @{term"A \<subseteq> B"} & @{term[source]"A \<le> B"}\\
   132 @{term"A \<subset> B"} & @{term[source]"A < B"}\\
   133 @{term[source]"A \<supseteq> B"} & @{term[source]"B \<le> A"}\\
   134 @{term[source]"A \<supset> B"} & @{term[source]"B < A"}\\
   135 @{term"{x. P}"} & @{term[source]"Collect (\<lambda>x. P)"}\\
   136 @{term[mode=xsymbols]"UN x:I. A"} & @{term[source]"UNION I (\<lambda>x. A)"} & (\texttt{UN})\\
   137 @{term[mode=xsymbols]"UN x. A"} & @{term[source]"UNION UNIV (\<lambda>x. A)"}\\
   138 @{term[mode=xsymbols]"INT x:I. A"} & @{term[source]"INTER I (\<lambda>x. A)"} & (\texttt{INT})\\
   139 @{term[mode=xsymbols]"INT x. A"} & @{term[source]"INTER UNIV (\<lambda>x. A)"}\\
   140 @{term"ALL x:A. P"} & @{term[source]"Ball A (\<lambda>x. P)"}\\
   141 @{term"EX x:A. P"} & @{term[source]"Bex A (\<lambda>x. P)"}\\
   142 @{term"range f"} & @{term[source]"f ` UNIV"}\\
   143 \end{supertabular}
   144 
   145 
   146 \section{Fun}
   147 
   148 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   149 @{const "Fun.id"} & @{typeof Fun.id}\\
   150 @{const "Fun.comp"} & @{typeof Fun.comp}\\
   151 @{const "Fun.inj_on"} & @{term_type_only Fun.inj_on "('a\<Rightarrow>'b)\<Rightarrow>'a set\<Rightarrow>bool"}\\
   152 @{const "Fun.inj"} & @{typeof Fun.inj}\\
   153 @{const "Fun.surj"} & @{typeof Fun.surj}\\
   154 @{const "Fun.bij"} & @{typeof Fun.bij}\\
   155 @{const "Fun.bij_betw"} & @{term_type_only Fun.bij_betw "('a\<Rightarrow>'b)\<Rightarrow>'a set\<Rightarrow>'b set\<Rightarrow>bool"}\\
   156 @{const "Fun.fun_upd"} & @{typeof Fun.fun_upd}\\
   157 \end{supertabular}
   158 
   159 \subsubsection*{Syntax}
   160 
   161 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
   162 @{term"fun_upd f x y"} & @{term[source]"fun_upd f x y"}\\
   163 @{text"f(x\<^isub>1:=y\<^isub>1,\<dots>,x\<^isub>n:=y\<^isub>n)"} & @{text"f(x\<^isub>1:=y\<^isub>1)\<dots>(x\<^isub>n:=y\<^isub>n)"}\\
   164 \end{tabular}
   165 
   166 
   167 \section{Fixed Points}
   168 
   169 Theory: @{theory Inductive}.
   170 
   171 Least and greatest fixed points in a complete lattice @{typ 'a}:
   172 
   173 \begin{tabular}{@ {} l @ {~::~} l @ {}}
   174 @{const Inductive.lfp} & @{typeof Inductive.lfp}\\
   175 @{const Inductive.gfp} & @{typeof Inductive.gfp}\\
   176 \end{tabular}
   177 
   178 Note that in particular sets (@{typ"'a \<Rightarrow> bool"}) are complete lattices.
   179 
   180 \section{Sum\_Type}
   181 
   182 Type constructor @{text"+"}.
   183 
   184 \begin{tabular}{@ {} l @ {~::~} l @ {}}
   185 @{const Sum_Type.Inl} & @{typeof Sum_Type.Inl}\\
   186 @{const Sum_Type.Inr} & @{typeof Sum_Type.Inr}\\
   187 @{const Sum_Type.Plus} & @{term_type_only Sum_Type.Plus "'a set\<Rightarrow>'b set\<Rightarrow>('a+'b)set"}
   188 \end{tabular}
   189 
   190 
   191 \section{Product\_Type}
   192 
   193 Types @{typ unit} and @{text"\<times>"}.
   194 
   195 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   196 @{const Product_Type.Unity} & @{typeof Product_Type.Unity}\\
   197 @{const Pair} & @{typeof Pair}\\
   198 @{const fst} & @{typeof fst}\\
   199 @{const snd} & @{typeof snd}\\
   200 @{const split} & @{typeof split}\\
   201 @{const curry} & @{typeof curry}\\
   202 @{const Product_Type.Sigma} & @{term_type_only Product_Type.Sigma "'a set\<Rightarrow>('a\<Rightarrow>'b set)\<Rightarrow>('a*'b)set"}\\
   203 \end{supertabular}
   204 
   205 \subsubsection*{Syntax}
   206 
   207 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} ll @ {}}
   208 @{term"Pair a b"} & @{term[source]"Pair a b"}\\
   209 @{term"split (\<lambda>x y. t)"} & @{term[source]"split (\<lambda>x y. t)"}\\
   210 @{term"A <*> B"} &  @{text"Sigma A (\<lambda>\<^raw:\_>. B)"} & (\verb$<*>$)
   211 \end{tabular}
   212 
   213 Pairs may be nested. Nesting to the right is printed as a tuple,
   214 e.g.\ \mbox{@{term"(a,b,c)"}} is really \mbox{@{text"(a, (b, c))"}.}
   215 Pattern matching with pairs and tuples extends to all binders,
   216 e.g.\ \mbox{@{prop"ALL (x,y):A. P"},} @{term"{(x,y). P}"}, etc.
   217 
   218 
   219 \section{Relation}
   220 
   221 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   222 @{const Relation.converse} & @{term_type_only Relation.converse "('a * 'b)set \<Rightarrow> ('b*'a)set"}\\
   223 @{const Relation.rel_comp} & @{term_type_only Relation.rel_comp "('a*'b)set\<Rightarrow>('c*'a)set\<Rightarrow>('c*'b)set"}\\
   224 @{const Relation.Image} & @{term_type_only Relation.Image "('a*'b)set\<Rightarrow>'a set\<Rightarrow>'b set"}\\
   225 @{const Relation.inv_image} & @{term_type_only Relation.inv_image "('a*'a)set\<Rightarrow>('b\<Rightarrow>'a)\<Rightarrow>('b*'b)set"}\\
   226 @{const Relation.Id_on} & @{term_type_only Relation.Id_on "'a set\<Rightarrow>('a*'a)set"}\\
   227 @{const Relation.Id} & @{term_type_only Relation.Id "('a*'a)set"}\\
   228 @{const Relation.Domain} & @{term_type_only Relation.Domain "('a*'b)set\<Rightarrow>'a set"}\\
   229 @{const Relation.Range} & @{term_type_only Relation.Range "('a*'b)set\<Rightarrow>'b set"}\\
   230 @{const Relation.Field} & @{term_type_only Relation.Field "('a*'a)set\<Rightarrow>'a set"}\\
   231 @{const Relation.refl_on} & @{term_type_only Relation.refl_on "'a set\<Rightarrow>('a*'a)set\<Rightarrow>bool"}\\
   232 @{const Relation.refl} & @{term_type_only Relation.refl "('a*'a)set\<Rightarrow>bool"}\\
   233 @{const Relation.sym} & @{term_type_only Relation.sym "('a*'a)set\<Rightarrow>bool"}\\
   234 @{const Relation.antisym} & @{term_type_only Relation.antisym "('a*'a)set\<Rightarrow>bool"}\\
   235 @{const Relation.trans} & @{term_type_only Relation.trans "('a*'a)set\<Rightarrow>bool"}\\
   236 @{const Relation.irrefl} & @{term_type_only Relation.irrefl "('a*'a)set\<Rightarrow>bool"}\\
   237 @{const Relation.total_on} & @{term_type_only Relation.total_on "'a set\<Rightarrow>('a*'a)set\<Rightarrow>bool"}\\
   238 @{const Relation.total} & @{term_type_only Relation.total "('a*'a)set\<Rightarrow>bool"}\\
   239 \end{supertabular}
   240 
   241 \subsubsection*{Syntax}
   242 
   243 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}}
   244 @{term"converse r"} & @{term[source]"converse r"} & (\verb$^-1$)
   245 \end{tabular}
   246 
   247 \section{Equiv\_Relations}
   248 
   249 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   250 @{const Equiv_Relations.equiv} & @{term_type_only Equiv_Relations.equiv "'a set \<Rightarrow> ('a*'a)set\<Rightarrow>bool"}\\
   251 @{const Equiv_Relations.quotient} & @{term_type_only Equiv_Relations.quotient "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set set"}\\
   252 @{const Equiv_Relations.congruent} & @{term_type_only Equiv_Relations.congruent "('a*'a)set\<Rightarrow>('a\<Rightarrow>'b)\<Rightarrow>bool"}\\
   253 @{const Equiv_Relations.congruent2} & @{term_type_only Equiv_Relations.congruent2 "('a*'a)set\<Rightarrow>('b*'b)set\<Rightarrow>('a\<Rightarrow>'b\<Rightarrow>'c)\<Rightarrow>bool"}\\
   254 %@ {const Equiv_Relations.} & @ {term_type_only Equiv_Relations. ""}\\
   255 \end{supertabular}
   256 
   257 \subsubsection*{Syntax}
   258 
   259 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
   260 @{term"congruent r f"} & @{term[source]"congruent r f"}\\
   261 @{term"congruent2 r r f"} & @{term[source]"congruent2 r r f"}\\
   262 \end{tabular}
   263 
   264 
   265 \section{Transitive\_Closure}
   266 
   267 \begin{tabular}{@ {} l @ {~::~} l @ {}}
   268 @{const Transitive_Closure.rtrancl} & @{term_type_only Transitive_Closure.rtrancl "('a*'a)set\<Rightarrow>('a*'a)set"}\\
   269 @{const Transitive_Closure.trancl} & @{term_type_only Transitive_Closure.trancl "('a*'a)set\<Rightarrow>('a*'a)set"}\\
   270 @{const Transitive_Closure.reflcl} & @{term_type_only Transitive_Closure.reflcl "('a*'a)set\<Rightarrow>('a*'a)set"}\\
   271 \end{tabular}
   272 
   273 \subsubsection*{Syntax}
   274 
   275 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}}
   276 @{term"rtrancl r"} & @{term[source]"rtrancl r"} & (\verb$^*$)\\
   277 @{term"trancl r"} & @{term[source]"trancl r"} & (\verb$^+$)\\
   278 @{term"reflcl r"} & @{term[source]"reflcl r"} & (\verb$^=$)
   279 \end{tabular}
   280 
   281 
   282 \section{Algebra}
   283 
   284 Theories @{theory OrderedGroup}, @{theory Ring_and_Field} and @{theory
   285 Divides} define a large collection of classes describing common algebraic
   286 structures from semigroups up to fields. Everything is done in terms of
   287 overloaded operators:
   288 
   289 \begin{supertabular}{@ {} l @ {~::~} l l @ {}}
   290 @{text "0"} & @{typeof zero}\\
   291 @{text "1"} & @{typeof one}\\
   292 @{const plus} & @{typeof plus}\\
   293 @{const minus} & @{typeof minus}\\
   294 @{const uminus} & @{typeof uminus} & (\verb$-$)\\
   295 @{const times} & @{typeof times}\\
   296 @{const inverse} & @{typeof inverse}\\
   297 @{const divide} & @{typeof divide}\\
   298 @{const abs} & @{typeof abs}\\
   299 @{const sgn} & @{typeof sgn}\\
   300 @{const dvd_class.dvd} & @{typeof "dvd_class.dvd"}\\
   301 @{const div_class.div} & @{typeof "div_class.div"}\\
   302 @{const div_class.mod} & @{typeof "div_class.mod"}\\
   303 \end{supertabular}
   304 
   305 \subsubsection*{Syntax}
   306 
   307 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
   308 @{term"abs x"} & @{term[source]"abs x"}
   309 \end{tabular}
   310 
   311 
   312 \section{Nat}
   313 
   314 @{datatype nat}
   315 \bigskip
   316 
   317 \begin{tabular}{@ {} lllllll @ {}}
   318 @{term "op + :: nat \<Rightarrow> nat \<Rightarrow> nat"} &
   319 @{term "op - :: nat \<Rightarrow> nat \<Rightarrow> nat"} &
   320 @{term "op * :: nat \<Rightarrow> nat \<Rightarrow> nat"} &
   321 @{term "op ^ :: nat \<Rightarrow> nat \<Rightarrow> nat"} &
   322 @{term "op div :: nat \<Rightarrow> nat \<Rightarrow> nat"}&
   323 @{term "op mod :: nat \<Rightarrow> nat \<Rightarrow> nat"}&
   324 @{term "op dvd :: nat \<Rightarrow> nat \<Rightarrow> bool"}\\
   325 @{term "op \<le> :: nat \<Rightarrow> nat \<Rightarrow> bool"} &
   326 @{term "op < :: nat \<Rightarrow> nat \<Rightarrow> bool"} &
   327 @{term "min :: nat \<Rightarrow> nat \<Rightarrow> nat"} &
   328 @{term "max :: nat \<Rightarrow> nat \<Rightarrow> nat"} &
   329 @{term "Min :: nat set \<Rightarrow> nat"} &
   330 @{term "Max :: nat set \<Rightarrow> nat"}\\
   331 \end{tabular}
   332 
   333 \begin{tabular}{@ {} l @ {~::~} l @ {}}
   334 @{const Nat.of_nat} & @{typeof Nat.of_nat}
   335 \end{tabular}
   336 
   337 \section{Int}
   338 
   339 Type @{typ int}
   340 \bigskip
   341 
   342 \begin{tabular}{@ {} llllllll @ {}}
   343 @{term "op + :: int \<Rightarrow> int \<Rightarrow> int"} &
   344 @{term "op - :: int \<Rightarrow> int \<Rightarrow> int"} &
   345 @{term "uminus :: int \<Rightarrow> int"} &
   346 @{term "op * :: int \<Rightarrow> int \<Rightarrow> int"} &
   347 @{term "op ^ :: int \<Rightarrow> nat \<Rightarrow> int"} &
   348 @{term "op div :: int \<Rightarrow> int \<Rightarrow> int"}&
   349 @{term "op mod :: int \<Rightarrow> int \<Rightarrow> int"}&
   350 @{term "op dvd :: int \<Rightarrow> int \<Rightarrow> bool"}\\
   351 @{term "op \<le> :: int \<Rightarrow> int \<Rightarrow> bool"} &
   352 @{term "op < :: int \<Rightarrow> int \<Rightarrow> bool"} &
   353 @{term "min :: int \<Rightarrow> int \<Rightarrow> int"} &
   354 @{term "max :: int \<Rightarrow> int \<Rightarrow> int"} &
   355 @{term "Min :: int set \<Rightarrow> int"} &
   356 @{term "Max :: int set \<Rightarrow> int"}\\
   357 @{term "abs :: int \<Rightarrow> int"} &
   358 @{term "sgn :: int \<Rightarrow> int"}\\
   359 \end{tabular}
   360 
   361 \begin{tabular}{@ {} l @ {~::~} l l @ {}}
   362 @{const Int.nat} & @{typeof Int.nat}\\
   363 @{const Int.of_int} & @{typeof Int.of_int}\\
   364 @{const Int.Ints} & @{term_type_only Int.Ints "'a::ring_1 set"} & (\verb$Ints$)
   365 \end{tabular}
   366 
   367 \subsubsection*{Syntax}
   368 
   369 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
   370 @{term"of_nat::nat\<Rightarrow>int"} & @{term[source]"of_nat"}\\
   371 \end{tabular}
   372 
   373 
   374 \section{Finite\_Set}
   375 
   376 
   377 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   378 @{const Finite_Set.finite} & @{term_type_only Finite_Set.finite "'a set\<Rightarrow>bool"}\\
   379 @{const Finite_Set.card} & @{term_type_only Finite_Set.card "'a set => nat"}\\
   380 @{const Finite_Set.fold} & @{term_type_only Finite_Set.fold "('a \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"}\\
   381 @{const Finite_Set.fold_image} & @{typ "('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'b \<Rightarrow> 'a set \<Rightarrow> 'b"}\\
   382 @{const Finite_Set.setsum} & @{term_type_only Finite_Set.setsum "('a => 'b) => 'a set => 'b::comm_monoid_add"}\\
   383 @{const Finite_Set.setprod} & @{term_type_only Finite_Set.setprod "('a => 'b) => 'a set => 'b::comm_monoid_mult"}\\
   384 \end{supertabular}
   385 
   386 
   387 \subsubsection*{Syntax}
   388 
   389 \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}}
   390 @{term"setsum (%x. x) A"} & @{term[source]"setsum (\<lambda>x. x) A"} & (\verb$SUM$)\\
   391 @{term"setsum (%x. t) A"} & @{term[source]"setsum (\<lambda>x. t) A"}\\
   392 @{term[source]"\<Sum>x|P. t"} & @{term"\<Sum>x|P. t"}\\
   393 \multicolumn{2}{@ {}l@ {}}{Similarly for @{text"\<Prod>"} instead of @{text"\<Sum>"}} & (\verb$PROD$)\\
   394 \end{supertabular}
   395 
   396 
   397 \section{Wellfounded}
   398 
   399 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   400 @{const Wellfounded.wf} & @{term_type_only Wellfounded.wf "('a*'a)set\<Rightarrow>bool"}\\
   401 @{const Wellfounded.acyclic} & @{term_type_only Wellfounded.acyclic "('a*'a)set\<Rightarrow>bool"}\\
   402 @{const Wellfounded.acc} & @{term_type_only Wellfounded.acc "('a*'a)set\<Rightarrow>'a set"}\\
   403 @{const Wellfounded.measure} & @{term_type_only Wellfounded.measure "('a\<Rightarrow>nat)\<Rightarrow>('a*'a)set"}\\
   404 @{const Wellfounded.lex_prod} & @{term_type_only Wellfounded.lex_prod "('a*'a)set\<Rightarrow>('b*'b)set\<Rightarrow>(('a*'b)*('a*'b))set"}\\
   405 @{const Wellfounded.mlex_prod} & @{term_type_only Wellfounded.mlex_prod "('a\<Rightarrow>nat)\<Rightarrow>('a*'a)set\<Rightarrow>('a*'a)set"}\\
   406 @{const Wellfounded.less_than} & @{term_type_only Wellfounded.less_than "(nat*nat)set"}\\
   407 @{const Wellfounded.pred_nat} & @{term_type_only Wellfounded.pred_nat "(nat*nat)set"}\\
   408 \end{supertabular}
   409 
   410 
   411 \section{SetInterval}
   412 
   413 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   414 @{const lessThan} & @{term_type_only lessThan "'a::ord \<Rightarrow> 'a set"}\\
   415 @{const atMost} & @{term_type_only atMost "'a::ord \<Rightarrow> 'a set"}\\
   416 @{const greaterThan} & @{term_type_only greaterThan "'a::ord \<Rightarrow> 'a set"}\\
   417 @{const atLeast} & @{term_type_only atLeast "'a::ord \<Rightarrow> 'a set"}\\
   418 @{const greaterThanLessThan} & @{term_type_only greaterThanLessThan "'a::ord \<Rightarrow> 'a \<Rightarrow> 'a set"}\\
   419 @{const atLeastLessThan} & @{term_type_only atLeastLessThan "'a::ord \<Rightarrow> 'a \<Rightarrow> 'a set"}\\
   420 @{const greaterThanAtMost} & @{term_type_only greaterThanAtMost "'a::ord \<Rightarrow> 'a \<Rightarrow> 'a set"}\\
   421 @{const atLeastAtMost} & @{term_type_only atLeastAtMost "'a::ord \<Rightarrow> 'a \<Rightarrow> 'a set"}\\
   422 \end{supertabular}
   423 
   424 \subsubsection*{Syntax}
   425 
   426 \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
   427 @{term "lessThan y"} & @{term[source] "lessThan y"}\\
   428 @{term "atMost y"} & @{term[source] "atMost y"}\\
   429 @{term "greaterThan x"} & @{term[source] "greaterThan x"}\\
   430 @{term "atLeast x"} & @{term[source] "atLeast x"}\\
   431 @{term "greaterThanLessThan x y"} & @{term[source] "greaterThanLessThan x y"}\\
   432 @{term "atLeastLessThan x y"} & @{term[source] "atLeastLessThan x y"}\\
   433 @{term "greaterThanAtMost x y"} & @{term[source] "greaterThanAtMost x y"}\\
   434 @{term "atLeastAtMost x y"} & @{term[source] "atLeastAtMost x y"}\\
   435 @{term[mode=xsymbols] "UN i:{..n}. A"} & @{term[source] "\<Union> i \<in> {..n}. A"}\\
   436 @{term[mode=xsymbols] "UN i:{..<n}. A"} & @{term[source] "\<Union> i \<in> {..<n}. A"}\\
   437 \multicolumn{2}{@ {}l@ {}}{Similarly for @{text"\<Inter>"} instead of @{text"\<Union>"}}\\
   438 @{term "setsum (%x. t) {a..b}"} & @{term[source] "setsum (\<lambda>x. t) {a..b}"}\\
   439 @{term "setsum (%x. t) {a..<b}"} & @{term[source] "setsum (\<lambda>x. t) {a..<b}"}\\
   440 @{term "setsum (%x. t) {..b}"} & @{term[source] "setsum (\<lambda>x. t) {..b}"}\\
   441 @{term "setsum (%x. t) {..<b}"} & @{term[source] "setsum (\<lambda>x. t) {..<b}"}\\
   442 \multicolumn{2}{@ {}l@ {}}{Similarly for @{text"\<Prod>"} instead of @{text"\<Sum>"}}\\
   443 \end{supertabular}
   444 
   445 
   446 \section{Power}
   447 
   448 \begin{tabular}{@ {} l @ {~::~} l @ {}}
   449 @{const Power.power} & @{typeof Power.power}
   450 \end{tabular}
   451 
   452 
   453 \section{Iterated Functions and Relations}
   454 
   455 Theory: @{theory Relation_Power}
   456 
   457 Iterated functions \ @{term[source]"(f::'a\<Rightarrow>'a) ^ n"} \
   458 and relations \ @{term[source]"(r::('a\<times>'a)set) ^ n"}.
   459 
   460 
   461 \section{Option}
   462 
   463 @{datatype option}
   464 \bigskip
   465 
   466 \begin{tabular}{@ {} l @ {~::~} l @ {}}
   467 @{const Option.the} & @{typeof Option.the}\\
   468 @{const Option.map} & @{typ[source]"('a \<Rightarrow> 'b) \<Rightarrow> 'a option \<Rightarrow> 'b option"}\\
   469 @{const Option.set} & @{term_type_only Option.set "'a option \<Rightarrow> 'a set"}
   470 \end{tabular}
   471 
   472 \section{List}
   473 
   474 @{datatype list}
   475 \bigskip
   476 
   477 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   478 @{const List.append} & @{typeof List.append}\\
   479 @{const List.butlast} & @{typeof List.butlast}\\
   480 @{const List.concat} & @{typeof List.concat}\\
   481 @{const List.distinct} & @{typeof List.distinct}\\
   482 @{const List.drop} & @{typeof List.drop}\\
   483 @{const List.dropWhile} & @{typeof List.dropWhile}\\
   484 @{const List.filter} & @{typeof List.filter}\\
   485 @{const List.foldl} & @{typeof List.foldl}\\
   486 @{const List.foldr} & @{typeof List.foldr}\\
   487 @{const List.hd} & @{typeof List.hd}\\
   488 @{const List.last} & @{typeof List.last}\\
   489 @{const List.length} & @{typeof List.length}\\
   490 @{const List.lenlex} & @{term_type_only List.lenlex "('a*'a)set\<Rightarrow>('a list * 'a list)set"}\\
   491 @{const List.lex} & @{term_type_only List.lex "('a*'a)set\<Rightarrow>('a list * 'a list)set"}\\
   492 @{const List.lexn} & @{term_type_only List.lexn "('a*'a)set\<Rightarrow>nat\<Rightarrow>('a list * 'a list)set"}\\
   493 @{const List.lexord} & @{term_type_only List.lexord "('a*'a)set\<Rightarrow>('a list * 'a list)set"}\\
   494 @{const List.listrel} & @{term_type_only List.listrel "('a*'a)set\<Rightarrow>('a list * 'a list)set"}\\
   495 @{const List.lists} & @{term_type_only List.lists "'a set\<Rightarrow>'a list set"}\\
   496 @{const List.listset} & @{term_type_only List.listset "'a set list \<Rightarrow> 'a list set"}\\
   497 @{const List.listsum} & @{typeof List.listsum}\\
   498 @{const List.list_all2} & @{typeof List.list_all2}\\
   499 @{const List.list_update} & @{typeof List.list_update}\\
   500 @{const List.map} & @{typeof List.map}\\
   501 @{const List.measures} & @{term_type_only List.measures "('a\<Rightarrow>nat)list\<Rightarrow>('a*'a)set"}\\
   502 @{const List.remdups} & @{typeof List.remdups}\\
   503 @{const List.removeAll} & @{typeof List.removeAll}\\
   504 @{const List.remove1} & @{typeof List.remove1}\\
   505 @{const List.replicate} & @{typeof List.replicate}\\
   506 @{const List.rev} & @{typeof List.rev}\\
   507 @{const List.rotate} & @{typeof List.rotate}\\
   508 @{const List.rotate1} & @{typeof List.rotate1}\\
   509 @{const List.set} & @{term_type_only List.set "'a list \<Rightarrow> 'a set"}\\
   510 @{const List.sort} & @{typeof List.sort}\\
   511 @{const List.sorted} & @{typeof List.sorted}\\
   512 @{const List.splice} & @{typeof List.splice}\\
   513 @{const List.sublist} & @{typeof List.sublist}\\
   514 @{const List.take} & @{typeof List.take}\\
   515 @{const List.takeWhile} & @{typeof List.takeWhile}\\
   516 @{const List.tl} & @{typeof List.tl}\\
   517 @{const List.upt} & @{typeof List.upt}\\
   518 @{const List.upto} & @{typeof List.upto}\\
   519 @{const List.zip} & @{typeof List.zip}\\
   520 \end{supertabular}
   521 
   522 \subsubsection*{Syntax}
   523 
   524 \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
   525 @{text"[x\<^isub>1,\<dots>,x\<^isub>n]"} & @{text"x\<^isub>1 # \<dots> # x\<^isub>n # []"}\\
   526 @{term"[m..<n]"} & @{term[source]"upt m n"}\\
   527 @{term"[i..j]"} & @{term[source]"upto i j"}\\
   528 @{text"[e. x \<leftarrow> xs]"} & @{term"map (%x. e) xs"}\\
   529 @{term"[x \<leftarrow> xs. b]"} & @{term[source]"filter (\<lambda>x. b) xs"} \\
   530 @{term"xs[n := x]"} & @{term[source]"list_update xs n x"}\\
   531 @{term"\<Sum>x\<leftarrow>xs. e"} & @{term[source]"listsum (map (\<lambda>x. e) xs)"}\\
   532 \end{supertabular}
   533 \medskip
   534 
   535 List comprehension: @{text"[e. q\<^isub>1, \<dots>, q\<^isub>n]"} where each
   536 qualifier @{text q\<^isub>i} is either a generator \mbox{@{text"pat \<leftarrow> e"}} or a
   537 guard, i.e.\ boolean expression.
   538 
   539 \section{Map}
   540 
   541 Maps model partial functions and are often used as finite tables. However,
   542 the domain of a map may be infinite.
   543 
   544 @{text"'a \<rightharpoonup> 'b  =  'a \<Rightarrow> 'b option"}
   545 \bigskip
   546 
   547 \begin{supertabular}{@ {} l @ {~::~} l @ {}}
   548 @{const Map.empty} & @{typeof Map.empty}\\
   549 @{const Map.map_add} & @{typeof Map.map_add}\\
   550 @{const Map.map_comp} & @{typeof Map.map_comp}\\
   551 @{const Map.restrict_map} & @{term_type_only Map.restrict_map "('a\<Rightarrow>'b option)\<Rightarrow>'a set\<Rightarrow>('a\<Rightarrow>'b option)"}\\
   552 @{const Map.dom} & @{term_type_only Map.dom "('a\<Rightarrow>'b option)\<Rightarrow>'a set"}\\
   553 @{const Map.ran} & @{term_type_only Map.ran "('a\<Rightarrow>'b option)\<Rightarrow>'b set"}\\
   554 @{const Map.map_le} & @{typeof Map.map_le}\\
   555 @{const Map.map_of} & @{typeof Map.map_of}\\
   556 @{const Map.map_upds} & @{typeof Map.map_upds}\\
   557 \end{supertabular}
   558 
   559 \subsubsection*{Syntax}
   560 
   561 \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}}
   562 @{term"Map.empty"} & @{term"\<lambda>x. None"}\\
   563 @{term"m(x:=Some y)"} & @{term[source]"m(x:=Some y)"}\\
   564 @{text"m(x\<^isub>1\<mapsto>y\<^isub>1,\<dots>,x\<^isub>n\<mapsto>y\<^isub>n)"} & @{text[source]"m(x\<^isub>1\<mapsto>y\<^isub>1)\<dots>(x\<^isub>n\<mapsto>y\<^isub>n)"}\\
   565 @{text"[x\<^isub>1\<mapsto>y\<^isub>1,\<dots>,x\<^isub>n\<mapsto>y\<^isub>n]"} & @{text[source]"Map.empty(x\<^isub>1\<mapsto>y\<^isub>1,\<dots>,x\<^isub>n\<mapsto>y\<^isub>n)"}\\
   566 @{term"map_upds m xs ys"} & @{term[source]"map_upds m xs ys"}\\
   567 \end{tabular}
   568 
   569 *}
   570 (*<*)
   571 end
   572 (*>*)