diff --git a/src/Doc/Main/Main_Doc.thy b/src/Doc/Main/Main_Doc.thy --- a/src/Doc/Main/Main_Doc.thy +++ b/src/Doc/Main/Main_Doc.thy @@ -1,650 +1,650 @@ (*<*) theory Main_Doc imports Main begin setup \ Document_Output.antiquotation_pretty_source \<^binding>\term_type_only\ (Args.term -- Args.typ_abbrev) (fn ctxt => fn (t, T) => (if fastype_of t = Sign.certify_typ (Proof_Context.theory_of ctxt) T then () else error "term_type_only: type mismatch"; Syntax.pretty_typ ctxt T)) \ setup \ Document_Output.antiquotation_pretty_source \<^binding>\expanded_typ\ Args.typ Syntax.pretty_typ \ (*>*) text\ \begin{abstract} 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. For infix operators and their precedences see the final section. The sophisticated class structure is only hinted at. For details see \<^url>\https://isabelle.in.tum.de/library/HOL\. \end{abstract} \section*{HOL} The basic logic: \<^prop>\x = y\, \<^const>\True\, \<^const>\False\, \<^prop>\\ P\, \<^prop>\P \ Q\, \<^prop>\P \ Q\, \<^prop>\P \ Q\, \<^prop>\\x. P\, \<^prop>\\x. P\, \<^prop>\\! x. P\, \<^term>\THE x. P\. \<^smallskip> \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\HOL.undefined\ & \<^typeof>\HOL.undefined\\\ \<^const>\HOL.default\ & \<^typeof>\HOL.default\\\ \end{tabular} \subsubsection*{Syntax} \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}} \<^term>\\ (x = y)\ & @{term[source]"\ (x = y)"} & (\<^verbatim>\~=\)\\ @{term[source]"P \ Q"} & \<^term>\P \ Q\ \\ \<^term>\If x y z\ & @{term[source]"If x y z"}\\ \<^term>\Let e\<^sub>1 (\x. e\<^sub>2)\ & @{term[source]"Let e\<^sub>1 (\x. e\<^sub>2)"}\\ \end{supertabular} \section*{Orderings} A collection of classes defining basic orderings: preorder, partial order, linear order, dense linear order and wellorder. \<^smallskip> \begin{supertabular}{@ {} l @ {~::~} l l @ {}} \<^const>\Orderings.less_eq\ & \<^typeof>\Orderings.less_eq\ & (\<^verbatim>\<=\)\\ \<^const>\Orderings.less\ & \<^typeof>\Orderings.less\\\ \<^const>\Orderings.Least\ & \<^typeof>\Orderings.Least\\\ \<^const>\Orderings.Greatest\ & \<^typeof>\Orderings.Greatest\\\ \<^const>\Orderings.min\ & \<^typeof>\Orderings.min\\\ \<^const>\Orderings.max\ & \<^typeof>\Orderings.max\\\ @{const[source] top} & \<^typeof>\Orderings.top\\\ @{const[source] bot} & \<^typeof>\Orderings.bot\\\ \<^const>\Orderings.mono\ & \<^typeof>\Orderings.mono\\\ \<^const>\Orderings.strict_mono\ & \<^typeof>\Orderings.strict_mono\\\ \end{supertabular} \subsubsection*{Syntax} \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}} @{term[source]"x \ y"} & \<^term>\x \ y\ & (\<^verbatim>\>=\)\\ @{term[source]"x > y"} & \<^term>\x > y\\\ \<^term>\\x\y. P\ & @{term[source]"\x. x \ y \ P"}\\ \<^term>\\x\y. P\ & @{term[source]"\x. x \ y \ P"}\\ \multicolumn{2}{@ {}l@ {}}{Similarly for $<$, $\ge$ and $>$}\\ \<^term>\LEAST x. P\ & @{term[source]"Least (\x. P)"}\\ \<^term>\GREATEST x. P\ & @{term[source]"Greatest (\x. P)"}\\ \end{supertabular} \section*{Lattices} Classes semilattice, lattice, distributive lattice and complete lattice (the latter in theory \<^theory>\HOL.Set\). \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Lattices.inf\ & \<^typeof>\Lattices.inf\\\ \<^const>\Lattices.sup\ & \<^typeof>\Lattices.sup\\\ \<^const>\Complete_Lattices.Inf\ & @{term_type_only Complete_Lattices.Inf "'a set \ 'a::Inf"}\\ \<^const>\Complete_Lattices.Sup\ & @{term_type_only Complete_Lattices.Sup "'a set \ 'a::Sup"}\\ \end{tabular} \subsubsection*{Syntax} -Available by loading theory \Lattice_Syntax\ in directory \Library\. +Available via \<^theory_text>\unbundle lattice_syntax\. \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} @{text[source]"x \ y"} & \<^term>\x \ y\\\ @{text[source]"x \ y"} & \<^term>\x < y\\\ @{text[source]"x \ y"} & \<^term>\inf x y\\\ @{text[source]"x \ y"} & \<^term>\sup x y\\\ @{text[source]"\A"} & \<^term>\Inf A\\\ @{text[source]"\A"} & \<^term>\Sup A\\\ @{text[source]"\"} & @{term[source] top}\\ @{text[source]"\"} & @{term[source] bot}\\ \end{supertabular} \section*{Set} \begin{supertabular}{@ {} l @ {~::~} l l @ {}} \<^const>\Set.empty\ & @{term_type_only "Set.empty" "'a set"}\\ \<^const>\Set.insert\ & @{term_type_only insert "'a\'a set\'a set"}\\ \<^const>\Collect\ & @{term_type_only Collect "('a\bool)\'a set"}\\ \<^const>\Set.member\ & @{term_type_only Set.member "'a\'a set\bool"} & (\<^verbatim>\:\)\\ \<^const>\Set.union\ & @{term_type_only Set.union "'a set\'a set \ 'a set"} & (\<^verbatim>\Un\)\\ \<^const>\Set.inter\ & @{term_type_only Set.inter "'a set\'a set \ 'a set"} & (\<^verbatim>\Int\)\\ \<^const>\Union\ & @{term_type_only Union "'a set set\'a set"}\\ \<^const>\Inter\ & @{term_type_only Inter "'a set set\'a set"}\\ \<^const>\Pow\ & @{term_type_only Pow "'a set \'a set set"}\\ \<^const>\UNIV\ & @{term_type_only UNIV "'a set"}\\ \<^const>\image\ & @{term_type_only image "('a\'b)\'a set\'b set"}\\ \<^const>\Ball\ & @{term_type_only Ball "'a set\('a\bool)\bool"}\\ \<^const>\Bex\ & @{term_type_only Bex "'a set\('a\bool)\bool"}\\ \end{supertabular} \subsubsection*{Syntax} \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}} \{a\<^sub>1,\,a\<^sub>n}\ & \insert a\<^sub>1 (\ (insert a\<^sub>n {})\)\\\ \<^term>\a \ A\ & @{term[source]"\(x \ A)"}\\ \<^term>\A \ B\ & @{term[source]"A \ B"}\\ \<^term>\A \ B\ & @{term[source]"A < B"}\\ @{term[source]"A \ B"} & @{term[source]"B \ A"}\\ @{term[source]"A \ B"} & @{term[source]"B < A"}\\ \<^term>\{x. P}\ & @{term[source]"Collect (\x. P)"}\\ \{t | x\<^sub>1 \ x\<^sub>n. P}\ & \{v. \x\<^sub>1 \ x\<^sub>n. v = t \ P}\\\ @{term[source]"\x\I. A"} & @{term[source]"\((\x. A) ` I)"} & (\texttt{UN})\\ @{term[source]"\x. A"} & @{term[source]"\((\x. A) ` UNIV)"}\\ @{term[source]"\x\I. A"} & @{term[source]"\((\x. A) ` I)"} & (\texttt{INT})\\ @{term[source]"\x. A"} & @{term[source]"\((\x. A) ` UNIV)"}\\ \<^term>\\x\A. P\ & @{term[source]"Ball A (\x. P)"}\\ \<^term>\\x\A. P\ & @{term[source]"Bex A (\x. P)"}\\ \<^term>\range f\ & @{term[source]"f ` UNIV"}\\ \end{supertabular} \section*{Fun} \begin{supertabular}{@ {} l @ {~::~} l l @ {}} \<^const>\Fun.id\ & \<^typeof>\Fun.id\\\ \<^const>\Fun.comp\ & \<^typeof>\Fun.comp\ & (\texttt{o})\\ \<^const>\Fun.inj_on\ & @{term_type_only Fun.inj_on "('a\'b)\'a set\bool"}\\ \<^const>\Fun.inj\ & \<^typeof>\Fun.inj\\\ \<^const>\Fun.surj\ & \<^typeof>\Fun.surj\\\ \<^const>\Fun.bij\ & \<^typeof>\Fun.bij\\\ \<^const>\Fun.bij_betw\ & @{term_type_only Fun.bij_betw "('a\'b)\'a set\'b set\bool"}\\ \<^const>\Fun.fun_upd\ & \<^typeof>\Fun.fun_upd\\\ \end{supertabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \<^term>\fun_upd f x y\ & @{term[source]"fun_upd f x y"}\\ \f(x\<^sub>1:=y\<^sub>1,\,x\<^sub>n:=y\<^sub>n)\ & \f(x\<^sub>1:=y\<^sub>1)\(x\<^sub>n:=y\<^sub>n)\\\ \end{tabular} \section*{Hilbert\_Choice} Hilbert's selection ($\varepsilon$) operator: \<^term>\SOME x. P\. \<^smallskip> \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Hilbert_Choice.inv_into\ & @{term_type_only Hilbert_Choice.inv_into "'a set \ ('a \ 'b) \ ('b \ 'a)"} \end{tabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \<^term>\inv\ & @{term[source]"inv_into UNIV"} \end{tabular} \section*{Fixed Points} Theory: \<^theory>\HOL.Inductive\. Least and greatest fixed points in a complete lattice \<^typ>\'a\: \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Inductive.lfp\ & \<^typeof>\Inductive.lfp\\\ \<^const>\Inductive.gfp\ & \<^typeof>\Inductive.gfp\\\ \end{tabular} Note that in particular sets (\<^typ>\'a \ bool\) are complete lattices. \section*{Sum\_Type} Type constructor \+\. \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Sum_Type.Inl\ & \<^typeof>\Sum_Type.Inl\\\ \<^const>\Sum_Type.Inr\ & \<^typeof>\Sum_Type.Inr\\\ \<^const>\Sum_Type.Plus\ & @{term_type_only Sum_Type.Plus "'a set\'b set\('a+'b)set"} \end{tabular} \section*{Product\_Type} Types \<^typ>\unit\ and \\\. \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\Product_Type.Unity\ & \<^typeof>\Product_Type.Unity\\\ \<^const>\Pair\ & \<^typeof>\Pair\\\ \<^const>\fst\ & \<^typeof>\fst\\\ \<^const>\snd\ & \<^typeof>\snd\\\ \<^const>\case_prod\ & \<^typeof>\case_prod\\\ \<^const>\curry\ & \<^typeof>\curry\\\ \<^const>\Product_Type.Sigma\ & @{term_type_only Product_Type.Sigma "'a set\('a\'b set)\('a*'b)set"}\\ \end{supertabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} ll @ {}} \<^term>\Pair a b\ & @{term[source]"Pair a b"}\\ \<^term>\case_prod (\x y. t)\ & @{term[source]"case_prod (\x y. t)"}\\ \<^term>\A \ B\ & \Sigma A (\\<^latex>\\_\. B)\ \end{tabular} Pairs may be nested. Nesting to the right is printed as a tuple, e.g.\ \mbox{\<^term>\(a,b,c)\} is really \mbox{\(a, (b, c))\.} Pattern matching with pairs and tuples extends to all binders, e.g.\ \mbox{\<^prop>\\(x,y)\A. P\,} \<^term>\{(x,y). P}\, etc. \section*{Relation} \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Relation.converse\ & @{term_type_only Relation.converse "('a * 'b)set \ ('b*'a)set"}\\ \<^const>\Relation.relcomp\ & @{term_type_only Relation.relcomp "('a*'b)set\('b*'c)set\('a*'c)set"}\\ \<^const>\Relation.Image\ & @{term_type_only Relation.Image "('a*'b)set\'a set\'b set"}\\ \<^const>\Relation.inv_image\ & @{term_type_only Relation.inv_image "('a*'a)set\('b\'a)\('b*'b)set"}\\ \<^const>\Relation.Id_on\ & @{term_type_only Relation.Id_on "'a set\('a*'a)set"}\\ \<^const>\Relation.Id\ & @{term_type_only Relation.Id "('a*'a)set"}\\ \<^const>\Relation.Domain\ & @{term_type_only Relation.Domain "('a*'b)set\'a set"}\\ \<^const>\Relation.Range\ & @{term_type_only Relation.Range "('a*'b)set\'b set"}\\ \<^const>\Relation.Field\ & @{term_type_only Relation.Field "('a*'a)set\'a set"}\\ \<^const>\Relation.refl_on\ & @{term_type_only Relation.refl_on "'a set\('a*'a)set\bool"}\\ \<^const>\Relation.refl\ & @{term_type_only Relation.refl "('a*'a)set\bool"}\\ \<^const>\Relation.sym\ & @{term_type_only Relation.sym "('a*'a)set\bool"}\\ \<^const>\Relation.antisym\ & @{term_type_only Relation.antisym "('a*'a)set\bool"}\\ \<^const>\Relation.trans\ & @{term_type_only Relation.trans "('a*'a)set\bool"}\\ \<^const>\Relation.irrefl\ & @{term_type_only Relation.irrefl "('a*'a)set\bool"}\\ \<^const>\Relation.total_on\ & @{term_type_only Relation.total_on "'a set\('a*'a)set\bool"}\\ \<^const>\Relation.total\ & @{term_type_only Relation.total "('a*'a)set\bool"}\\ \end{tabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}} \<^term>\converse r\ & @{term[source]"converse r"} & (\<^verbatim>\^-1\) \end{tabular} \<^medskip> \noindent Type synonym \ \<^typ>\'a rel\ \=\ @{expanded_typ "'a rel"} \section*{Equiv\_Relations} \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\Equiv_Relations.equiv\ & @{term_type_only Equiv_Relations.equiv "'a set \ ('a*'a)set\bool"}\\ \<^const>\Equiv_Relations.quotient\ & @{term_type_only Equiv_Relations.quotient "'a set \ ('a \ 'a) set \ 'a set set"}\\ \<^const>\Equiv_Relations.congruent\ & @{term_type_only Equiv_Relations.congruent "('a*'a)set\('a\'b)\bool"}\\ \<^const>\Equiv_Relations.congruent2\ & @{term_type_only Equiv_Relations.congruent2 "('a*'a)set\('b*'b)set\('a\'b\'c)\bool"}\\ %@ {const Equiv_Relations.} & @ {term_type_only Equiv_Relations. ""}\\ \end{supertabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \<^term>\congruent r f\ & @{term[source]"congruent r f"}\\ \<^term>\congruent2 r r f\ & @{term[source]"congruent2 r r f"}\\ \end{tabular} \section*{Transitive\_Closure} \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Transitive_Closure.rtrancl\ & @{term_type_only Transitive_Closure.rtrancl "('a*'a)set\('a*'a)set"}\\ \<^const>\Transitive_Closure.trancl\ & @{term_type_only Transitive_Closure.trancl "('a*'a)set\('a*'a)set"}\\ \<^const>\Transitive_Closure.reflcl\ & @{term_type_only Transitive_Closure.reflcl "('a*'a)set\('a*'a)set"}\\ \<^const>\Transitive_Closure.acyclic\ & @{term_type_only Transitive_Closure.acyclic "('a*'a)set\bool"}\\ \<^const>\compower\ & @{term_type_only "(^^) :: ('a*'a)set\nat\('a*'a)set" "('a*'a)set\nat\('a*'a)set"}\\ \end{tabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}} \<^term>\rtrancl r\ & @{term[source]"rtrancl r"} & (\<^verbatim>\^*\)\\ \<^term>\trancl r\ & @{term[source]"trancl r"} & (\<^verbatim>\^+\)\\ \<^term>\reflcl r\ & @{term[source]"reflcl r"} & (\<^verbatim>\^=\) \end{tabular} \section*{Algebra} Theories \<^theory>\HOL.Groups\, \<^theory>\HOL.Rings\, \<^theory>\HOL.Fields\ and \<^theory>\HOL.Divides\ define a large collection of classes describing common algebraic structures from semigroups up to fields. Everything is done in terms of overloaded operators: \begin{supertabular}{@ {} l @ {~::~} l l @ {}} \0\ & \<^typeof>\zero\\\ \1\ & \<^typeof>\one\\\ \<^const>\plus\ & \<^typeof>\plus\\\ \<^const>\minus\ & \<^typeof>\minus\\\ \<^const>\uminus\ & \<^typeof>\uminus\ & (\<^verbatim>\-\)\\ \<^const>\times\ & \<^typeof>\times\\\ \<^const>\inverse\ & \<^typeof>\inverse\\\ \<^const>\divide\ & \<^typeof>\divide\\\ \<^const>\abs\ & \<^typeof>\abs\\\ \<^const>\sgn\ & \<^typeof>\sgn\\\ \<^const>\Rings.dvd\ & \<^typeof>\Rings.dvd\\\ \<^const>\divide\ & \<^typeof>\divide\\\ \<^const>\modulo\ & \<^typeof>\modulo\\\ \end{supertabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \<^term>\\x\\ & @{term[source] "abs x"} \end{tabular} \section*{Nat} \<^datatype>\nat\ \<^bigskip> \begin{tabular}{@ {} lllllll @ {}} \<^term>\(+) :: nat \ nat \ nat\ & \<^term>\(-) :: nat \ nat \ nat\ & \<^term>\(*) :: nat \ nat \ nat\ & \<^term>\(^) :: nat \ nat \ nat\ & \<^term>\(div) :: nat \ nat \ nat\& \<^term>\(mod) :: nat \ nat \ nat\& \<^term>\(dvd) :: nat \ nat \ bool\\\ \<^term>\(\) :: nat \ nat \ bool\ & \<^term>\(<) :: nat \ nat \ bool\ & \<^term>\min :: nat \ nat \ nat\ & \<^term>\max :: nat \ nat \ nat\ & \<^term>\Min :: nat set \ nat\ & \<^term>\Max :: nat set \ nat\\\ \end{tabular} \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Nat.of_nat\ & \<^typeof>\Nat.of_nat\\\ \<^term>\(^^) :: ('a \ 'a) \ nat \ 'a \ 'a\ & @{term_type_only "(^^) :: ('a \ 'a) \ nat \ 'a \ 'a" "('a \ 'a) \ nat \ 'a \ 'a"} \end{tabular} \section*{Int} Type \<^typ>\int\ \<^bigskip> \begin{tabular}{@ {} llllllll @ {}} \<^term>\(+) :: int \ int \ int\ & \<^term>\(-) :: int \ int \ int\ & \<^term>\uminus :: int \ int\ & \<^term>\(*) :: int \ int \ int\ & \<^term>\(^) :: int \ nat \ int\ & \<^term>\(div) :: int \ int \ int\& \<^term>\(mod) :: int \ int \ int\& \<^term>\(dvd) :: int \ int \ bool\\\ \<^term>\(\) :: int \ int \ bool\ & \<^term>\(<) :: int \ int \ bool\ & \<^term>\min :: int \ int \ int\ & \<^term>\max :: int \ int \ int\ & \<^term>\Min :: int set \ int\ & \<^term>\Max :: int set \ int\\\ \<^term>\abs :: int \ int\ & \<^term>\sgn :: int \ int\\\ \end{tabular} \begin{tabular}{@ {} l @ {~::~} l l @ {}} \<^const>\Int.nat\ & \<^typeof>\Int.nat\\\ \<^const>\Int.of_int\ & \<^typeof>\Int.of_int\\\ \<^const>\Int.Ints\ & @{term_type_only Int.Ints "'a::ring_1 set"} & (\<^verbatim>\Ints\) \end{tabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \<^term>\of_nat::nat\int\ & @{term[source]"of_nat"}\\ \end{tabular} \section*{Finite\_Set} \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\Finite_Set.finite\ & @{term_type_only Finite_Set.finite "'a set\bool"}\\ \<^const>\Finite_Set.card\ & @{term_type_only Finite_Set.card "'a set \ nat"}\\ \<^const>\Finite_Set.fold\ & @{term_type_only Finite_Set.fold "('a \ 'b \ 'b) \ 'b \ 'a set \ 'b"}\\ \end{supertabular} \section*{Lattices\_Big} \begin{supertabular}{@ {} l @ {~::~} l l @ {}} \<^const>\Lattices_Big.Min\ & \<^typeof>\Lattices_Big.Min\\\ \<^const>\Lattices_Big.Max\ & \<^typeof>\Lattices_Big.Max\\\ \<^const>\Lattices_Big.arg_min\ & \<^typeof>\Lattices_Big.arg_min\\\ \<^const>\Lattices_Big.is_arg_min\ & \<^typeof>\Lattices_Big.is_arg_min\\\ \<^const>\Lattices_Big.arg_max\ & \<^typeof>\Lattices_Big.arg_max\\\ \<^const>\Lattices_Big.is_arg_max\ & \<^typeof>\Lattices_Big.is_arg_max\\\ \end{supertabular} \subsubsection*{Syntax} \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}} \<^term>\ARG_MIN f x. P\ & @{term[source]"arg_min f (\x. P)"}\\ \<^term>\ARG_MAX f x. P\ & @{term[source]"arg_max f (\x. P)"}\\ \end{supertabular} \section*{Groups\_Big} \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\Groups_Big.sum\ & @{term_type_only Groups_Big.sum "('a \ 'b) \ 'a set \ 'b::comm_monoid_add"}\\ \<^const>\Groups_Big.prod\ & @{term_type_only Groups_Big.prod "('a \ 'b) \ 'a set \ 'b::comm_monoid_mult"}\\ \end{supertabular} \subsubsection*{Syntax} \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l l @ {}} \<^term>\sum (\x. x) A\ & @{term[source]"sum (\x. x) A"} & (\<^verbatim>\SUM\)\\ \<^term>\sum (\x. t) A\ & @{term[source]"sum (\x. t) A"}\\ @{term[source] "\x|P. t"} & \<^term>\\x|P. t\\\ \multicolumn{2}{@ {}l@ {}}{Similarly for \\\ instead of \\\} & (\<^verbatim>\PROD\)\\ \end{supertabular} \section*{Wellfounded} \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\Wellfounded.wf\ & @{term_type_only Wellfounded.wf "('a*'a)set\bool"}\\ \<^const>\Wellfounded.acc\ & @{term_type_only Wellfounded.acc "('a*'a)set\'a set"}\\ \<^const>\Wellfounded.measure\ & @{term_type_only Wellfounded.measure "('a\nat)\('a*'a)set"}\\ \<^const>\Wellfounded.lex_prod\ & @{term_type_only Wellfounded.lex_prod "('a*'a)set\('b*'b)set\(('a*'b)*('a*'b))set"}\\ \<^const>\Wellfounded.mlex_prod\ & @{term_type_only Wellfounded.mlex_prod "('a\nat)\('a*'a)set\('a*'a)set"}\\ \<^const>\Wellfounded.less_than\ & @{term_type_only Wellfounded.less_than "(nat*nat)set"}\\ \<^const>\Wellfounded.pred_nat\ & @{term_type_only Wellfounded.pred_nat "(nat*nat)set"}\\ \end{supertabular} \section*{Set\_Interval} % \<^theory>\HOL.Set_Interval\ \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\lessThan\ & @{term_type_only lessThan "'a::ord \ 'a set"}\\ \<^const>\atMost\ & @{term_type_only atMost "'a::ord \ 'a set"}\\ \<^const>\greaterThan\ & @{term_type_only greaterThan "'a::ord \ 'a set"}\\ \<^const>\atLeast\ & @{term_type_only atLeast "'a::ord \ 'a set"}\\ \<^const>\greaterThanLessThan\ & @{term_type_only greaterThanLessThan "'a::ord \ 'a \ 'a set"}\\ \<^const>\atLeastLessThan\ & @{term_type_only atLeastLessThan "'a::ord \ 'a \ 'a set"}\\ \<^const>\greaterThanAtMost\ & @{term_type_only greaterThanAtMost "'a::ord \ 'a \ 'a set"}\\ \<^const>\atLeastAtMost\ & @{term_type_only atLeastAtMost "'a::ord \ 'a \ 'a set"}\\ \end{supertabular} \subsubsection*{Syntax} \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \<^term>\lessThan y\ & @{term[source] "lessThan y"}\\ \<^term>\atMost y\ & @{term[source] "atMost y"}\\ \<^term>\greaterThan x\ & @{term[source] "greaterThan x"}\\ \<^term>\atLeast x\ & @{term[source] "atLeast x"}\\ \<^term>\greaterThanLessThan x y\ & @{term[source] "greaterThanLessThan x y"}\\ \<^term>\atLeastLessThan x y\ & @{term[source] "atLeastLessThan x y"}\\ \<^term>\greaterThanAtMost x y\ & @{term[source] "greaterThanAtMost x y"}\\ \<^term>\atLeastAtMost x y\ & @{term[source] "atLeastAtMost x y"}\\ @{term[source] "\i\n. A"} & @{term[source] "\i \ {..n}. A"}\\ @{term[source] "\ii \ {..\\ instead of \\\}\\ \<^term>\sum (\x. t) {a..b}\ & @{term[source] "sum (\x. t) {a..b}"}\\ \<^term>\sum (\x. t) {a.. & @{term[source] "sum (\x. t) {a..\sum (\x. t) {..b}\ & @{term[source] "sum (\x. t) {..b}"}\\ \<^term>\sum (\x. t) {.. & @{term[source] "sum (\x. t) {..\\ instead of \\\}\\ \end{supertabular} \section*{Power} \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Power.power\ & \<^typeof>\Power.power\ \end{tabular} \section*{Option} \<^datatype>\option\ \<^bigskip> \begin{tabular}{@ {} l @ {~::~} l @ {}} \<^const>\Option.the\ & \<^typeof>\Option.the\\\ \<^const>\map_option\ & @{typ[source]"('a \ 'b) \ 'a option \ 'b option"}\\ \<^const>\set_option\ & @{term_type_only set_option "'a option \ 'a set"}\\ \<^const>\Option.bind\ & @{term_type_only Option.bind "'a option \ ('a \ 'b option) \ 'b option"} \end{tabular} \section*{List} \<^datatype>\list\ \<^bigskip> \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\List.append\ & \<^typeof>\List.append\\\ \<^const>\List.butlast\ & \<^typeof>\List.butlast\\\ \<^const>\List.concat\ & \<^typeof>\List.concat\\\ \<^const>\List.distinct\ & \<^typeof>\List.distinct\\\ \<^const>\List.drop\ & \<^typeof>\List.drop\\\ \<^const>\List.dropWhile\ & \<^typeof>\List.dropWhile\\\ \<^const>\List.filter\ & \<^typeof>\List.filter\\\ \<^const>\List.find\ & \<^typeof>\List.find\\\ \<^const>\List.fold\ & \<^typeof>\List.fold\\\ \<^const>\List.foldr\ & \<^typeof>\List.foldr\\\ \<^const>\List.foldl\ & \<^typeof>\List.foldl\\\ \<^const>\List.hd\ & \<^typeof>\List.hd\\\ \<^const>\List.last\ & \<^typeof>\List.last\\\ \<^const>\List.length\ & \<^typeof>\List.length\\\ \<^const>\List.lenlex\ & @{term_type_only List.lenlex "('a*'a)set\('a list * 'a list)set"}\\ \<^const>\List.lex\ & @{term_type_only List.lex "('a*'a)set\('a list * 'a list)set"}\\ \<^const>\List.lexn\ & @{term_type_only List.lexn "('a*'a)set\nat\('a list * 'a list)set"}\\ \<^const>\List.lexord\ & @{term_type_only List.lexord "('a*'a)set\('a list * 'a list)set"}\\ \<^const>\List.listrel\ & @{term_type_only List.listrel "('a*'b)set\('a list * 'b list)set"}\\ \<^const>\List.listrel1\ & @{term_type_only List.listrel1 "('a*'a)set\('a list * 'a list)set"}\\ \<^const>\List.lists\ & @{term_type_only List.lists "'a set\'a list set"}\\ \<^const>\List.listset\ & @{term_type_only List.listset "'a set list \ 'a list set"}\\ \<^const>\Groups_List.sum_list\ & \<^typeof>\Groups_List.sum_list\\\ \<^const>\Groups_List.prod_list\ & \<^typeof>\Groups_List.prod_list\\\ \<^const>\List.list_all2\ & \<^typeof>\List.list_all2\\\ \<^const>\List.list_update\ & \<^typeof>\List.list_update\\\ \<^const>\List.map\ & \<^typeof>\List.map\\\ \<^const>\List.measures\ & @{term_type_only List.measures "('a\nat)list\('a*'a)set"}\\ \<^const>\List.nth\ & \<^typeof>\List.nth\\\ \<^const>\List.nths\ & \<^typeof>\List.nths\\\ \<^const>\List.remdups\ & \<^typeof>\List.remdups\\\ \<^const>\List.removeAll\ & \<^typeof>\List.removeAll\\\ \<^const>\List.remove1\ & \<^typeof>\List.remove1\\\ \<^const>\List.replicate\ & \<^typeof>\List.replicate\\\ \<^const>\List.rev\ & \<^typeof>\List.rev\\\ \<^const>\List.rotate\ & \<^typeof>\List.rotate\\\ \<^const>\List.rotate1\ & \<^typeof>\List.rotate1\\\ \<^const>\List.set\ & @{term_type_only List.set "'a list \ 'a set"}\\ \<^const>\List.shuffles\ & \<^typeof>\List.shuffles\\\ \<^const>\List.sort\ & \<^typeof>\List.sort\\\ \<^const>\List.sorted\ & \<^typeof>\List.sorted\\\ \<^const>\List.sorted_wrt\ & \<^typeof>\List.sorted_wrt\\\ \<^const>\List.splice\ & \<^typeof>\List.splice\\\ \<^const>\List.take\ & \<^typeof>\List.take\\\ \<^const>\List.takeWhile\ & \<^typeof>\List.takeWhile\\\ \<^const>\List.tl\ & \<^typeof>\List.tl\\\ \<^const>\List.upt\ & \<^typeof>\List.upt\\\ \<^const>\List.upto\ & \<^typeof>\List.upto\\\ \<^const>\List.zip\ & \<^typeof>\List.zip\\\ \end{supertabular} \subsubsection*{Syntax} \begin{supertabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \[x\<^sub>1,\,x\<^sub>n]\ & \x\<^sub>1 # \ # x\<^sub>n # []\\\ \<^term>\[m.. & @{term[source]"upt m n"}\\ \<^term>\[i..j]\ & @{term[source]"upto i j"}\\ \<^term>\xs[n := x]\ & @{term[source]"list_update xs n x"}\\ \<^term>\\x\xs. e\ & @{term[source]"listsum (map (\x. e) xs)"}\\ \end{supertabular} \<^medskip> Filter input syntax \[pat \ e. b]\, where \pat\ is a tuple pattern, which stands for \<^term>\filter (\pat. b) e\. List comprehension input syntax: \[e. q\<^sub>1, \, q\<^sub>n]\ where each qualifier \q\<^sub>i\ is either a generator \mbox{\pat \ e\} or a guard, i.e.\ boolean expression. \section*{Map} Maps model partial functions and are often used as finite tables. However, the domain of a map may be infinite. \begin{supertabular}{@ {} l @ {~::~} l @ {}} \<^const>\Map.empty\ & \<^typeof>\Map.empty\\\ \<^const>\Map.map_add\ & \<^typeof>\Map.map_add\\\ \<^const>\Map.map_comp\ & \<^typeof>\Map.map_comp\\\ \<^const>\Map.restrict_map\ & @{term_type_only Map.restrict_map "('a\'b option)\'a set\('a\'b option)"}\\ \<^const>\Map.dom\ & @{term_type_only Map.dom "('a\'b option)\'a set"}\\ \<^const>\Map.ran\ & @{term_type_only Map.ran "('a\'b option)\'b set"}\\ \<^const>\Map.map_le\ & \<^typeof>\Map.map_le\\\ \<^const>\Map.map_of\ & \<^typeof>\Map.map_of\\\ \<^const>\Map.map_upds\ & \<^typeof>\Map.map_upds\\\ \end{supertabular} \subsubsection*{Syntax} \begin{tabular}{@ {} l @ {\quad$\equiv$\quad} l @ {}} \<^term>\Map.empty\ & \<^term>\\x. None\\\ \<^term>\m(x:=Some y)\ & @{term[source]"m(x:=Some y)"}\\ \m(x\<^sub>1\y\<^sub>1,\,x\<^sub>n\y\<^sub>n)\ & @{text[source]"m(x\<^sub>1\y\<^sub>1)\(x\<^sub>n\y\<^sub>n)"}\\ \[x\<^sub>1\y\<^sub>1,\,x\<^sub>n\y\<^sub>n]\ & @{text[source]"Map.empty(x\<^sub>1\y\<^sub>1,\,x\<^sub>n\y\<^sub>n)"}\\ \<^term>\map_upds m xs ys\ & @{term[source]"map_upds m xs ys"}\\ \end{tabular} \section*{Infix operators in Main} % \<^theory>\Main\ \begin{center} \begin{tabular}{llll} & Operator & precedence & associativity \\ \hline Meta-logic & \\\ & 1 & right \\ & \\\ & 2 \\ \hline Logic & \\\ & 35 & right \\ &\\\ & 30 & right \\ &\\\, \\\ & 25 & right\\ &\=\, \\\ & 50 & left\\ \hline Orderings & \\\, \<\, \\\, \>\ & 50 \\ \hline Sets & \\\, \\\, \\\, \\\ & 50 \\ &\\\, \\\ & 50 \\ &\\\ & 70 & left \\ &\\\ & 65 & left \\ \hline Functions and Relations & \\\ & 55 & left\\ &\`\ & 90 & right\\ &\O\ & 75 & right\\ &\``\ & 90 & right\\ &\^^\ & 80 & right\\ \hline Numbers & \+\, \-\ & 65 & left \\ &\*\, \/\ & 70 & left \\ &\div\, \mod\ & 70 & left\\ &\^\ & 80 & right\\ &\dvd\ & 50 \\ \hline Lists & \#\, \@\ & 65 & right\\ &\!\ & 100 & left \end{tabular} \end{center} \ (*<*) end (*>*) diff --git a/src/Doc/Typeclass_Hierarchy/Setup.thy b/src/Doc/Typeclass_Hierarchy/Setup.thy --- a/src/Doc/Typeclass_Hierarchy/Setup.thy +++ b/src/Doc/Typeclass_Hierarchy/Setup.thy @@ -1,39 +1,41 @@ theory Setup -imports Complex_Main "HOL-Library.Multiset" "HOL-Library.Lattice_Syntax" +imports Complex_Main "HOL-Library.Multiset" begin +unbundle lattice_syntax + ML_file \../antiquote_setup.ML\ ML_file \../more_antiquote.ML\ attribute_setup all = \Scan.succeed (Thm.rule_attribute [] (K Thm.forall_intr_vars))\ "quantified schematic vars" setup \Config.put_global Printer.show_type_emphasis false\ setup \ let fun strip_all t = if Logic.is_all t then case snd (dest_comb t) of Abs (w, T, t') => strip_all t' |>> cons (w, T) else ([], t); fun frugal (w, T as TFree (v, sort)) visited = if member (op =) visited v then ((w, dummyT), visited) else ((w, T), v :: visited) | frugal (w, T) visited = ((w, dummyT), visited); fun frugal_sorts t = let val (vTs, body) = strip_all t val (vTs', _) = fold_map frugal vTs []; in Logic.list_all (vTs', map_types (K dummyT) body) end; in Term_Style.setup \<^binding>\frugal_sorts\ (Scan.succeed (K frugal_sorts)) end \ declare [[show_sorts]] end diff --git a/src/HOL/Examples/Knaster_Tarski.thy b/src/HOL/Examples/Knaster_Tarski.thy --- a/src/HOL/Examples/Knaster_Tarski.thy +++ b/src/HOL/Examples/Knaster_Tarski.thy @@ -1,107 +1,109 @@ (* Title: HOL/Examples/Knaster_Tarski.thy Author: Makarius Typical textbook proof example. *) section \Textbook-style reasoning: the Knaster-Tarski Theorem\ theory Knaster_Tarski - imports Main "HOL-Library.Lattice_Syntax" + imports Main begin +unbundle lattice_syntax + subsection \Prose version\ text \ According to the textbook @{cite \pages 93--94\ "davey-priestley"}, the Knaster-Tarski fixpoint theorem is as follows.\<^footnote>\We have dualized the argument, and tuned the notation a little bit.\ \<^bold>\The Knaster-Tarski Fixpoint Theorem.\ Let \L\ be a complete lattice and \f: L \ L\ an order-preserving map. Then \\{x \ L | f(x) \ x}\ is a fixpoint of \f\. \<^bold>\Proof.\ Let \H = {x \ L | f(x) \ x}\ and \a = \H\. For all \x \ H\ we have \a \ x\, so \f(a) \ f(x) \ x\. Thus \f(a)\ is a lower bound of \H\, whence \f(a) \ a\. We now use this inequality to prove the reverse one (!) and thereby complete the proof that \a\ is a fixpoint. Since \f\ is order-preserving, \f(f(a)) \ f(a)\. This says \f(a) \ H\, so \a \ f(a)\.\ subsection \Formal versions\ text \ The Isar proof below closely follows the original presentation. Virtually all of the prose narration has been rephrased in terms of formal Isar language elements. Just as many textbook-style proofs, there is a strong bias towards forward proof, and several bends in the course of reasoning. \ theorem Knaster_Tarski: fixes f :: "'a::complete_lattice \ 'a" assumes "mono f" shows "\a. f a = a" proof let ?H = "{u. f u \ u}" let ?a = "\?H" show "f ?a = ?a" proof - { fix x assume "x \ ?H" then have "?a \ x" by (rule Inf_lower) with \mono f\ have "f ?a \ f x" .. also from \x \ ?H\ have "\ \ x" .. finally have "f ?a \ x" . } then have "f ?a \ ?a" by (rule Inf_greatest) { also presume "\ \ f ?a" finally (order_antisym) show ?thesis . } from \mono f\ and \f ?a \ ?a\ have "f (f ?a) \ f ?a" .. then have "f ?a \ ?H" .. then show "?a \ f ?a" by (rule Inf_lower) qed qed text \ Above we have used several advanced Isar language elements, such as explicit block structure and weak assumptions. Thus we have mimicked the particular way of reasoning of the original text. In the subsequent version the order of reasoning is changed to achieve structured top-down decomposition of the problem at the outer level, while only the inner steps of reasoning are done in a forward manner. We are certainly more at ease here, requiring only the most basic features of the Isar language. \ theorem Knaster_Tarski': fixes f :: "'a::complete_lattice \ 'a" assumes "mono f" shows "\a. f a = a" proof let ?H = "{u. f u \ u}" let ?a = "\?H" show "f ?a = ?a" proof (rule order_antisym) show "f ?a \ ?a" proof (rule Inf_greatest) fix x assume "x \ ?H" then have "?a \ x" by (rule Inf_lower) with \mono f\ have "f ?a \ f x" .. also from \x \ ?H\ have "\ \ x" .. finally show "f ?a \ x" . qed show "?a \ f ?a" proof (rule Inf_lower) from \mono f\ and \f ?a \ ?a\ have "f (f ?a) \ f ?a" .. then show "f ?a \ ?H" .. qed qed qed end diff --git a/src/HOL/Library/Combine_PER.thy b/src/HOL/Library/Combine_PER.thy --- a/src/HOL/Library/Combine_PER.thy +++ b/src/HOL/Library/Combine_PER.thy @@ -1,52 +1,54 @@ (* Author: Florian Haftmann, TU Muenchen *) section \A combinator to build partial equivalence relations from a predicate and an equivalence relation\ theory Combine_PER - imports Main Lattice_Syntax + imports Main begin +unbundle lattice_syntax + definition combine_per :: "('a \ bool) \ ('a \ 'a \ bool) \ 'a \ 'a \ bool" where "combine_per P R = (\x y. P x \ P y) \ R" lemma combine_per_simp [simp]: "combine_per P R x y \ P x \ P y \ x \ y" for R (infixl "\" 50) by (simp add: combine_per_def) lemma combine_per_top [simp]: "combine_per \ R = R" by (simp add: fun_eq_iff) lemma combine_per_eq [simp]: "combine_per P HOL.eq = HOL.eq \ (\x y. P x)" by (auto simp add: fun_eq_iff) lemma symp_combine_per: "symp R \ symp (combine_per P R)" by (auto simp add: symp_def sym_def combine_per_def) lemma transp_combine_per: "transp R \ transp (combine_per P R)" by (auto simp add: transp_def trans_def combine_per_def) lemma combine_perI: "P x \ P y \ x \ y \ combine_per P R x y" for R (infixl "\" 50) by (simp add: combine_per_def) lemma symp_combine_per_symp: "symp R \ symp (combine_per P R)" by (auto intro!: sympI elim: sympE) lemma transp_combine_per_transp: "transp R \ transp (combine_per P R)" by (auto intro!: transpI elim: transpE) lemma equivp_combine_per_part_equivp [intro?]: fixes R (infixl "\" 50) assumes "\x. P x" and "equivp R" shows "part_equivp (combine_per P R)" proof - from \\x. P x\ obtain x where "P x" .. moreover from \equivp R\ have "x \ x" by (rule equivp_reflp) ultimately have "\x. P x \ x \ x" by blast with \equivp R\ show ?thesis by (auto intro!: part_equivpI symp_combine_per_symp transp_combine_per_transp elim: equivpE) qed end diff --git a/src/HOL/Library/Complete_Partial_Order2.thy b/src/HOL/Library/Complete_Partial_Order2.thy --- a/src/HOL/Library/Complete_Partial_Order2.thy +++ b/src/HOL/Library/Complete_Partial_Order2.thy @@ -1,1751 +1,1753 @@ (* Title: HOL/Library/Complete_Partial_Order2.thy Author: Andreas Lochbihler, ETH Zurich *) section \Formalisation of chain-complete partial orders, continuity and admissibility\ theory Complete_Partial_Order2 imports - Main Lattice_Syntax + Main begin +unbundle lattice_syntax + lemma chain_transfer [transfer_rule]: includes lifting_syntax shows "((A ===> A ===> (=)) ===> rel_set A ===> (=)) Complete_Partial_Order.chain Complete_Partial_Order.chain" unfolding chain_def[abs_def] by transfer_prover lemma linorder_chain [simp, intro!]: fixes Y :: "_ :: linorder set" shows "Complete_Partial_Order.chain (\) Y" by(auto intro: chainI) lemma fun_lub_apply: "\Sup. fun_lub Sup Y x = Sup ((\f. f x) ` Y)" by(simp add: fun_lub_def image_def) lemma fun_lub_empty [simp]: "fun_lub lub {} = (\_. lub {})" by(rule ext)(simp add: fun_lub_apply) lemma chain_fun_ordD: assumes "Complete_Partial_Order.chain (fun_ord le) Y" shows "Complete_Partial_Order.chain le ((\f. f x) ` Y)" by(rule chainI)(auto dest: chainD[OF assms] simp add: fun_ord_def) lemma chain_Diff: "Complete_Partial_Order.chain ord A \ Complete_Partial_Order.chain ord (A - B)" by(erule chain_subset) blast lemma chain_rel_prodD1: "Complete_Partial_Order.chain (rel_prod orda ordb) Y \ Complete_Partial_Order.chain orda (fst ` Y)" by(auto 4 3 simp add: chain_def) lemma chain_rel_prodD2: "Complete_Partial_Order.chain (rel_prod orda ordb) Y \ Complete_Partial_Order.chain ordb (snd ` Y)" by(auto 4 3 simp add: chain_def) context ccpo begin lemma ccpo_fun: "class.ccpo (fun_lub Sup) (fun_ord (\)) (mk_less (fun_ord (\)))" by standard (auto 4 3 simp add: mk_less_def fun_ord_def fun_lub_apply intro: order.trans order.antisym chain_imageI ccpo_Sup_upper ccpo_Sup_least) lemma ccpo_Sup_below_iff: "Complete_Partial_Order.chain (\) Y \ Sup Y \ x \ (\y\Y. y \ x)" by(fast intro: order_trans[OF ccpo_Sup_upper] ccpo_Sup_least) lemma Sup_minus_bot: assumes chain: "Complete_Partial_Order.chain (\) A" shows "\(A - {\{}}) = \A" (is "?lhs = ?rhs") proof (rule order.antisym) show "?lhs \ ?rhs" by (blast intro: ccpo_Sup_least chain_Diff[OF chain] ccpo_Sup_upper[OF chain]) show "?rhs \ ?lhs" proof (rule ccpo_Sup_least [OF chain]) show "x \ A \ x \ ?lhs" for x by (cases "x = \{}") (blast intro: ccpo_Sup_least chain_empty ccpo_Sup_upper[OF chain_Diff[OF chain]])+ qed qed lemma mono_lub: fixes le_b (infix "\" 60) assumes chain: "Complete_Partial_Order.chain (fun_ord (\)) Y" and mono: "\f. f \ Y \ monotone le_b (\) f" shows "monotone (\) (\) (fun_lub Sup Y)" proof(rule monotoneI) fix x y assume "x \ y" have chain'': "\x. Complete_Partial_Order.chain (\) ((\f. f x) ` Y)" using chain by(rule chain_imageI)(simp add: fun_ord_def) then show "fun_lub Sup Y x \ fun_lub Sup Y y" unfolding fun_lub_apply proof(rule ccpo_Sup_least) fix x' assume "x' \ (\f. f x) ` Y" then obtain f where "f \ Y" "x' = f x" by blast note \x' = f x\ also from \f \ Y\ \x \ y\ have "f x \ f y" by(blast dest: mono monotoneD) also have "\ \ \((\f. f y) ` Y)" using chain'' by(rule ccpo_Sup_upper)(simp add: \f \ Y\) finally show "x' \ \((\f. f y) ` Y)" . qed qed context fixes le_b (infix "\" 60) and Y f assumes chain: "Complete_Partial_Order.chain le_b Y" and mono1: "\y. y \ Y \ monotone le_b (\) (\x. f x y)" and mono2: "\x a b. \ x \ Y; a \ b; a \ Y; b \ Y \ \ f x a \ f x b" begin lemma Sup_mono: assumes le: "x \ y" and x: "x \ Y" and y: "y \ Y" shows "\(f x ` Y) \ \(f y ` Y)" (is "_ \ ?rhs") proof(rule ccpo_Sup_least) from chain show chain': "Complete_Partial_Order.chain (\) (f x ` Y)" when "x \ Y" for x by(rule chain_imageI) (insert that, auto dest: mono2) fix x' assume "x' \ f x ` Y" then obtain y' where "y' \ Y" "x' = f x y'" by blast note this(2) also from mono1[OF \y' \ Y\] le have "\ \ f y y'" by(rule monotoneD) also have "\ \ ?rhs" using chain'[OF y] by (auto intro!: ccpo_Sup_upper simp add: \y' \ Y\) finally show "x' \ ?rhs" . qed(rule x) lemma diag_Sup: "\((\x. \(f x ` Y)) ` Y) = \((\x. f x x) ` Y)" (is "?lhs = ?rhs") proof(rule order.antisym) have chain1: "Complete_Partial_Order.chain (\) ((\x. \(f x ` Y)) ` Y)" using chain by(rule chain_imageI)(rule Sup_mono) have chain2: "\y'. y' \ Y \ Complete_Partial_Order.chain (\) (f y' ` Y)" using chain by(rule chain_imageI)(auto dest: mono2) have chain3: "Complete_Partial_Order.chain (\) ((\x. f x x) ` Y)" using chain by(rule chain_imageI)(auto intro: monotoneD[OF mono1] mono2 order.trans) show "?lhs \ ?rhs" using chain1 proof(rule ccpo_Sup_least) fix x' assume "x' \ (\x. \(f x ` Y)) ` Y" then obtain y' where "y' \ Y" "x' = \(f y' ` Y)" by blast note this(2) also have "\ \ ?rhs" using chain2[OF \y' \ Y\] proof(rule ccpo_Sup_least) fix x assume "x \ f y' ` Y" then obtain y where "y \ Y" and x: "x = f y' y" by blast define y'' where "y'' = (if y \ y' then y' else y)" from chain \y \ Y\ \y' \ Y\ have "y \ y' \ y' \ y" by(rule chainD) hence "f y' y \ f y'' y''" using \y \ Y\ \y' \ Y\ by(auto simp add: y''_def intro: mono2 monotoneD[OF mono1]) also from \y \ Y\ \y' \ Y\ have "y'' \ Y" by(simp add: y''_def) from chain3 have "f y'' y'' \ ?rhs" by(rule ccpo_Sup_upper)(simp add: \y'' \ Y\) finally show "x \ ?rhs" by(simp add: x) qed finally show "x' \ ?rhs" . qed show "?rhs \ ?lhs" using chain3 proof(rule ccpo_Sup_least) fix y assume "y \ (\x. f x x) ` Y" then obtain x where "x \ Y" and "y = f x x" by blast note this(2) also from chain2[OF \x \ Y\] have "\ \ \(f x ` Y)" by(rule ccpo_Sup_upper)(simp add: \x \ Y\) also have "\ \ ?lhs" by(rule ccpo_Sup_upper[OF chain1])(simp add: \x \ Y\) finally show "y \ ?lhs" . qed qed end lemma Sup_image_mono_le: fixes le_b (infix "\" 60) and Sup_b ("\") assumes ccpo: "class.ccpo Sup_b (\) lt_b" assumes chain: "Complete_Partial_Order.chain (\) Y" and mono: "\x y. \ x \ y; x \ Y \ \ f x \ f y" shows "Sup (f ` Y) \ f (\Y)" proof(rule ccpo_Sup_least) show "Complete_Partial_Order.chain (\) (f ` Y)" using chain by(rule chain_imageI)(rule mono) fix x assume "x \ f ` Y" then obtain y where "y \ Y" and "x = f y" by blast note this(2) also have "y \ \Y" using ccpo chain \y \ Y\ by(rule ccpo.ccpo_Sup_upper) hence "f y \ f (\Y)" using \y \ Y\ by(rule mono) finally show "x \ \" . qed lemma swap_Sup: fixes le_b (infix "\" 60) assumes Y: "Complete_Partial_Order.chain (\) Y" and Z: "Complete_Partial_Order.chain (fun_ord (\)) Z" and mono: "\f. f \ Z \ monotone (\) (\) f" shows "\((\x. \(x ` Y)) ` Z) = \((\x. \((\f. f x) ` Z)) ` Y)" (is "?lhs = ?rhs") proof(cases "Y = {}") case True then show ?thesis by (simp add: image_constant_conv cong del: SUP_cong_simp) next case False have chain1: "\f. f \ Z \ Complete_Partial_Order.chain (\) (f ` Y)" by(rule chain_imageI[OF Y])(rule monotoneD[OF mono]) have chain2: "Complete_Partial_Order.chain (\) ((\x. \(x ` Y)) ` Z)" using Z proof(rule chain_imageI) fix f g assume "f \ Z" "g \ Z" and "fun_ord (\) f g" from chain1[OF \f \ Z\] show "\(f ` Y) \ \(g ` Y)" proof(rule ccpo_Sup_least) fix x assume "x \ f ` Y" then obtain y where "y \ Y" "x = f y" by blast note this(2) also have "\ \ g y" using \fun_ord (\) f g\ by(simp add: fun_ord_def) also have "\ \ \(g ` Y)" using chain1[OF \g \ Z\] by(rule ccpo_Sup_upper)(simp add: \y \ Y\) finally show "x \ \(g ` Y)" . qed qed have chain3: "\x. Complete_Partial_Order.chain (\) ((\f. f x) ` Z)" using Z by(rule chain_imageI)(simp add: fun_ord_def) have chain4: "Complete_Partial_Order.chain (\) ((\x. \((\f. f x) ` Z)) ` Y)" using Y proof(rule chain_imageI) fix f x y assume "x \ y" show "\((\f. f x) ` Z) \ \((\f. f y) ` Z)" (is "_ \ ?rhs") using chain3 proof(rule ccpo_Sup_least) fix x' assume "x' \ (\f. f x) ` Z" then obtain f where "f \ Z" "x' = f x" by blast note this(2) also have "f x \ f y" using \f \ Z\ \x \ y\ by(rule monotoneD[OF mono]) also have "f y \ ?rhs" using chain3 by(rule ccpo_Sup_upper)(simp add: \f \ Z\) finally show "x' \ ?rhs" . qed qed from chain2 have "?lhs \ ?rhs" proof(rule ccpo_Sup_least) fix x assume "x \ (\x. \(x ` Y)) ` Z" then obtain f where "f \ Z" "x = \(f ` Y)" by blast note this(2) also have "\ \ ?rhs" using chain1[OF \f \ Z\] proof(rule ccpo_Sup_least) fix x' assume "x' \ f ` Y" then obtain y where "y \ Y" "x' = f y" by blast note this(2) also have "f y \ \((\f. f y) ` Z)" using chain3 by(rule ccpo_Sup_upper)(simp add: \f \ Z\) also have "\ \ ?rhs" using chain4 by(rule ccpo_Sup_upper)(simp add: \y \ Y\) finally show "x' \ ?rhs" . qed finally show "x \ ?rhs" . qed moreover have "?rhs \ ?lhs" using chain4 proof(rule ccpo_Sup_least) fix x assume "x \ (\x. \((\f. f x) ` Z)) ` Y" then obtain y where "y \ Y" "x = \((\f. f y) ` Z)" by blast note this(2) also have "\ \ ?lhs" using chain3 proof(rule ccpo_Sup_least) fix x' assume "x' \ (\f. f y) ` Z" then obtain f where "f \ Z" "x' = f y" by blast note this(2) also have "f y \ \(f ` Y)" using chain1[OF \f \ Z\] by(rule ccpo_Sup_upper)(simp add: \y \ Y\) also have "\ \ ?lhs" using chain2 by(rule ccpo_Sup_upper)(simp add: \f \ Z\) finally show "x' \ ?lhs" . qed finally show "x \ ?lhs" . qed ultimately show "?lhs = ?rhs" by (rule order.antisym) qed lemma fixp_mono: assumes fg: "fun_ord (\) f g" and f: "monotone (\) (\) f" and g: "monotone (\) (\) g" shows "ccpo_class.fixp f \ ccpo_class.fixp g" unfolding fixp_def proof(rule ccpo_Sup_least) fix x assume "x \ ccpo_class.iterates f" thus "x \ \ccpo_class.iterates g" proof induction case (step x) from f step.IH have "f x \ f (\ccpo_class.iterates g)" by(rule monotoneD) also have "\ \ g (\ccpo_class.iterates g)" using fg by(simp add: fun_ord_def) also have "\ = \ccpo_class.iterates g" by(fold fixp_def fixp_unfold[OF g]) simp finally show ?case . qed(blast intro: ccpo_Sup_least) qed(rule chain_iterates[OF f]) context fixes ordb :: "'b \ 'b \ bool" (infix "\" 60) begin lemma iterates_mono: assumes f: "f \ ccpo.iterates (fun_lub Sup) (fun_ord (\)) F" and mono: "\f. monotone (\) (\) f \ monotone (\) (\) (F f)" shows "monotone (\) (\) f" using f by(induction rule: ccpo.iterates.induct[OF ccpo_fun, consumes 1, case_names step Sup])(blast intro: mono mono_lub)+ lemma fixp_preserves_mono: assumes mono: "\x. monotone (fun_ord (\)) (\) (\f. F f x)" and mono2: "\f. monotone (\) (\) f \ monotone (\) (\) (F f)" shows "monotone (\) (\) (ccpo.fixp (fun_lub Sup) (fun_ord (\)) F)" (is "monotone _ _ ?fixp") proof(rule monotoneI) have mono: "monotone (fun_ord (\)) (fun_ord (\)) F" by(rule monotoneI)(auto simp add: fun_ord_def intro: monotoneD[OF mono]) let ?iter = "ccpo.iterates (fun_lub Sup) (fun_ord (\)) F" have chain: "\x. Complete_Partial_Order.chain (\) ((\f. f x) ` ?iter)" by(rule chain_imageI[OF ccpo.chain_iterates[OF ccpo_fun mono]])(simp add: fun_ord_def) fix x y assume "x \ y" show "?fixp x \ ?fixp y" apply (simp only: ccpo.fixp_def[OF ccpo_fun] fun_lub_apply) using chain proof(rule ccpo_Sup_least) fix x' assume "x' \ (\f. f x) ` ?iter" then obtain f where "f \ ?iter" "x' = f x" by blast note this(2) also have "f x \ f y" by(rule monotoneD[OF iterates_mono[OF \f \ ?iter\ mono2]])(blast intro: \x \ y\)+ also have "f y \ \((\f. f y) ` ?iter)" using chain by(rule ccpo_Sup_upper)(simp add: \f \ ?iter\) finally show "x' \ \" . qed qed end end lemma monotone2monotone: assumes 2: "\x. monotone ordb ordc (\y. f x y)" and t: "monotone orda ordb (\x. t x)" and 1: "\y. monotone orda ordc (\x. f x y)" and trans: "transp ordc" shows "monotone orda ordc (\x. f x (t x))" by(blast intro: monotoneI transpD[OF trans] monotoneD[OF t] monotoneD[OF 2] monotoneD[OF 1]) subsection \Continuity\ definition cont :: "('a set \ 'a) \ ('a \ 'a \ bool) \ ('b set \ 'b) \ ('b \ 'b \ bool) \ ('a \ 'b) \ bool" where "cont luba orda lubb ordb f \ (\Y. Complete_Partial_Order.chain orda Y \ Y \ {} \ f (luba Y) = lubb (f ` Y))" definition mcont :: "('a set \ 'a) \ ('a \ 'a \ bool) \ ('b set \ 'b) \ ('b \ 'b \ bool) \ ('a \ 'b) \ bool" where "mcont luba orda lubb ordb f \ monotone orda ordb f \ cont luba orda lubb ordb f" subsubsection \Theorem collection \cont_intro\\ named_theorems cont_intro "continuity and admissibility intro rules" ML \ (* apply cont_intro rules as intro and try to solve the remaining of the emerging subgoals with simp *) fun cont_intro_tac ctxt = REPEAT_ALL_NEW (resolve_tac ctxt (rev (Named_Theorems.get ctxt \<^named_theorems>\cont_intro\))) THEN_ALL_NEW (SOLVED' (simp_tac ctxt)) fun cont_intro_simproc ctxt ct = let fun mk_stmt t = t |> HOLogic.mk_Trueprop |> Thm.cterm_of ctxt |> Goal.init fun mk_thm t = case SINGLE (cont_intro_tac ctxt 1) (mk_stmt t) of SOME thm => SOME (Goal.finish ctxt thm RS @{thm Eq_TrueI}) | NONE => NONE in case Thm.term_of ct of t as Const (\<^const_name>\ccpo.admissible\, _) $ _ $ _ $ _ => mk_thm t | t as Const (\<^const_name>\mcont\, _) $ _ $ _ $ _ $ _ $ _ => mk_thm t | t as Const (\<^const_name>\monotone\, _) $ _ $ _ $ _ => mk_thm t | _ => NONE end handle THM _ => NONE | TYPE _ => NONE \ simproc_setup "cont_intro" ( "ccpo.admissible lub ord P" | "mcont lub ord lub' ord' f" | "monotone ord ord' f" ) = \K cont_intro_simproc\ lemmas [cont_intro] = call_mono let_mono if_mono option.const_mono tailrec.const_mono bind_mono declare if_mono[simp] lemma monotone_id' [cont_intro]: "monotone ord ord (\x. x)" by(simp add: monotone_def) lemma monotone_applyI: "monotone orda ordb F \ monotone (fun_ord orda) ordb (\f. F (f x))" by(rule monotoneI)(auto simp add: fun_ord_def dest: monotoneD) lemma monotone_if_fun [partial_function_mono]: "\ monotone (fun_ord orda) (fun_ord ordb) F; monotone (fun_ord orda) (fun_ord ordb) G \ \ monotone (fun_ord orda) (fun_ord ordb) (\f n. if c n then F f n else G f n)" by(simp add: monotone_def fun_ord_def) lemma monotone_fun_apply_fun [partial_function_mono]: "monotone (fun_ord (fun_ord ord)) (fun_ord ord) (\f n. f t (g n))" by(rule monotoneI)(simp add: fun_ord_def) lemma monotone_fun_ord_apply: "monotone orda (fun_ord ordb) f \ (\x. monotone orda ordb (\y. f y x))" by(auto simp add: monotone_def fun_ord_def) context preorder begin declare transp_le[cont_intro] lemma monotone_const [simp, cont_intro]: "monotone ord (\) (\_. c)" by(rule monotoneI) simp end lemma transp_le [cont_intro, simp]: "class.preorder ord (mk_less ord) \ transp ord" by(rule preorder.transp_le) context partial_function_definitions begin declare const_mono [cont_intro, simp] lemma transp_le [cont_intro, simp]: "transp leq" by(rule transpI)(rule leq_trans) lemma preorder [cont_intro, simp]: "class.preorder leq (mk_less leq)" by(unfold_locales)(auto simp add: mk_less_def intro: leq_refl leq_trans) declare ccpo[cont_intro, simp] end lemma contI [intro?]: "(\Y. \ Complete_Partial_Order.chain orda Y; Y \ {} \ \ f (luba Y) = lubb (f ` Y)) \ cont luba orda lubb ordb f" unfolding cont_def by blast lemma contD: "\ cont luba orda lubb ordb f; Complete_Partial_Order.chain orda Y; Y \ {} \ \ f (luba Y) = lubb (f ` Y)" unfolding cont_def by blast lemma cont_id [simp, cont_intro]: "\Sup. cont Sup ord Sup ord id" by(rule contI) simp lemma cont_id' [simp, cont_intro]: "\Sup. cont Sup ord Sup ord (\x. x)" using cont_id[unfolded id_def] . lemma cont_applyI [cont_intro]: assumes cont: "cont luba orda lubb ordb g" shows "cont (fun_lub luba) (fun_ord orda) lubb ordb (\f. g (f x))" by(rule contI)(drule chain_fun_ordD[where x=x], simp add: fun_lub_apply image_image contD[OF cont]) lemma call_cont: "cont (fun_lub lub) (fun_ord ord) lub ord (\f. f t)" by(simp add: cont_def fun_lub_apply) lemma cont_if [cont_intro]: "\ cont luba orda lubb ordb f; cont luba orda lubb ordb g \ \ cont luba orda lubb ordb (\x. if c then f x else g x)" by(cases c) simp_all lemma mcontI [intro?]: "\ monotone orda ordb f; cont luba orda lubb ordb f \ \ mcont luba orda lubb ordb f" by(simp add: mcont_def) lemma mcont_mono: "mcont luba orda lubb ordb f \ monotone orda ordb f" by(simp add: mcont_def) lemma mcont_cont [simp]: "mcont luba orda lubb ordb f \ cont luba orda lubb ordb f" by(simp add: mcont_def) lemma mcont_monoD: "\ mcont luba orda lubb ordb f; orda x y \ \ ordb (f x) (f y)" by(auto simp add: mcont_def dest: monotoneD) lemma mcont_contD: "\ mcont luba orda lubb ordb f; Complete_Partial_Order.chain orda Y; Y \ {} \ \ f (luba Y) = lubb (f ` Y)" by(auto simp add: mcont_def dest: contD) lemma mcont_call [cont_intro, simp]: "mcont (fun_lub lub) (fun_ord ord) lub ord (\f. f t)" by(simp add: mcont_def call_mono call_cont) lemma mcont_id' [cont_intro, simp]: "mcont lub ord lub ord (\x. x)" by(simp add: mcont_def monotone_id') lemma mcont_applyI: "mcont luba orda lubb ordb (\x. F x) \ mcont (fun_lub luba) (fun_ord orda) lubb ordb (\f. F (f x))" by(simp add: mcont_def monotone_applyI cont_applyI) lemma mcont_if [cont_intro, simp]: "\ mcont luba orda lubb ordb (\x. f x); mcont luba orda lubb ordb (\x. g x) \ \ mcont luba orda lubb ordb (\x. if c then f x else g x)" by(simp add: mcont_def cont_if) lemma cont_fun_lub_apply: "cont luba orda (fun_lub lubb) (fun_ord ordb) f \ (\x. cont luba orda lubb ordb (\y. f y x))" by(simp add: cont_def fun_lub_def fun_eq_iff)(auto simp add: image_def) lemma mcont_fun_lub_apply: "mcont luba orda (fun_lub lubb) (fun_ord ordb) f \ (\x. mcont luba orda lubb ordb (\y. f y x))" by(auto simp add: monotone_fun_ord_apply cont_fun_lub_apply mcont_def) context ccpo begin lemma cont_const [simp, cont_intro]: "cont luba orda Sup (\) (\x. c)" by (rule contI) (simp add: image_constant_conv cong del: SUP_cong_simp) lemma mcont_const [cont_intro, simp]: "mcont luba orda Sup (\) (\x. c)" by(simp add: mcont_def) lemma cont_apply: assumes 2: "\x. cont lubb ordb Sup (\) (\y. f x y)" and t: "cont luba orda lubb ordb (\x. t x)" and 1: "\y. cont luba orda Sup (\) (\x. f x y)" and mono: "monotone orda ordb (\x. t x)" and mono2: "\x. monotone ordb (\) (\y. f x y)" and mono1: "\y. monotone orda (\) (\x. f x y)" shows "cont luba orda Sup (\) (\x. f x (t x))" proof fix Y assume chain: "Complete_Partial_Order.chain orda Y" and "Y \ {}" moreover from chain have chain': "Complete_Partial_Order.chain ordb (t ` Y)" by(rule chain_imageI)(rule monotoneD[OF mono]) ultimately show "f (luba Y) (t (luba Y)) = \((\x. f x (t x)) ` Y)" by(simp add: contD[OF 1] contD[OF t] contD[OF 2] image_image) (rule diag_Sup[OF chain], auto intro: monotone2monotone[OF mono2 mono monotone_const transpI] monotoneD[OF mono1]) qed lemma mcont2mcont': "\ \x. mcont lub' ord' Sup (\) (\y. f x y); \y. mcont lub ord Sup (\) (\x. f x y); mcont lub ord lub' ord' (\y. t y) \ \ mcont lub ord Sup (\) (\x. f x (t x))" unfolding mcont_def by(blast intro: transp_le monotone2monotone cont_apply) lemma mcont2mcont: "\mcont lub' ord' Sup (\) (\x. f x); mcont lub ord lub' ord' (\x. t x)\ \ mcont lub ord Sup (\) (\x. f (t x))" by(rule mcont2mcont'[OF _ mcont_const]) context fixes ord :: "'b \ 'b \ bool" (infix "\" 60) and lub :: "'b set \ 'b" ("\") begin lemma cont_fun_lub_Sup: assumes chainM: "Complete_Partial_Order.chain (fun_ord (\)) M" and mcont [rule_format]: "\f\M. mcont lub (\) Sup (\) f" shows "cont lub (\) Sup (\) (fun_lub Sup M)" proof(rule contI) fix Y assume chain: "Complete_Partial_Order.chain (\) Y" and Y: "Y \ {}" from swap_Sup[OF chain chainM mcont[THEN mcont_mono]] show "fun_lub Sup M (\Y) = \(fun_lub Sup M ` Y)" by(simp add: mcont_contD[OF mcont chain Y] fun_lub_apply cong: image_cong) qed lemma mcont_fun_lub_Sup: "\ Complete_Partial_Order.chain (fun_ord (\)) M; \f\M. mcont lub ord Sup (\) f \ \ mcont lub (\) Sup (\) (fun_lub Sup M)" by(simp add: mcont_def cont_fun_lub_Sup mono_lub) lemma iterates_mcont: assumes f: "f \ ccpo.iterates (fun_lub Sup) (fun_ord (\)) F" and mono: "\f. mcont lub (\) Sup (\) f \ mcont lub (\) Sup (\) (F f)" shows "mcont lub (\) Sup (\) f" using f by(induction rule: ccpo.iterates.induct[OF ccpo_fun, consumes 1, case_names step Sup])(blast intro: mono mcont_fun_lub_Sup)+ lemma fixp_preserves_mcont: assumes mono: "\x. monotone (fun_ord (\)) (\) (\f. F f x)" and mcont: "\f. mcont lub (\) Sup (\) f \ mcont lub (\) Sup (\) (F f)" shows "mcont lub (\) Sup (\) (ccpo.fixp (fun_lub Sup) (fun_ord (\)) F)" (is "mcont _ _ _ _ ?fixp") unfolding mcont_def proof(intro conjI monotoneI contI) have mono: "monotone (fun_ord (\)) (fun_ord (\)) F" by(rule monotoneI)(auto simp add: fun_ord_def intro: monotoneD[OF mono]) let ?iter = "ccpo.iterates (fun_lub Sup) (fun_ord (\)) F" have chain: "\x. Complete_Partial_Order.chain (\) ((\f. f x) ` ?iter)" by(rule chain_imageI[OF ccpo.chain_iterates[OF ccpo_fun mono]])(simp add: fun_ord_def) { fix x y assume "x \ y" show "?fixp x \ ?fixp y" apply (simp only: ccpo.fixp_def[OF ccpo_fun] fun_lub_apply) using chain proof(rule ccpo_Sup_least) fix x' assume "x' \ (\f. f x) ` ?iter" then obtain f where "f \ ?iter" "x' = f x" by blast note this(2) also from _ \x \ y\ have "f x \ f y" by(rule mcont_monoD[OF iterates_mcont[OF \f \ ?iter\ mcont]]) also have "f y \ \((\f. f y) ` ?iter)" using chain by(rule ccpo_Sup_upper)(simp add: \f \ ?iter\) finally show "x' \ \" . qed next fix Y assume chain: "Complete_Partial_Order.chain (\) Y" and Y: "Y \ {}" { fix f assume "f \ ?iter" hence "f (\Y) = \(f ` Y)" using mcont chain Y by(rule mcont_contD[OF iterates_mcont]) } moreover have "\((\f. \(f ` Y)) ` ?iter) = \((\x. \((\f. f x) ` ?iter)) ` Y)" using chain ccpo.chain_iterates[OF ccpo_fun mono] by(rule swap_Sup)(rule mcont_mono[OF iterates_mcont[OF _ mcont]]) ultimately show "?fixp (\Y) = \(?fixp ` Y)" unfolding ccpo.fixp_def[OF ccpo_fun] by(simp add: fun_lub_apply cong: image_cong) } qed end context fixes F :: "'c \ 'c" and U :: "'c \ 'b \ 'a" and C :: "('b \ 'a) \ 'c" and f assumes mono: "\x. monotone (fun_ord (\)) (\) (\f. U (F (C f)) x)" and eq: "f \ C (ccpo.fixp (fun_lub Sup) (fun_ord (\)) (\f. U (F (C f))))" and inverse: "\f. U (C f) = f" begin lemma fixp_preserves_mono_uc: assumes mono2: "\f. monotone ord (\) (U f) \ monotone ord (\) (U (F f))" shows "monotone ord (\) (U f)" using fixp_preserves_mono[OF mono mono2] by(subst eq)(simp add: inverse) lemma fixp_preserves_mcont_uc: assumes mcont: "\f. mcont lubb ordb Sup (\) (U f) \ mcont lubb ordb Sup (\) (U (F f))" shows "mcont lubb ordb Sup (\) (U f)" using fixp_preserves_mcont[OF mono mcont] by(subst eq)(simp add: inverse) end lemmas fixp_preserves_mono1 = fixp_preserves_mono_uc[of "\x. x" _ "\x. x", OF _ _ refl] lemmas fixp_preserves_mono2 = fixp_preserves_mono_uc[of "case_prod" _ "curry", unfolded case_prod_curry curry_case_prod, OF _ _ refl] lemmas fixp_preserves_mono3 = fixp_preserves_mono_uc[of "\f. case_prod (case_prod f)" _ "\f. curry (curry f)", unfolded case_prod_curry curry_case_prod, OF _ _ refl] lemmas fixp_preserves_mono4 = fixp_preserves_mono_uc[of "\f. case_prod (case_prod (case_prod f))" _ "\f. curry (curry (curry f))", unfolded case_prod_curry curry_case_prod, OF _ _ refl] lemmas fixp_preserves_mcont1 = fixp_preserves_mcont_uc[of "\x. x" _ "\x. x", OF _ _ refl] lemmas fixp_preserves_mcont2 = fixp_preserves_mcont_uc[of "case_prod" _ "curry", unfolded case_prod_curry curry_case_prod, OF _ _ refl] lemmas fixp_preserves_mcont3 = fixp_preserves_mcont_uc[of "\f. case_prod (case_prod f)" _ "\f. curry (curry f)", unfolded case_prod_curry curry_case_prod, OF _ _ refl] lemmas fixp_preserves_mcont4 = fixp_preserves_mcont_uc[of "\f. case_prod (case_prod (case_prod f))" _ "\f. curry (curry (curry f))", unfolded case_prod_curry curry_case_prod, OF _ _ refl] end lemma (in preorder) monotone_if_bot: fixes bot assumes mono: "\x y. \ x \ y; \ (x \ bound) \ \ ord (f x) (f y)" and bot: "\x. \ x \ bound \ ord bot (f x)" "ord bot bot" shows "monotone (\) ord (\x. if x \ bound then bot else f x)" by(rule monotoneI)(auto intro: bot intro: mono order_trans) lemma (in ccpo) mcont_if_bot: fixes bot and lub ("\") and ord (infix "\" 60) assumes ccpo: "class.ccpo lub (\) lt" and mono: "\x y. \ x \ y; \ x \ bound \ \ f x \ f y" and cont: "\Y. \ Complete_Partial_Order.chain (\) Y; Y \ {}; \x. x \ Y \ \ x \ bound \ \ f (\Y) = \(f ` Y)" and bot: "\x. \ x \ bound \ bot \ f x" shows "mcont Sup (\) lub (\) (\x. if x \ bound then bot else f x)" (is "mcont _ _ _ _ ?g") proof(intro mcontI contI) interpret c: ccpo lub "(\)" lt by(fact ccpo) show "monotone (\) (\) ?g" by(rule monotone_if_bot)(simp_all add: mono bot) fix Y assume chain: "Complete_Partial_Order.chain (\) Y" and Y: "Y \ {}" show "?g (\Y) = \(?g ` Y)" proof(cases "Y \ {x. x \ bound}") case True hence "\Y \ bound" using chain by(auto intro: ccpo_Sup_least) moreover have "Y \ {x. \ x \ bound} = {}" using True by auto ultimately show ?thesis using True Y by (auto simp add: image_constant_conv cong del: c.SUP_cong_simp) next case False let ?Y = "Y \ {x. \ x \ bound}" have chain': "Complete_Partial_Order.chain (\) ?Y" using chain by(rule chain_subset) simp from False obtain y where ybound: "\ y \ bound" and y: "y \ Y" by blast hence "\ \Y \ bound" by (metis ccpo_Sup_upper chain order.trans) hence "?g (\Y) = f (\Y)" by simp also have "\Y \ \?Y" using chain proof(rule ccpo_Sup_least) fix x assume x: "x \ Y" show "x \ \?Y" proof(cases "x \ bound") case True with chainD[OF chain x y] have "x \ y" using ybound by(auto intro: order_trans) thus ?thesis by(rule order_trans)(auto intro: ccpo_Sup_upper[OF chain'] simp add: y ybound) qed(auto intro: ccpo_Sup_upper[OF chain'] simp add: x) qed hence "\Y = \?Y" by(rule order.antisym)(blast intro: ccpo_Sup_least[OF chain'] ccpo_Sup_upper[OF chain]) hence "f (\Y) = f (\?Y)" by simp also have "f (\?Y) = \(f ` ?Y)" using chain' by(rule cont)(insert y ybound, auto) also have "\(f ` ?Y) = \(?g ` Y)" proof(cases "Y \ {x. x \ bound} = {}") case True hence "f ` ?Y = ?g ` Y" by auto thus ?thesis by(rule arg_cong) next case False have chain'': "Complete_Partial_Order.chain (\) (insert bot (f ` ?Y))" using chain by(auto intro!: chainI bot dest: chainD intro: mono) hence chain''': "Complete_Partial_Order.chain (\) (f ` ?Y)" by(rule chain_subset) blast have "bot \ \(f ` ?Y)" using y ybound by(blast intro: c.order_trans[OF bot] c.ccpo_Sup_upper[OF chain''']) hence "\(insert bot (f ` ?Y)) \ \(f ` ?Y)" using chain'' by(auto intro: c.ccpo_Sup_least c.ccpo_Sup_upper[OF chain''']) with _ have "\ = \(insert bot (f ` ?Y))" by(rule c.order.antisym)(blast intro: c.ccpo_Sup_least[OF chain'''] c.ccpo_Sup_upper[OF chain'']) also have "insert bot (f ` ?Y) = ?g ` Y" using False by auto finally show ?thesis . qed finally show ?thesis . qed qed context partial_function_definitions begin lemma mcont_const [cont_intro, simp]: "mcont luba orda lub leq (\x. c)" by(rule ccpo.mcont_const)(rule Partial_Function.ccpo[OF partial_function_definitions_axioms]) lemmas [cont_intro, simp] = ccpo.cont_const[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemma mono2mono: assumes "monotone ordb leq (\y. f y)" "monotone orda ordb (\x. t x)" shows "monotone orda leq (\x. f (t x))" using assms by(rule monotone2monotone) simp_all lemmas mcont2mcont' = ccpo.mcont2mcont'[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas mcont2mcont = ccpo.mcont2mcont[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mono1 = ccpo.fixp_preserves_mono1[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mono2 = ccpo.fixp_preserves_mono2[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mono3 = ccpo.fixp_preserves_mono3[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mono4 = ccpo.fixp_preserves_mono4[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mcont1 = ccpo.fixp_preserves_mcont1[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mcont2 = ccpo.fixp_preserves_mcont2[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mcont3 = ccpo.fixp_preserves_mcont3[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemmas fixp_preserves_mcont4 = ccpo.fixp_preserves_mcont4[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] lemma monotone_if_bot: fixes bot assumes g: "\x. g x = (if leq x bound then bot else f x)" and mono: "\x y. \ leq x y; \ leq x bound \ \ ord (f x) (f y)" and bot: "\x. \ leq x bound \ ord bot (f x)" "ord bot bot" shows "monotone leq ord g" unfolding g[abs_def] using preorder mono bot by(rule preorder.monotone_if_bot) lemma mcont_if_bot: fixes bot assumes ccpo: "class.ccpo lub' ord (mk_less ord)" and bot: "\x. \ leq x bound \ ord bot (f x)" and g: "\x. g x = (if leq x bound then bot else f x)" and mono: "\x y. \ leq x y; \ leq x bound \ \ ord (f x) (f y)" and cont: "\Y. \ Complete_Partial_Order.chain leq Y; Y \ {}; \x. x \ Y \ \ leq x bound \ \ f (lub Y) = lub' (f ` Y)" shows "mcont lub leq lub' ord g" unfolding g[abs_def] using ccpo mono cont bot by(rule ccpo.mcont_if_bot[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]]) end subsection \Admissibility\ lemma admissible_subst: assumes adm: "ccpo.admissible luba orda (\x. P x)" and mcont: "mcont lubb ordb luba orda f" shows "ccpo.admissible lubb ordb (\x. P (f x))" apply(rule ccpo.admissibleI) apply(frule (1) mcont_contD[OF mcont]) apply(auto intro: ccpo.admissibleD[OF adm] chain_imageI dest: mcont_monoD[OF mcont]) done lemmas [simp, cont_intro] = admissible_all admissible_ball admissible_const admissible_conj lemma admissible_disj' [simp, cont_intro]: "\ class.ccpo lub ord (mk_less ord); ccpo.admissible lub ord P; ccpo.admissible lub ord Q \ \ ccpo.admissible lub ord (\x. P x \ Q x)" by(rule ccpo.admissible_disj) lemma admissible_imp' [cont_intro]: "\ class.ccpo lub ord (mk_less ord); ccpo.admissible lub ord (\x. \ P x); ccpo.admissible lub ord (\x. Q x) \ \ ccpo.admissible lub ord (\x. P x \ Q x)" unfolding imp_conv_disj by(rule ccpo.admissible_disj) lemma admissible_imp [cont_intro]: "(Q \ ccpo.admissible lub ord (\x. P x)) \ ccpo.admissible lub ord (\x. Q \ P x)" by(rule ccpo.admissibleI)(auto dest: ccpo.admissibleD) lemma admissible_not_mem' [THEN admissible_subst, cont_intro, simp]: shows admissible_not_mem: "ccpo.admissible Union (\) (\A. x \ A)" by(rule ccpo.admissibleI) auto lemma admissible_eqI: assumes f: "cont luba orda lub ord (\x. f x)" and g: "cont luba orda lub ord (\x. g x)" shows "ccpo.admissible luba orda (\x. f x = g x)" apply(rule ccpo.admissibleI) apply(simp_all add: contD[OF f] contD[OF g] cong: image_cong) done corollary admissible_eq_mcontI [cont_intro]: "\ mcont luba orda lub ord (\x. f x); mcont luba orda lub ord (\x. g x) \ \ ccpo.admissible luba orda (\x. f x = g x)" by(rule admissible_eqI)(auto simp add: mcont_def) lemma admissible_iff [cont_intro, simp]: "\ ccpo.admissible lub ord (\x. P x \ Q x); ccpo.admissible lub ord (\x. Q x \ P x) \ \ ccpo.admissible lub ord (\x. P x \ Q x)" by(subst iff_conv_conj_imp)(rule admissible_conj) context ccpo begin lemma admissible_leI: assumes f: "mcont luba orda Sup (\) (\x. f x)" and g: "mcont luba orda Sup (\) (\x. g x)" shows "ccpo.admissible luba orda (\x. f x \ g x)" proof(rule ccpo.admissibleI) fix A assume chain: "Complete_Partial_Order.chain orda A" and le: "\x\A. f x \ g x" and False: "A \ {}" have "f (luba A) = \(f ` A)" by(simp add: mcont_contD[OF f] chain False) also have "\ \ \(g ` A)" proof(rule ccpo_Sup_least) from chain show "Complete_Partial_Order.chain (\) (f ` A)" by(rule chain_imageI)(rule mcont_monoD[OF f]) fix x assume "x \ f ` A" then obtain y where "y \ A" "x = f y" by blast note this(2) also have "f y \ g y" using le \y \ A\ by simp also have "Complete_Partial_Order.chain (\) (g ` A)" using chain by(rule chain_imageI)(rule mcont_monoD[OF g]) hence "g y \ \(g ` A)" by(rule ccpo_Sup_upper)(simp add: \y \ A\) finally show "x \ \" . qed also have "\ = g (luba A)" by(simp add: mcont_contD[OF g] chain False) finally show "f (luba A) \ g (luba A)" . qed end lemma admissible_leI: fixes ord (infix "\" 60) and lub ("\") assumes "class.ccpo lub (\) (mk_less (\))" and "mcont luba orda lub (\) (\x. f x)" and "mcont luba orda lub (\) (\x. g x)" shows "ccpo.admissible luba orda (\x. f x \ g x)" using assms by(rule ccpo.admissible_leI) declare ccpo_class.admissible_leI[cont_intro] context ccpo begin lemma admissible_not_below: "ccpo.admissible Sup (\) (\x. \ (\) x y)" by(rule ccpo.admissibleI)(simp add: ccpo_Sup_below_iff) end lemma (in preorder) preorder [cont_intro, simp]: "class.preorder (\) (mk_less (\))" by(unfold_locales)(auto simp add: mk_less_def intro: order_trans) context partial_function_definitions begin lemmas [cont_intro, simp] = admissible_leI[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] ccpo.admissible_not_below[THEN admissible_subst, OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] end setup \Sign.map_naming (Name_Space.mandatory_path "ccpo")\ inductive compact :: "('a set \ 'a) \ ('a \ 'a \ bool) \ 'a \ bool" for lub ord x where compact: "\ ccpo.admissible lub ord (\y. \ ord x y); ccpo.admissible lub ord (\y. x \ y) \ \ compact lub ord x" setup \Sign.map_naming Name_Space.parent_path\ context ccpo begin lemma compactI: assumes "ccpo.admissible Sup (\) (\y. \ x \ y)" shows "ccpo.compact Sup (\) x" using assms proof(rule ccpo.compact.intros) have neq: "(\y. x \ y) = (\y. \ x \ y \ \ y \ x)" by(auto) show "ccpo.admissible Sup (\) (\y. x \ y)" by(subst neq)(rule admissible_disj admissible_not_below assms)+ qed lemma compact_bot: assumes "x = Sup {}" shows "ccpo.compact Sup (\) x" proof(rule compactI) show "ccpo.admissible Sup (\) (\y. \ x \ y)" using assms by(auto intro!: ccpo.admissibleI intro: ccpo_Sup_least chain_empty) qed end lemma admissible_compact_neq' [THEN admissible_subst, cont_intro, simp]: shows admissible_compact_neq: "ccpo.compact lub ord k \ ccpo.admissible lub ord (\x. k \ x)" by(simp add: ccpo.compact.simps) lemma admissible_neq_compact' [THEN admissible_subst, cont_intro, simp]: shows admissible_neq_compact: "ccpo.compact lub ord k \ ccpo.admissible lub ord (\x. x \ k)" by(subst eq_commute)(rule admissible_compact_neq) context partial_function_definitions begin lemmas [cont_intro, simp] = ccpo.compact_bot[OF Partial_Function.ccpo[OF partial_function_definitions_axioms]] end context ccpo begin lemma fixp_strong_induct: assumes [cont_intro]: "ccpo.admissible Sup (\) P" and mono: "monotone (\) (\) f" and bot: "P (\{})" and step: "\x. \ x \ ccpo_class.fixp f; P x \ \ P (f x)" shows "P (ccpo_class.fixp f)" proof(rule fixp_induct[where P="\x. x \ ccpo_class.fixp f \ P x", THEN conjunct2]) note [cont_intro] = admissible_leI show "ccpo.admissible Sup (\) (\x. x \ ccpo_class.fixp f \ P x)" by simp next show "\{} \ ccpo_class.fixp f \ P (\{})" by(auto simp add: bot intro: ccpo_Sup_least chain_empty) next fix x assume "x \ ccpo_class.fixp f \ P x" thus "f x \ ccpo_class.fixp f \ P (f x)" by(subst fixp_unfold[OF mono])(auto dest: monotoneD[OF mono] intro: step) qed(rule mono) end context partial_function_definitions begin lemma fixp_strong_induct_uc: fixes F :: "'c \ 'c" and U :: "'c \ 'b \ 'a" and C :: "('b \ 'a) \ 'c" and P :: "('b \ 'a) \ bool" assumes mono: "\x. mono_body (\f. U (F (C f)) x)" and eq: "f \ C (fixp_fun (\f. U (F (C f))))" and inverse: "\f. U (C f) = f" and adm: "ccpo.admissible lub_fun le_fun P" and bot: "P (\_. lub {})" and step: "\f'. \ P (U f'); le_fun (U f') (U f) \ \ P (U (F f'))" shows "P (U f)" unfolding eq inverse apply (rule ccpo.fixp_strong_induct[OF ccpo adm]) apply (insert mono, auto simp: monotone_def fun_ord_def bot fun_lub_def)[2] apply (rule_tac f'5="C x" in step) apply (simp_all add: inverse eq) done end subsection \\<^term>\(=)\ as order\ definition lub_singleton :: "('a set \ 'a) \ bool" where "lub_singleton lub \ (\a. lub {a} = a)" definition the_Sup :: "'a set \ 'a" where "the_Sup A = (THE a. a \ A)" lemma lub_singleton_the_Sup [cont_intro, simp]: "lub_singleton the_Sup" by(simp add: lub_singleton_def the_Sup_def) lemma (in ccpo) lub_singleton: "lub_singleton Sup" by(simp add: lub_singleton_def) lemma (in partial_function_definitions) lub_singleton [cont_intro, simp]: "lub_singleton lub" by(rule ccpo.lub_singleton)(rule Partial_Function.ccpo[OF partial_function_definitions_axioms]) lemma preorder_eq [cont_intro, simp]: "class.preorder (=) (mk_less (=))" by(unfold_locales)(simp_all add: mk_less_def) lemma monotone_eqI [cont_intro]: assumes "class.preorder ord (mk_less ord)" shows "monotone (=) ord f" proof - interpret preorder ord "mk_less ord" by fact show ?thesis by(simp add: monotone_def) qed lemma cont_eqI [cont_intro]: fixes f :: "'a \ 'b" assumes "lub_singleton lub" shows "cont the_Sup (=) lub ord f" proof(rule contI) fix Y :: "'a set" assume "Complete_Partial_Order.chain (=) Y" "Y \ {}" then obtain a where "Y = {a}" by(auto simp add: chain_def) thus "f (the_Sup Y) = lub (f ` Y)" using assms by(simp add: the_Sup_def lub_singleton_def) qed lemma mcont_eqI [cont_intro, simp]: "\ class.preorder ord (mk_less ord); lub_singleton lub \ \ mcont the_Sup (=) lub ord f" by(simp add: mcont_def cont_eqI monotone_eqI) subsection \ccpo for products\ definition prod_lub :: "('a set \ 'a) \ ('b set \ 'b) \ ('a \ 'b) set \ 'a \ 'b" where "prod_lub Sup_a Sup_b Y = (Sup_a (fst ` Y), Sup_b (snd ` Y))" lemma lub_singleton_prod_lub [cont_intro, simp]: "\ lub_singleton luba; lub_singleton lubb \ \ lub_singleton (prod_lub luba lubb)" by(simp add: lub_singleton_def prod_lub_def) lemma prod_lub_empty [simp]: "prod_lub luba lubb {} = (luba {}, lubb {})" by(simp add: prod_lub_def) lemma preorder_rel_prodI [cont_intro, simp]: assumes "class.preorder orda (mk_less orda)" and "class.preorder ordb (mk_less ordb)" shows "class.preorder (rel_prod orda ordb) (mk_less (rel_prod orda ordb))" proof - interpret a: preorder orda "mk_less orda" by fact interpret b: preorder ordb "mk_less ordb" by fact show ?thesis by(unfold_locales)(auto simp add: mk_less_def intro: a.order_trans b.order_trans) qed lemma order_rel_prodI: assumes a: "class.order orda (mk_less orda)" and b: "class.order ordb (mk_less ordb)" shows "class.order (rel_prod orda ordb) (mk_less (rel_prod orda ordb))" (is "class.order ?ord ?ord'") proof(intro class.order.intro class.order_axioms.intro) interpret a: order orda "mk_less orda" by(fact a) interpret b: order ordb "mk_less ordb" by(fact b) show "class.preorder ?ord ?ord'" by(rule preorder_rel_prodI) unfold_locales fix x y assume "?ord x y" "?ord y x" thus "x = y" by(cases x y rule: prod.exhaust[case_product prod.exhaust]) auto qed lemma monotone_rel_prodI: assumes mono2: "\a. monotone ordb ordc (\b. f (a, b))" and mono1: "\b. monotone orda ordc (\a. f (a, b))" and a: "class.preorder orda (mk_less orda)" and b: "class.preorder ordb (mk_less ordb)" and c: "class.preorder ordc (mk_less ordc)" shows "monotone (rel_prod orda ordb) ordc f" proof - interpret a: preorder orda "mk_less orda" by(rule a) interpret b: preorder ordb "mk_less ordb" by(rule b) interpret c: preorder ordc "mk_less ordc" by(rule c) show ?thesis using mono2 mono1 by(auto 7 2 simp add: monotone_def intro: c.order_trans) qed lemma monotone_rel_prodD1: assumes mono: "monotone (rel_prod orda ordb) ordc f" and preorder: "class.preorder ordb (mk_less ordb)" shows "monotone orda ordc (\a. f (a, b))" proof - interpret preorder ordb "mk_less ordb" by(rule preorder) show ?thesis using mono by(simp add: monotone_def) qed lemma monotone_rel_prodD2: assumes mono: "monotone (rel_prod orda ordb) ordc f" and preorder: "class.preorder orda (mk_less orda)" shows "monotone ordb ordc (\b. f (a, b))" proof - interpret preorder orda "mk_less orda" by(rule preorder) show ?thesis using mono by(simp add: monotone_def) qed lemma monotone_case_prodI: "\ \a. monotone ordb ordc (f a); \b. monotone orda ordc (\a. f a b); class.preorder orda (mk_less orda); class.preorder ordb (mk_less ordb); class.preorder ordc (mk_less ordc) \ \ monotone (rel_prod orda ordb) ordc (case_prod f)" by(rule monotone_rel_prodI) simp_all lemma monotone_case_prodD1: assumes mono: "monotone (rel_prod orda ordb) ordc (case_prod f)" and preorder: "class.preorder ordb (mk_less ordb)" shows "monotone orda ordc (\a. f a b)" using monotone_rel_prodD1[OF assms] by simp lemma monotone_case_prodD2: assumes mono: "monotone (rel_prod orda ordb) ordc (case_prod f)" and preorder: "class.preorder orda (mk_less orda)" shows "monotone ordb ordc (f a)" using monotone_rel_prodD2[OF assms] by simp context fixes orda ordb ordc assumes a: "class.preorder orda (mk_less orda)" and b: "class.preorder ordb (mk_less ordb)" and c: "class.preorder ordc (mk_less ordc)" begin lemma monotone_rel_prod_iff: "monotone (rel_prod orda ordb) ordc f \ (\a. monotone ordb ordc (\b. f (a, b))) \ (\b. monotone orda ordc (\a. f (a, b)))" using a b c by(blast intro: monotone_rel_prodI dest: monotone_rel_prodD1 monotone_rel_prodD2) lemma monotone_case_prod_iff [simp]: "monotone (rel_prod orda ordb) ordc (case_prod f) \ (\a. monotone ordb ordc (f a)) \ (\b. monotone orda ordc (\a. f a b))" by(simp add: monotone_rel_prod_iff) end lemma monotone_case_prod_apply_iff: "monotone orda ordb (\x. (case_prod f x) y) \ monotone orda ordb (case_prod (\a b. f a b y))" by(simp add: monotone_def) lemma monotone_case_prod_applyD: "monotone orda ordb (\x. (case_prod f x) y) \ monotone orda ordb (case_prod (\a b. f a b y))" by(simp add: monotone_case_prod_apply_iff) lemma monotone_case_prod_applyI: "monotone orda ordb (case_prod (\a b. f a b y)) \ monotone orda ordb (\x. (case_prod f x) y)" by(simp add: monotone_case_prod_apply_iff) lemma cont_case_prod_apply_iff: "cont luba orda lubb ordb (\x. (case_prod f x) y) \ cont luba orda lubb ordb (case_prod (\a b. f a b y))" by(simp add: cont_def split_def) lemma cont_case_prod_applyI: "cont luba orda lubb ordb (case_prod (\a b. f a b y)) \ cont luba orda lubb ordb (\x. (case_prod f x) y)" by(simp add: cont_case_prod_apply_iff) lemma cont_case_prod_applyD: "cont luba orda lubb ordb (\x. (case_prod f x) y) \ cont luba orda lubb ordb (case_prod (\a b. f a b y))" by(simp add: cont_case_prod_apply_iff) lemma mcont_case_prod_apply_iff [simp]: "mcont luba orda lubb ordb (\x. (case_prod f x) y) \ mcont luba orda lubb ordb (case_prod (\a b. f a b y))" by(simp add: mcont_def monotone_case_prod_apply_iff cont_case_prod_apply_iff) lemma cont_prodD1: assumes cont: "cont (prod_lub luba lubb) (rel_prod orda ordb) lubc ordc f" and "class.preorder orda (mk_less orda)" and luba: "lub_singleton luba" shows "cont lubb ordb lubc ordc (\y. f (x, y))" proof(rule contI) interpret preorder orda "mk_less orda" by fact fix Y :: "'b set" let ?Y = "{x} \ Y" assume "Complete_Partial_Order.chain ordb Y" "Y \ {}" hence "Complete_Partial_Order.chain (rel_prod orda ordb) ?Y" "?Y \ {}" by(simp_all add: chain_def) with cont have "f (prod_lub luba lubb ?Y) = lubc (f ` ?Y)" by(rule contD) moreover have "f ` ?Y = (\y. f (x, y)) ` Y" by auto ultimately show "f (x, lubb Y) = lubc ((\y. f (x, y)) ` Y)" using luba by(simp add: prod_lub_def \Y \ {}\ lub_singleton_def) qed lemma cont_prodD2: assumes cont: "cont (prod_lub luba lubb) (rel_prod orda ordb) lubc ordc f" and "class.preorder ordb (mk_less ordb)" and lubb: "lub_singleton lubb" shows "cont luba orda lubc ordc (\x. f (x, y))" proof(rule contI) interpret preorder ordb "mk_less ordb" by fact fix Y assume Y: "Complete_Partial_Order.chain orda Y" "Y \ {}" let ?Y = "Y \ {y}" have "f (luba Y, y) = f (prod_lub luba lubb ?Y)" using lubb by(simp add: prod_lub_def Y lub_singleton_def) also from Y have "Complete_Partial_Order.chain (rel_prod orda ordb) ?Y" "?Y \ {}" by(simp_all add: chain_def) with cont have "f (prod_lub luba lubb ?Y) = lubc (f ` ?Y)" by(rule contD) also have "f ` ?Y = (\x. f (x, y)) ` Y" by auto finally show "f (luba Y, y) = lubc \" . qed lemma cont_case_prodD1: assumes "cont (prod_lub luba lubb) (rel_prod orda ordb) lubc ordc (case_prod f)" and "class.preorder orda (mk_less orda)" and "lub_singleton luba" shows "cont lubb ordb lubc ordc (f x)" using cont_prodD1[OF assms] by simp lemma cont_case_prodD2: assumes "cont (prod_lub luba lubb) (rel_prod orda ordb) lubc ordc (case_prod f)" and "class.preorder ordb (mk_less ordb)" and "lub_singleton lubb" shows "cont luba orda lubc ordc (\x. f x y)" using cont_prodD2[OF assms] by simp context ccpo begin lemma cont_prodI: assumes mono: "monotone (rel_prod orda ordb) (\) f" and cont1: "\x. cont lubb ordb Sup (\) (\y. f (x, y))" and cont2: "\y. cont luba orda Sup (\) (\x. f (x, y))" and "class.preorder orda (mk_less orda)" and "class.preorder ordb (mk_less ordb)" shows "cont (prod_lub luba lubb) (rel_prod orda ordb) Sup (\) f" proof(rule contI) interpret a: preorder orda "mk_less orda" by fact interpret b: preorder ordb "mk_less ordb" by fact fix Y assume chain: "Complete_Partial_Order.chain (rel_prod orda ordb) Y" and "Y \ {}" have "f (prod_lub luba lubb Y) = f (luba (fst ` Y), lubb (snd ` Y))" by(simp add: prod_lub_def) also from cont2 have "f (luba (fst ` Y), lubb (snd ` Y)) = \((\x. f (x, lubb (snd ` Y))) ` fst ` Y)" by(rule contD)(simp_all add: chain_rel_prodD1[OF chain] \Y \ {}\) also from cont1 have "\x. f (x, lubb (snd ` Y)) = \((\y. f (x, y)) ` snd ` Y)" by(rule contD)(simp_all add: chain_rel_prodD2[OF chain] \Y \ {}\) hence "\((\x. f (x, lubb (snd ` Y))) ` fst ` Y) = \((\x. \ x) ` fst ` Y)" by simp also have "\ = \((\x. f (fst x, snd x)) ` Y)" unfolding image_image split_def using chain apply(rule diag_Sup) using monotoneD[OF mono] by(auto intro: monotoneI) finally show "f (prod_lub luba lubb Y) = \(f ` Y)" by simp qed lemma cont_case_prodI: assumes "monotone (rel_prod orda ordb) (\) (case_prod f)" and "\x. cont lubb ordb Sup (\) (\y. f x y)" and "\y. cont luba orda Sup (\) (\x. f x y)" and "class.preorder orda (mk_less orda)" and "class.preorder ordb (mk_less ordb)" shows "cont (prod_lub luba lubb) (rel_prod orda ordb) Sup (\) (case_prod f)" by(rule cont_prodI)(simp_all add: assms) lemma cont_case_prod_iff: "\ monotone (rel_prod orda ordb) (\) (case_prod f); class.preorder orda (mk_less orda); lub_singleton luba; class.preorder ordb (mk_less ordb); lub_singleton lubb \ \ cont (prod_lub luba lubb) (rel_prod orda ordb) Sup (\) (case_prod f) \ (\x. cont lubb ordb Sup (\) (\y. f x y)) \ (\y. cont luba orda Sup (\) (\x. f x y))" by(blast dest: cont_case_prodD1 cont_case_prodD2 intro: cont_case_prodI) end context partial_function_definitions begin lemma mono2mono2: assumes f: "monotone (rel_prod ordb ordc) leq (\(x, y). f x y)" and t: "monotone orda ordb (\x. t x)" and t': "monotone orda ordc (\x. t' x)" shows "monotone orda leq (\x. f (t x) (t' x))" proof(rule monotoneI) fix x y assume "orda x y" hence "rel_prod ordb ordc (t x, t' x) (t y, t' y)" using t t' by(auto dest: monotoneD) from monotoneD[OF f this] show "leq (f (t x) (t' x)) (f (t y) (t' y))" by simp qed lemma cont_case_prodI [cont_intro]: "\ monotone (rel_prod orda ordb) leq (case_prod f); \x. cont lubb ordb lub leq (\y. f x y); \y. cont luba orda lub leq (\x. f x y); class.preorder orda (mk_less orda); class.preorder ordb (mk_less ordb) \ \ cont (prod_lub luba lubb) (rel_prod orda ordb) lub leq (case_prod f)" by(rule ccpo.cont_case_prodI)(rule Partial_Function.ccpo[OF partial_function_definitions_axioms]) lemma cont_case_prod_iff: "\ monotone (rel_prod orda ordb) leq (case_prod f); class.preorder orda (mk_less orda); lub_singleton luba; class.preorder ordb (mk_less ordb); lub_singleton lubb \ \ cont (prod_lub luba lubb) (rel_prod orda ordb) lub leq (case_prod f) \ (\x. cont lubb ordb lub leq (\y. f x y)) \ (\y. cont luba orda lub leq (\x. f x y))" by(blast dest: cont_case_prodD1 cont_case_prodD2 intro: cont_case_prodI) lemma mcont_case_prod_iff [simp]: "\ class.preorder orda (mk_less orda); lub_singleton luba; class.preorder ordb (mk_less ordb); lub_singleton lubb \ \ mcont (prod_lub luba lubb) (rel_prod orda ordb) lub leq (case_prod f) \ (\x. mcont lubb ordb lub leq (\y. f x y)) \ (\y. mcont luba orda lub leq (\x. f x y))" unfolding mcont_def by(auto simp add: cont_case_prod_iff) end lemma mono2mono_case_prod [cont_intro]: assumes "\x y. monotone orda ordb (\f. pair f x y)" shows "monotone orda ordb (\f. case_prod (pair f) x)" by(rule monotoneI)(auto split: prod.split dest: monotoneD[OF assms]) subsection \Complete lattices as ccpo\ context complete_lattice begin lemma complete_lattice_ccpo: "class.ccpo Sup (\) (<)" by(unfold_locales)(fast intro: Sup_upper Sup_least)+ lemma complete_lattice_ccpo': "class.ccpo Sup (\) (mk_less (\))" by(unfold_locales)(auto simp add: mk_less_def intro: Sup_upper Sup_least) lemma complete_lattice_partial_function_definitions: "partial_function_definitions (\) Sup" by(unfold_locales)(auto intro: Sup_least Sup_upper) lemma complete_lattice_partial_function_definitions_dual: "partial_function_definitions (\) Inf" by(unfold_locales)(auto intro: Inf_lower Inf_greatest) lemmas [cont_intro, simp] = Partial_Function.ccpo[OF complete_lattice_partial_function_definitions] Partial_Function.ccpo[OF complete_lattice_partial_function_definitions_dual] lemma mono2mono_inf: assumes f: "monotone ord (\) (\x. f x)" and g: "monotone ord (\) (\x. g x)" shows "monotone ord (\) (\x. f x \ g x)" by(auto 4 3 dest: monotoneD[OF f] monotoneD[OF g] intro: le_infI1 le_infI2 intro!: monotoneI) lemma mcont_const [simp]: "mcont lub ord Sup (\) (\_. c)" by(rule ccpo.mcont_const[OF complete_lattice_ccpo]) lemma mono2mono_sup: assumes f: "monotone ord (\) (\x. f x)" and g: "monotone ord (\) (\x. g x)" shows "monotone ord (\) (\x. f x \ g x)" by(auto 4 3 intro!: monotoneI intro: sup.coboundedI1 sup.coboundedI2 dest: monotoneD[OF f] monotoneD[OF g]) lemma Sup_image_sup: assumes "Y \ {}" shows "\((\) x ` Y) = x \ \Y" proof(rule Sup_eqI) fix y assume "y \ (\) x ` Y" then obtain z where "y = x \ z" and "z \ Y" by blast from \z \ Y\ have "z \ \Y" by(rule Sup_upper) with _ show "y \ x \ \Y" unfolding \y = x \ z\ by(rule sup_mono) simp next fix y assume upper: "\z. z \ (\) x ` Y \ z \ y" show "x \ \Y \ y" unfolding Sup_insert[symmetric] proof(rule Sup_least) fix z assume "z \ insert x Y" from assms obtain z' where "z' \ Y" by blast let ?z = "if z \ Y then x \ z else x \ z'" have "z \ x \ ?z" using \z' \ Y\ \z \ insert x Y\ by auto also have "\ \ y" by(rule upper)(auto split: if_split_asm intro: \z' \ Y\) finally show "z \ y" . qed qed lemma mcont_sup1: "mcont Sup (\) Sup (\) (\y. x \ y)" by(auto 4 3 simp add: mcont_def sup.coboundedI1 sup.coboundedI2 intro!: monotoneI contI intro: Sup_image_sup[symmetric]) lemma mcont_sup2: "mcont Sup (\) Sup (\) (\x. x \ y)" by(subst sup_commute)(rule mcont_sup1) lemma mcont2mcont_sup [cont_intro, simp]: "\ mcont lub ord Sup (\) (\x. f x); mcont lub ord Sup (\) (\x. g x) \ \ mcont lub ord Sup (\) (\x. f x \ g x)" by(best intro: ccpo.mcont2mcont'[OF complete_lattice_ccpo] mcont_sup1 mcont_sup2 ccpo.mcont_const[OF complete_lattice_ccpo]) end lemmas [cont_intro] = admissible_leI[OF complete_lattice_ccpo'] context complete_distrib_lattice begin lemma mcont_inf1: "mcont Sup (\) Sup (\) (\y. x \ y)" by(auto intro: monotoneI contI simp add: le_infI2 inf_Sup mcont_def) lemma mcont_inf2: "mcont Sup (\) Sup (\) (\x. x \ y)" by(auto intro: monotoneI contI simp add: le_infI1 Sup_inf mcont_def) lemma mcont2mcont_inf [cont_intro, simp]: "\ mcont lub ord Sup (\) (\x. f x); mcont lub ord Sup (\) (\x. g x) \ \ mcont lub ord Sup (\) (\x. f x \ g x)" by(best intro: ccpo.mcont2mcont'[OF complete_lattice_ccpo] mcont_inf1 mcont_inf2 ccpo.mcont_const[OF complete_lattice_ccpo]) end interpretation lfp: partial_function_definitions "(\) :: _ :: complete_lattice \ _" Sup by(rule complete_lattice_partial_function_definitions) declaration \Partial_Function.init "lfp" \<^term>\lfp.fixp_fun\ \<^term>\lfp.mono_body\ @{thm lfp.fixp_rule_uc} @{thm lfp.fixp_induct_uc} NONE\ interpretation gfp: partial_function_definitions "(\) :: _ :: complete_lattice \ _" Inf by(rule complete_lattice_partial_function_definitions_dual) declaration \Partial_Function.init "gfp" \<^term>\gfp.fixp_fun\ \<^term>\gfp.mono_body\ @{thm gfp.fixp_rule_uc} @{thm gfp.fixp_induct_uc} NONE\ lemma insert_mono [partial_function_mono]: "monotone (fun_ord (\)) (\) A \ monotone (fun_ord (\)) (\) (\y. insert x (A y))" by(rule monotoneI)(auto simp add: fun_ord_def dest: monotoneD) lemma mono2mono_insert [THEN lfp.mono2mono, cont_intro, simp]: shows monotone_insert: "monotone (\) (\) (insert x)" by(rule monotoneI) blast lemma mcont2mcont_insert[THEN lfp.mcont2mcont, cont_intro, simp]: shows mcont_insert: "mcont Union (\) Union (\) (insert x)" by(blast intro: mcontI contI monotone_insert) lemma mono2mono_image [THEN lfp.mono2mono, cont_intro, simp]: shows monotone_image: "monotone (\) (\) ((`) f)" by(rule monotoneI) blast lemma cont_image: "cont Union (\) Union (\) ((`) f)" by(rule contI)(auto) lemma mcont2mcont_image [THEN lfp.mcont2mcont, cont_intro, simp]: shows mcont_image: "mcont Union (\) Union (\) ((`) f)" by(blast intro: mcontI monotone_image cont_image) context complete_lattice begin lemma monotone_Sup [cont_intro, simp]: "monotone ord (\) f \ monotone ord (\) (\x. \f x)" by(blast intro: monotoneI Sup_least Sup_upper dest: monotoneD) lemma cont_Sup: assumes "cont lub ord Union (\) f" shows "cont lub ord Sup (\) (\x. \f x)" apply(rule contI) apply(simp add: contD[OF assms]) apply(blast intro: Sup_least Sup_upper order_trans order.antisym) done lemma mcont_Sup: "mcont lub ord Union (\) f \ mcont lub ord Sup (\) (\x. \f x)" unfolding mcont_def by(blast intro: monotone_Sup cont_Sup) lemma monotone_SUP: "\ monotone ord (\) f; \y. monotone ord (\) (\x. g x y) \ \ monotone ord (\) (\x. \y\f x. g x y)" by(rule monotoneI)(blast dest: monotoneD intro: Sup_upper order_trans intro!: Sup_least) lemma monotone_SUP2: "(\y. y \ A \ monotone ord (\) (\x. g x y)) \ monotone ord (\) (\x. \y\A. g x y)" by(rule monotoneI)(blast intro: Sup_upper order_trans dest: monotoneD intro!: Sup_least) lemma cont_SUP: assumes f: "mcont lub ord Union (\) f" and g: "\y. mcont lub ord Sup (\) (\x. g x y)" shows "cont lub ord Sup (\) (\x. \y\f x. g x y)" proof(rule contI) fix Y assume chain: "Complete_Partial_Order.chain ord Y" and Y: "Y \ {}" show "\(g (lub Y) ` f (lub Y)) = \((\x. \(g x ` f x)) ` Y)" (is "?lhs = ?rhs") proof(rule order.antisym) show "?lhs \ ?rhs" proof(rule Sup_least) fix x assume "x \ g (lub Y) ` f (lub Y)" with mcont_contD[OF f chain Y] mcont_contD[OF g chain Y] obtain y z where "y \ Y" "z \ f y" and x: "x = \((\x. g x z) ` Y)" by auto show "x \ ?rhs" unfolding x proof(rule Sup_least) fix u assume "u \ (\x. g x z) ` Y" then obtain y' where "u = g y' z" "y' \ Y" by auto from chain \y \ Y\ \y' \ Y\ have "ord y y' \ ord y' y" by(rule chainD) thus "u \ ?rhs" proof note \u = g y' z\ also assume "ord y y'" with f have "f y \ f y'" by(rule mcont_monoD) with \z \ f y\ have "g y' z \ \(g y' ` f y')" by(auto intro: Sup_upper) also have "\ \ ?rhs" using \y' \ Y\ by(auto intro: Sup_upper) finally show ?thesis . next note \u = g y' z\ also assume "ord y' y" with g have "g y' z \ g y z" by(rule mcont_monoD) also have "\ \ \(g y ` f y)" using \z \ f y\ by(auto intro: Sup_upper) also have "\ \ ?rhs" using \y \ Y\ by(auto intro: Sup_upper) finally show ?thesis . qed qed qed next show "?rhs \ ?lhs" proof(rule Sup_least) fix x assume "x \ (\x. \(g x ` f x)) ` Y" then obtain y where x: "x = \(g y ` f y)" and "y \ Y" by auto show "x \ ?lhs" unfolding x proof(rule Sup_least) fix u assume "u \ g y ` f y" then obtain z where "u = g y z" "z \ f y" by auto note \u = g y z\ also have "g y z \ \((\x. g x z) ` Y)" using \y \ Y\ by(auto intro: Sup_upper) also have "\ = g (lub Y) z" by(simp add: mcont_contD[OF g chain Y]) also have "\ \ ?lhs" using \z \ f y\ \y \ Y\ by(auto intro: Sup_upper simp add: mcont_contD[OF f chain Y]) finally show "u \ ?lhs" . qed qed qed qed lemma mcont_SUP [cont_intro, simp]: "\ mcont lub ord Union (\) f; \y. mcont lub ord Sup (\) (\x. g x y) \ \ mcont lub ord Sup (\) (\x. \y\f x. g x y)" by(blast intro: mcontI cont_SUP monotone_SUP mcont_mono) end lemma admissible_Ball [cont_intro, simp]: "\ \x. ccpo.admissible lub ord (\A. P A x); mcont lub ord Union (\) f; class.ccpo lub ord (mk_less ord) \ \ ccpo.admissible lub ord (\A. \x\f A. P A x)" unfolding Ball_def by simp lemma admissible_Bex'[THEN admissible_subst, cont_intro, simp]: shows admissible_Bex: "ccpo.admissible Union (\) (\A. \x\A. P x)" by(rule ccpo.admissibleI)(auto) subsection \Parallel fixpoint induction\ context fixes luba :: "'a set \ 'a" and orda :: "'a \ 'a \ bool" and lubb :: "'b set \ 'b" and ordb :: "'b \ 'b \ bool" assumes a: "class.ccpo luba orda (mk_less orda)" and b: "class.ccpo lubb ordb (mk_less ordb)" begin interpretation a: ccpo luba orda "mk_less orda" by(rule a) interpretation b: ccpo lubb ordb "mk_less ordb" by(rule b) lemma ccpo_rel_prodI: "class.ccpo (prod_lub luba lubb) (rel_prod orda ordb) (mk_less (rel_prod orda ordb))" (is "class.ccpo ?lub ?ord ?ord'") proof(intro class.ccpo.intro class.ccpo_axioms.intro) show "class.order ?ord ?ord'" by(rule order_rel_prodI) intro_locales qed(auto 4 4 simp add: prod_lub_def intro: a.ccpo_Sup_upper b.ccpo_Sup_upper a.ccpo_Sup_least b.ccpo_Sup_least rev_image_eqI dest: chain_rel_prodD1 chain_rel_prodD2) interpretation ab: ccpo "prod_lub luba lubb" "rel_prod orda ordb" "mk_less (rel_prod orda ordb)" by(rule ccpo_rel_prodI) lemma monotone_map_prod [simp]: "monotone (rel_prod orda ordb) (rel_prod ordc ordd) (map_prod f g) \ monotone orda ordc f \ monotone ordb ordd g" by(auto simp add: monotone_def) lemma parallel_fixp_induct: assumes adm: "ccpo.admissible (prod_lub luba lubb) (rel_prod orda ordb) (\x. P (fst x) (snd x))" and f: "monotone orda orda f" and g: "monotone ordb ordb g" and bot: "P (luba {}) (lubb {})" and step: "\x y. P x y \ P (f x) (g y)" shows "P (ccpo.fixp luba orda f) (ccpo.fixp lubb ordb g)" proof - let ?lub = "prod_lub luba lubb" and ?ord = "rel_prod orda ordb" and ?P = "\(x, y). P x y" from adm have adm': "ccpo.admissible ?lub ?ord ?P" by(simp add: split_def) hence "?P (ccpo.fixp (prod_lub luba lubb) (rel_prod orda ordb) (map_prod f g))" by(rule ab.fixp_induct)(auto simp add: f g step bot) also have "ccpo.fixp (prod_lub luba lubb) (rel_prod orda ordb) (map_prod f g) = (ccpo.fixp luba orda f, ccpo.fixp lubb ordb g)" (is "?lhs = (?rhs1, ?rhs2)") proof(rule ab.order.antisym) have "ccpo.admissible ?lub ?ord (\xy. ?ord xy (?rhs1, ?rhs2))" by(rule admissible_leI[OF ccpo_rel_prodI])(auto simp add: prod_lub_def chain_empty intro: a.ccpo_Sup_least b.ccpo_Sup_least) thus "?ord ?lhs (?rhs1, ?rhs2)" by(rule ab.fixp_induct)(auto 4 3 dest: monotoneD[OF f] monotoneD[OF g] simp add: b.fixp_unfold[OF g, symmetric] a.fixp_unfold[OF f, symmetric] f g intro: a.ccpo_Sup_least b.ccpo_Sup_least chain_empty) next have "ccpo.admissible luba orda (\x. orda x (fst ?lhs))" by(rule admissible_leI[OF a])(auto intro: a.ccpo_Sup_least simp add: chain_empty) hence "orda ?rhs1 (fst ?lhs)" using f proof(rule a.fixp_induct) fix x assume "orda x (fst ?lhs)" thus "orda (f x) (fst ?lhs)" by(subst ab.fixp_unfold)(auto simp add: f g dest: monotoneD[OF f]) qed(auto intro: a.ccpo_Sup_least chain_empty) moreover have "ccpo.admissible lubb ordb (\y. ordb y (snd ?lhs))" by(rule admissible_leI[OF b])(auto intro: b.ccpo_Sup_least simp add: chain_empty) hence "ordb ?rhs2 (snd ?lhs)" using g proof(rule b.fixp_induct) fix y assume "ordb y (snd ?lhs)" thus "ordb (g y) (snd ?lhs)" by(subst ab.fixp_unfold)(auto simp add: f g dest: monotoneD[OF g]) qed(auto intro: b.ccpo_Sup_least chain_empty) ultimately show "?ord (?rhs1, ?rhs2) ?lhs" by(simp add: rel_prod_conv split_beta) qed finally show ?thesis by simp qed end lemma parallel_fixp_induct_uc: assumes a: "partial_function_definitions orda luba" and b: "partial_function_definitions ordb lubb" and F: "\x. monotone (fun_ord orda) orda (\f. U1 (F (C1 f)) x)" and G: "\y. monotone (fun_ord ordb) ordb (\g. U2 (G (C2 g)) y)" and eq1: "f \ C1 (ccpo.fixp (fun_lub luba) (fun_ord orda) (\f. U1 (F (C1 f))))" and eq2: "g \ C2 (ccpo.fixp (fun_lub lubb) (fun_ord ordb) (\g. U2 (G (C2 g))))" and inverse: "\f. U1 (C1 f) = f" and inverse2: "\g. U2 (C2 g) = g" and adm: "ccpo.admissible (prod_lub (fun_lub luba) (fun_lub lubb)) (rel_prod (fun_ord orda) (fun_ord ordb)) (\x. P (fst x) (snd x))" and bot: "P (\_. luba {}) (\_. lubb {})" and step: "\f g. P (U1 f) (U2 g) \ P (U1 (F f)) (U2 (G g))" shows "P (U1 f) (U2 g)" apply(unfold eq1 eq2 inverse inverse2) apply(rule parallel_fixp_induct[OF partial_function_definitions.ccpo[OF a] partial_function_definitions.ccpo[OF b] adm]) using F apply(simp add: monotone_def fun_ord_def) using G apply(simp add: monotone_def fun_ord_def) apply(simp add: fun_lub_def bot) apply(rule step, simp add: inverse inverse2) done lemmas parallel_fixp_induct_1_1 = parallel_fixp_induct_uc[ of _ _ _ _ "\x. x" _ "\x. x" "\x. x" _ "\x. x", OF _ _ _ _ _ _ refl refl] lemmas parallel_fixp_induct_2_2 = parallel_fixp_induct_uc[ of _ _ _ _ "case_prod" _ "curry" "case_prod" _ "curry", where P="\f g. P (curry f) (curry g)", unfolded case_prod_curry curry_case_prod curry_K, OF _ _ _ _ _ _ refl refl] for P lemma monotone_fst: "monotone (rel_prod orda ordb) orda fst" by(auto intro: monotoneI) lemma mcont_fst: "mcont (prod_lub luba lubb) (rel_prod orda ordb) luba orda fst" by(auto intro!: mcontI monotoneI contI simp add: prod_lub_def) lemma mcont2mcont_fst [cont_intro, simp]: "mcont lub ord (prod_lub luba lubb) (rel_prod orda ordb) t \ mcont lub ord luba orda (\x. fst (t x))" by(auto intro!: mcontI monotoneI contI dest: mcont_monoD mcont_contD simp add: rel_prod_sel split_beta prod_lub_def image_image) lemma monotone_snd: "monotone (rel_prod orda ordb) ordb snd" by(auto intro: monotoneI) lemma mcont_snd: "mcont (prod_lub luba lubb) (rel_prod orda ordb) lubb ordb snd" by(auto intro!: mcontI monotoneI contI simp add: prod_lub_def) lemma mcont2mcont_snd [cont_intro, simp]: "mcont lub ord (prod_lub luba lubb) (rel_prod orda ordb) t \ mcont lub ord lubb ordb (\x. snd (t x))" by(auto intro!: mcontI monotoneI contI dest: mcont_monoD mcont_contD simp add: rel_prod_sel split_beta prod_lub_def image_image) lemma monotone_Pair: "\ monotone ord orda f; monotone ord ordb g \ \ monotone ord (rel_prod orda ordb) (\x. (f x, g x))" by(simp add: monotone_def) lemma cont_Pair: "\ cont lub ord luba orda f; cont lub ord lubb ordb g \ \ cont lub ord (prod_lub luba lubb) (rel_prod orda ordb) (\x. (f x, g x))" by(rule contI)(auto simp add: prod_lub_def image_image dest!: contD) lemma mcont_Pair: "\ mcont lub ord luba orda f; mcont lub ord lubb ordb g \ \ mcont lub ord (prod_lub luba lubb) (rel_prod orda ordb) (\x. (f x, g x))" by(rule mcontI)(simp_all add: monotone_Pair mcont_mono cont_Pair) context partial_function_definitions begin text \Specialised versions of @{thm [source] mcont_call} for admissibility proofs for parallel fixpoint inductions\ lemmas mcont_call_fst [cont_intro] = mcont_call[THEN mcont2mcont, OF mcont_fst] lemmas mcont_call_snd [cont_intro] = mcont_call[THEN mcont2mcont, OF mcont_snd] end lemma map_option_mono [partial_function_mono]: "mono_option B \ mono_option (\f. map_option g (B f))" unfolding map_conv_bind_option by(rule bind_mono) simp_all lemma compact_flat_lub [cont_intro]: "ccpo.compact (flat_lub x) (flat_ord x) y" using flat_interpretation[THEN ccpo] proof(rule ccpo.compactI[OF _ ccpo.admissibleI]) fix A assume chain: "Complete_Partial_Order.chain (flat_ord x) A" and A: "A \ {}" and *: "\z\A. \ flat_ord x y z" from A obtain z where "z \ A" by blast with * have z: "\ flat_ord x y z" .. hence y: "x \ y" "y \ z" by(auto simp add: flat_ord_def) { assume "\ A \ {x}" then obtain z' where "z' \ A" "z' \ x" by auto then have "(THE z. z \ A - {x}) = z'" by(intro the_equality)(auto dest: chainD[OF chain] simp add: flat_ord_def) moreover have "z' \ y" using \z' \ A\ * by(auto simp add: flat_ord_def) ultimately have "y \ (THE z. z \ A - {x})" by simp } with z show "\ flat_ord x y (flat_lub x A)" by(simp add: flat_ord_def flat_lub_def) qed end diff --git a/src/HOL/Library/Lattice_Syntax.thy b/src/HOL/Library/Lattice_Syntax.thy deleted file mode 100644 --- a/src/HOL/Library/Lattice_Syntax.thy +++ /dev/null @@ -1,23 +0,0 @@ -(* Author: Florian Haftmann, TU Muenchen *) - -section \Pretty syntax for lattice operations\ - -theory Lattice_Syntax -imports Main -begin - -notation - bot ("\") and - top ("\") and - inf (infixl "\" 70) and - sup (infixl "\" 65) and - Inf ("\ _" [900] 900) and - Sup ("\ _" [900] 900) - -syntax - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - -end diff --git a/src/HOL/Library/Library.thy b/src/HOL/Library/Library.thy --- a/src/HOL/Library/Library.thy +++ b/src/HOL/Library/Library.thy @@ -1,101 +1,100 @@ (*<*) theory Library imports AList Adhoc_Overloading BigO BNF_Axiomatization BNF_Corec Bourbaki_Witt_Fixpoint Char_ord Code_Cardinality Code_Lazy Code_Test Combine_PER Complete_Partial_Order2 Conditional_Parametricity Confluence Confluent_Quotient Countable Countable_Complete_Lattices Countable_Set_Type Debug Diagonal_Subsequence Discrete Disjoint_Sets Disjoint_FSets Dlist Dual_Ordered_Lattice Equipollence Extended Extended_Nat Extended_Nonnegative_Real Extended_Real Finite_Map Float FSet FuncSet Function_Division Fun_Lexorder Going_To_Filter Groups_Big_Fun Indicator_Function Infinite_Set Interval Interval_Float IArray Landau_Symbols Lattice_Algebras - Lattice_Syntax Lattice_Constructions Linear_Temporal_Logic_on_Streams ListVector Lub_Glb Mapping Monad_Syntax More_List Multiset_Order Nonpos_Ints Numeral_Type Omega_Words_Fun Open_State_Syntax Option_ord Order_Continuity Parallel Pattern_Aliases Periodic_Fun Poly_Mapping Power_By_Squaring Preorder Product_Plus Quadratic_Discriminant Quotient_List Quotient_Option Quotient_Product Quotient_Set Quotient_Sum Quotient_Syntax Quotient_Type Ramsey Reflection Rewrite Saturated Set_Algebras Set_Idioms Signed_Division State_Monad Stream Sorting_Algorithms Sublist Sum_of_Squares Transitive_Closure_Table Tree_Multiset Tree_Real Type_Length Uprod While_Combinator Word Z2 begin end (*>*) diff --git a/src/HOL/Library/Option_ord.thy b/src/HOL/Library/Option_ord.thy --- a/src/HOL/Library/Option_ord.thy +++ b/src/HOL/Library/Option_ord.thy @@ -1,480 +1,454 @@ (* Title: HOL/Library/Option_ord.thy Author: Florian Haftmann, TU Muenchen *) section \Canonical order on option type\ theory Option_ord imports Main begin -notation - bot ("\") and - top ("\") and - inf (infixl "\" 70) and - sup (infixl "\" 65) and - Inf ("\ _" [900] 900) and - Sup ("\ _" [900] 900) - -syntax - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - +unbundle lattice_syntax instantiation option :: (preorder) preorder begin definition less_eq_option where "x \ y \ (case x of None \ True | Some x \ (case y of None \ False | Some y \ x \ y))" definition less_option where "x < y \ (case y of None \ False | Some y \ (case x of None \ True | Some x \ x < y))" lemma less_eq_option_None [simp]: "None \ x" by (simp add: less_eq_option_def) lemma less_eq_option_None_code [code]: "None \ x \ True" by simp lemma less_eq_option_None_is_None: "x \ None \ x = None" by (cases x) (simp_all add: less_eq_option_def) lemma less_eq_option_Some_None [simp, code]: "Some x \ None \ False" by (simp add: less_eq_option_def) lemma less_eq_option_Some [simp, code]: "Some x \ Some y \ x \ y" by (simp add: less_eq_option_def) lemma less_option_None [simp, code]: "x < None \ False" by (simp add: less_option_def) lemma less_option_None_is_Some: "None < x \ \z. x = Some z" by (cases x) (simp_all add: less_option_def) lemma less_option_None_Some [simp]: "None < Some x" by (simp add: less_option_def) lemma less_option_None_Some_code [code]: "None < Some x \ True" by simp lemma less_option_Some [simp, code]: "Some x < Some y \ x < y" by (simp add: less_option_def) instance by standard (auto simp add: less_eq_option_def less_option_def less_le_not_le elim: order_trans split: option.splits) end instance option :: (order) order by standard (auto simp add: less_eq_option_def less_option_def split: option.splits) instance option :: (linorder) linorder by standard (auto simp add: less_eq_option_def less_option_def split: option.splits) instantiation option :: (order) order_bot begin definition bot_option where "\ = None" instance by standard (simp add: bot_option_def) end instantiation option :: (order_top) order_top begin definition top_option where "\ = Some \" instance by standard (simp add: top_option_def less_eq_option_def split: option.split) end instance option :: (wellorder) wellorder proof fix P :: "'a option \ bool" fix z :: "'a option" assume H: "\x. (\y. y < x \ P y) \ P x" have "P None" by (rule H) simp then have P_Some [case_names Some]: "P z" if "\x. z = Some x \ (P \ Some) x" for z using \P None\ that by (cases z) simp_all show "P z" proof (cases z rule: P_Some) case (Some w) show "(P \ Some) w" proof (induct rule: less_induct) case (less x) have "P (Some x)" proof (rule H) fix y :: "'a option" assume "y < Some x" show "P y" proof (cases y rule: P_Some) case (Some v) with \y < Some x\ have "v < x" by simp with less show "(P \ Some) v" . qed qed then show ?case by simp qed qed qed instantiation option :: (inf) inf begin definition inf_option where "x \ y = (case x of None \ None | Some x \ (case y of None \ None | Some y \ Some (x \ y)))" lemma inf_None_1 [simp, code]: "None \ y = None" by (simp add: inf_option_def) lemma inf_None_2 [simp, code]: "x \ None = None" by (cases x) (simp_all add: inf_option_def) lemma inf_Some [simp, code]: "Some x \ Some y = Some (x \ y)" by (simp add: inf_option_def) instance .. end instantiation option :: (sup) sup begin definition sup_option where "x \ y = (case x of None \ y | Some x' \ (case y of None \ x | Some y \ Some (x' \ y)))" lemma sup_None_1 [simp, code]: "None \ y = y" by (simp add: sup_option_def) lemma sup_None_2 [simp, code]: "x \ None = x" by (cases x) (simp_all add: sup_option_def) lemma sup_Some [simp, code]: "Some x \ Some y = Some (x \ y)" by (simp add: sup_option_def) instance .. end instance option :: (semilattice_inf) semilattice_inf proof fix x y z :: "'a option" show "x \ y \ x" by (cases x, simp_all, cases y, simp_all) show "x \ y \ y" by (cases x, simp_all, cases y, simp_all) show "x \ y \ x \ z \ x \ y \ z" by (cases x, simp_all, cases y, simp_all, cases z, simp_all) qed instance option :: (semilattice_sup) semilattice_sup proof fix x y z :: "'a option" show "x \ x \ y" by (cases x, simp_all, cases y, simp_all) show "y \ x \ y" by (cases x, simp_all, cases y, simp_all) fix x y z :: "'a option" show "y \ x \ z \ x \ y \ z \ x" by (cases y, simp_all, cases z, simp_all, cases x, simp_all) qed instance option :: (lattice) lattice .. instance option :: (lattice) bounded_lattice_bot .. instance option :: (bounded_lattice_top) bounded_lattice_top .. instance option :: (bounded_lattice_top) bounded_lattice .. instance option :: (distrib_lattice) distrib_lattice proof fix x y z :: "'a option" show "x \ y \ z = (x \ y) \ (x \ z)" by (cases x, simp_all, cases y, simp_all, cases z, simp_all add: sup_inf_distrib1 inf_commute) qed instantiation option :: (complete_lattice) complete_lattice begin definition Inf_option :: "'a option set \ 'a option" where "\A = (if None \ A then None else Some (\Option.these A))" lemma None_in_Inf [simp]: "None \ A \ \A = None" by (simp add: Inf_option_def) definition Sup_option :: "'a option set \ 'a option" where "\A = (if A = {} \ A = {None} then None else Some (\Option.these A))" lemma empty_Sup [simp]: "\{} = None" by (simp add: Sup_option_def) lemma singleton_None_Sup [simp]: "\{None} = None" by (simp add: Sup_option_def) instance proof fix x :: "'a option" and A assume "x \ A" then show "\A \ x" by (cases x) (auto simp add: Inf_option_def in_these_eq intro: Inf_lower) next fix z :: "'a option" and A assume *: "\x. x \ A \ z \ x" show "z \ \A" proof (cases z) case None then show ?thesis by simp next case (Some y) show ?thesis by (auto simp add: Inf_option_def in_these_eq Some intro!: Inf_greatest dest!: *) qed next fix x :: "'a option" and A assume "x \ A" then show "x \ \A" by (cases x) (auto simp add: Sup_option_def in_these_eq intro: Sup_upper) next fix z :: "'a option" and A assume *: "\x. x \ A \ x \ z" show "\A \ z " proof (cases z) case None with * have "\x. x \ A \ x = None" by (auto dest: less_eq_option_None_is_None) then have "A = {} \ A = {None}" by blast then show ?thesis by (simp add: Sup_option_def) next case (Some y) from * have "\w. Some w \ A \ Some w \ z" . with Some have "\w. w \ Option.these A \ w \ y" by (simp add: in_these_eq) then have "\Option.these A \ y" by (rule Sup_least) with Some show ?thesis by (simp add: Sup_option_def) qed next show "\{} = (\::'a option)" by (auto simp: bot_option_def) show "\{} = (\::'a option)" by (auto simp: top_option_def Inf_option_def) qed end lemma Some_Inf: "Some (\A) = \(Some ` A)" by (auto simp add: Inf_option_def) lemma Some_Sup: "A \ {} \ Some (\A) = \(Some ` A)" by (auto simp add: Sup_option_def) lemma Some_INF: "Some (\x\A. f x) = (\x\A. Some (f x))" by (simp add: Some_Inf image_comp) lemma Some_SUP: "A \ {} \ Some (\x\A. f x) = (\x\A. Some (f x))" by (simp add: Some_Sup image_comp) lemma option_Inf_Sup: "\(Sup ` A) \ \(Inf ` {f ` A |f. \Y\A. f Y \ Y})" for A :: "('a::complete_distrib_lattice option) set set" proof (cases "{} \ A") case True then show ?thesis by (rule INF_lower2, simp_all) next case False from this have X: "{} \ A" by simp then show ?thesis proof (cases "{None} \ A") case True then show ?thesis by (rule INF_lower2, simp_all) next case False {fix y assume A: "y \ A" have "Sup (y - {None}) = Sup y" by (metis (no_types, lifting) Sup_option_def insert_Diff_single these_insert_None these_not_empty_eq) from A and this have "(\z. y - {None} = z - {None} \ z \ A) \ \y = \(y - {None})" by auto } from this have A: "Sup ` A = (Sup ` {y - {None} | y. y\A})" by (auto simp add: image_def) have [simp]: "\y. y \ A \ \ya. {ya. \x. x \ y \ (\y. x = Some y) \ ya = the x} = {y. \x\ya - {None}. y = the x} \ ya \ A" by (rule exI, auto) have [simp]: "\y. y \ A \ (\ya. y - {None} = ya - {None} \ ya \ A) \ \{ya. \x\y - {None}. ya = the x} = \{ya. \x. x \ y \ (\y. x = Some y) \ ya = the x}" apply (safe, blast) by (rule arg_cong [of _ _ Sup], auto) {fix y assume [simp]: "y \ A" have "\x. (\y. x = {ya. \x\y - {None}. ya = the x} \ y \ A) \ \{ya. \x. x \ y \ (\y. x = Some y) \ ya = the x} = \x" and "\x. (\y. x = y - {None} \ y \ A) \ \{ya. \x\y - {None}. ya = the x} = \{y. \xa. xa \ x \ (\y. xa = Some y) \ y = the xa}" apply (rule exI [of _ "{ya. \x. x \ y \ (\y. x = Some y) \ ya = the x}"], simp) by (rule exI [of _ "y - {None}"], simp) } from this have C: "(\x. (\Option.these x)) ` {y - {None} |y. y \ A} = (Sup ` {the ` (y - {None}) |y. y \ A})" by (simp add: image_def Option.these_def, safe, simp_all) have D: "\ f . \Y\A. f Y \ Y \ False" by (drule spec [of _ "\ Y . SOME x . x \ Y"], simp add: X some_in_eq) define F where "F = (\ Y . SOME x::'a option . x \ (Y - {None}))" have G: "\ Y . Y \ A \ \ x . x \ Y - {None}" by (metis False X all_not_in_conv insert_Diff_single these_insert_None these_not_empty_eq) have F: "\ Y . Y \ A \ F Y \ (Y - {None})" by (metis F_def G empty_iff some_in_eq) have "Some \ \ Inf (F ` A)" by (metis (no_types, lifting) Diff_iff F Inf_option_def bot.extremum image_iff less_eq_option_Some singletonI) from this have "Inf (F ` A) \ None" by (cases "\x\A. F x", simp_all) from this have "Inf (F ` A) \ None \ Inf (F ` A) \ Inf ` {f ` A |f. \Y\A. f Y \ Y}" using F by auto from this have "\ x . x \ None \ x \ Inf ` {f ` A |f. \Y\A. f Y \ Y}" by blast from this have E:" Inf ` {f ` A |f. \Y\A. f Y \ Y} = {None} \ False" by blast have [simp]: "((\x\{f ` A |f. \Y\A. f Y \ Y}. \x) = None) = False" by (metis (no_types, lifting) E Sup_option_def \\x. x \ None \ x \ Inf ` {f ` A |f. \Y\A. f Y \ Y}\ ex_in_conv option.simps(3)) have B: "Option.these ((\x. Some (\Option.these x)) ` {y - {None} |y. y \ A}) = ((\x. (\ Option.these x)) ` {y - {None} |y. y \ A})" by (metis image_image these_image_Some_eq) { fix f assume A: "\ Y . (\y. Y = the ` (y - {None}) \ y \ A) \ f Y \ Y" have "\xa. xa \ A \ f {y. \a\xa - {None}. y = the a} = f (the ` (xa - {None}))" by (simp add: image_def) from this have [simp]: "\xa. xa \ A \ \x\A. f {y. \a\xa - {None}. y = the a} = f (the ` (x - {None}))" by blast have "\xa. xa \ A \ f (the ` (xa - {None})) = f {y. \a \ xa - {None}. y = the a} \ xa \ A" by (simp add: image_def) from this have [simp]: "\xa. xa \ A \ \x. f (the ` (xa - {None})) = f {y. \a\x - {None}. y = the a} \ x \ A" by blast { fix Y have "Y \ A \ Some (f (the ` (Y - {None}))) \ Y" using A [of "the ` (Y - {None})"] apply (simp add: image_def) using option.collapse by fastforce } from this have [simp]: "\ Y . Y \ A \ Some (f (the ` (Y - {None}))) \ Y" by blast have [simp]: "(\x\A. Some (f {y. \x\x - {None}. y = the x})) = \{Some (f {y. \a\x - {None}. y = the a}) |x. x \ A}" by (simp add: Setcompr_eq_image) have [simp]: "\x. (\f. x = {y. \x\A. y = f x} \ (\Y\A. f Y \ Y)) \ \{Some (f {y. \a\x - {None}. y = the a}) |x. x \ A} = \x" apply (rule exI [of _ "{Some (f {y. \a\x - {None}. y = the a}) | x . x\ A}"], safe) by (rule exI [of _ "(\ Y . Some (f (the ` (Y - {None})))) "], safe, simp_all) { fix xb have "xb \ A \ (\x\{{ya. \x\y - {None}. ya = the x} |y. y \ A}. f x) \ f {y. \x\xb - {None}. y = the x}" apply (rule INF_lower2 [of "{y. \x\xb - {None}. y = the x}"]) by blast+ } from this have [simp]: "(\x\{the ` (y - {None}) |y. y \ A}. f x) \ the (\Y\A. Some (f (the ` (Y - {None}))))" apply (simp add: Inf_option_def image_def Option.these_def) by (rule Inf_greatest, clarsimp) have [simp]: "the (\Y\A. Some (f (the ` (Y - {None})))) \ Option.these (Inf ` {f ` A |f. \Y\A. f Y \ Y})" apply (auto simp add: Option.these_def) apply (rule imageI) apply auto using \\Y. Y \ A \ Some (f (the ` (Y - {None}))) \ Y\ apply blast apply (auto simp add: Some_INF [symmetric]) done have "(\x\{the ` (y - {None}) |y. y \ A}. f x) \ \Option.these (Inf ` {f ` A |f. \Y\A. f Y \ Y})" by (rule Sup_upper2 [of "the (Inf ((\ Y . Some (f (the ` (Y - {None})) )) ` A))"], simp_all) } from this have X: "\ f . \Y. (\y. Y = the ` (y - {None}) \ y \ A) \ f Y \ Y \ (\x\{the ` (y - {None}) |y. y \ A}. f x) \ \Option.these (Inf ` {f ` A |f. \Y\A. f Y \ Y})" by blast have [simp]: "\ x . x\{y - {None} |y. y \ A} \ x \ {} \ x \ {None}" using F by fastforce have "(Inf (Sup `A)) = (Inf (Sup ` {y - {None} | y. y\A}))" by (subst A, simp) also have "... = (\x\{y - {None} |y. y \ A}. if x = {} \ x = {None} then None else Some (\Option.these x))" by (simp add: Sup_option_def) also have "... = (\x\{y - {None} |y. y \ A}. Some (\Option.these x))" using G by fastforce also have "... = Some (\Option.these ((\x. Some (\Option.these x)) ` {y - {None} |y. y \ A}))" by (simp add: Inf_option_def, safe) also have "... = Some (\ ((\x. (\Option.these x)) ` {y - {None} |y. y \ A}))" by (simp add: B) also have "... = Some (Inf (Sup ` {the ` (y - {None}) |y. y \ A}))" by (unfold C, simp) thm Inf_Sup also have "... = Some (\x\{f ` {the ` (y - {None}) |y. y \ A} |f. \Y. (\y. Y = the ` (y - {None}) \ y \ A) \ f Y \ Y}. \x) " by (simp add: Inf_Sup) also have "... \ \ (Inf ` {f ` A |f. \Y\A. f Y \ Y})" proof (cases "\ (Inf ` {f ` A |f. \Y\A. f Y \ Y})") case None then show ?thesis by (simp add: less_eq_option_def) next case (Some a) then show ?thesis apply simp apply (rule Sup_least, safe) apply (simp add: Sup_option_def) apply (cases "(\f. \Y\A. f Y \ Y) \ Inf ` {f ` A |f. \Y\A. f Y \ Y} = {None}", simp_all) by (drule X, simp) qed finally show ?thesis by simp qed qed instance option :: (complete_distrib_lattice) complete_distrib_lattice by (standard, simp add: option_Inf_Sup) instance option :: (complete_linorder) complete_linorder .. - -no_notation - bot ("\") and - top ("\") and - inf (infixl "\" 70) and - sup (infixl "\" 65) and - Inf ("\ _" [900] 900) and - Sup ("\ _" [900] 900) - -no_syntax - "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) - "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) - "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) +unbundle no_lattice_syntax end diff --git a/src/HOL/Main.thy b/src/HOL/Main.thy --- a/src/HOL/Main.thy +++ b/src/HOL/Main.thy @@ -1,74 +1,109 @@ section \Main HOL\ text \ Classical Higher-order Logic -- only ``Main'', excluding real and complex numbers etc. \ theory Main imports Predicate_Compile Quickcheck_Narrowing Mirabelle Extraction Nunchaku BNF_Greatest_Fixpoint Filter Conditionally_Complete_Lattices Binomial GCD begin -text \Namespace cleanup\ +subsection \Namespace cleanup\ hide_const (open) czero cinfinite cfinite csum cone ctwo Csum cprod cexp image2 image2p vimage2p Gr Grp collect fsts snds setl setr convol pick_middlep fstOp sndOp csquare relImage relInvImage Succ Shift shift proj id_bnf hide_fact (open) id_bnf_def type_definition_id_bnf_UNIV -text \Syntax cleanup\ +subsection \Syntax cleanup\ no_notation - bot ("\") and - top ("\") and - inf (infixl "\" 70) and - sup (infixl "\" 65) and - Inf ("\") and - Sup ("\") and ordLeq2 (infix "<=o" 50) and ordLeq3 (infix "\o" 50) and ordLess2 (infix "(_,/ _)\") -bundle cardinal_syntax begin +bundle cardinal_syntax +begin + notation ordLeq2 (infix "<=o" 50) and ordLeq3 (infix "\o" 50) and ordLess2 (infix "Lattice syntax\ + +bundle lattice_syntax +begin + +notation + bot ("\") and + top ("\") and + inf (infixl "\" 70) and + sup (infixl "\" 65) and + Inf ("\ _" [900] 900) and + Sup ("\ _" [900] 900) + +syntax + "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) + "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) + "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) + "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) + +end + +bundle no_lattice_syntax +begin + +no_notation + bot ("\") and + top ("\") and + inf (infixl "\" 70) and + sup (infixl "\" 65) and + Inf ("\ _" [900] 900) and + Sup ("\ _" [900] 900) + no_syntax "_INF1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) "_INF" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) "_SUP1" :: "pttrns \ 'b \ 'b" ("(3\_./ _)" [0, 10] 10) "_SUP" :: "pttrn \ 'a set \ 'b \ 'b" ("(3\_\_./ _)" [0, 0, 10] 10) end + +unbundle no_lattice_syntax +no_notation Inf ("\") and Sup ("\") + +end