diff -r 989182f660e0 -r 8a86fd2a1bf0 src/HOL/FixedPoint.thy --- a/src/HOL/FixedPoint.thy Fri Mar 16 21:32:07 2007 +0100 +++ b/src/HOL/FixedPoint.thy Fri Mar 16 21:32:08 2007 +0100 @@ -5,37 +5,35 @@ Copyright 1992 University of Cambridge *) -header{* Fixed Points and the Knaster-Tarski Theorem*} +header {* Fixed Points and the Knaster-Tarski Theorem*} theory FixedPoint -imports Product_Type LOrder +imports Product_Type begin subsection {* Complete lattices *} -consts - Inf :: "'a::order set \ 'a" - -definition - Sup :: "'a::order set \ 'a" where - "Sup A = Inf {b. \a \ A. a \ b}" - -class comp_lat = order + +class complete_lattice = lattice + + fixes Inf :: "'a set \ 'a" assumes Inf_lower: "x \ A \ Inf A \ x" assumes Inf_greatest: "(\x. x \ A \ z \ x) \ z \ Inf A" -theorem Sup_upper: "(x::'a::comp_lat) \ A \ x <= Sup A" +definition + Sup :: "'a\complete_lattice set \ 'a" where + "Sup A = Inf {b. \a \ A. a \ b}" + +theorem Sup_upper: "(x::'a::complete_lattice) \ A \ x <= Sup A" by (auto simp: Sup_def intro: Inf_greatest) -theorem Sup_least: "(\x::'a::comp_lat. x \ A \ x <= z) \ Sup A <= z" +theorem Sup_least: "(\x::'a::complete_lattice. x \ A \ x <= z) \ Sup A <= z" by (auto simp: Sup_def intro: Inf_lower) definition - SUPR :: "'a set \ ('a \ 'b::comp_lat) \ 'b" where + SUPR :: "'a set \ ('a \ 'b::complete_lattice) \ 'b" where "SUPR A f == Sup (f ` A)" definition - INFI :: "'a set \ ('a \ 'b::comp_lat) \ 'b" where + INFI :: "'a set \ ('a \ 'b::complete_lattice) \ 'b" where "INFI A f == Inf (f ` A)" syntax @@ -80,17 +78,6 @@ text {* A complete lattice is a lattice *} -lemma is_meet_Inf: "is_meet (\(x::'a::comp_lat) y. Inf {x, y})" - by (auto simp: is_meet_def intro: Inf_lower Inf_greatest) - -lemma is_join_Sup: "is_join (\(x::'a::comp_lat) y. Sup {x, y})" - by (auto simp: is_join_def intro: Sup_upper Sup_least) - -instance comp_lat < lorder -proof - from is_meet_Inf show "\m::'a\'a\'a. is_meet m" by iprover - from is_join_Sup show "\j::'a\'a\'a. is_join j" by iprover -qed subsubsection {* Properties *} @@ -100,7 +87,7 @@ lemma mono_sup: "mono f \ sup (f A) (f B) <= f (sup A B)" by (auto simp add: mono_def) -lemma Sup_insert[simp]: "Sup (insert (a::'a::comp_lat) A) = sup a (Sup A)" +lemma Sup_insert[simp]: "Sup (insert (a::'a::complete_lattice) A) = sup a (Sup A)" apply (rule order_antisym) apply (rule Sup_least) apply (erule insertE) @@ -116,7 +103,7 @@ apply simp done -lemma Inf_insert[simp]: "Inf (insert (a::'a::comp_lat) A) = inf a (Inf A)" +lemma Inf_insert[simp]: "Inf (insert (a::'a::complete_lattice) A) = inf a (Inf A)" apply (rule order_antisym) apply (rule le_infI) apply (rule Inf_lower) @@ -132,10 +119,10 @@ apply (erule Inf_lower) done -lemma bot_least[simp]: "Sup{} \ (x::'a::comp_lat)" +lemma bot_least[simp]: "Sup{} \ (x::'a::complete_lattice)" by (rule Sup_least) simp -lemma top_greatest[simp]: "(x::'a::comp_lat) \ Inf{}" +lemma top_greatest[simp]: "(x::'a::complete_lattice) \ Inf{}" by (rule Inf_greatest) simp lemma SUP_const[simp]: "A \ {} \ (SUP i:A. M) = M" @@ -149,51 +136,15 @@ subsubsection {* Booleans *} -defs - Inf_bool_def: "Inf A == ALL x:A. x" - -instance bool :: comp_lat +instance bool :: complete_lattice + Inf_bool_def: "Inf A \ \x\A. x" apply intro_classes apply (unfold Inf_bool_def) apply (iprover intro!: le_boolI elim: ballE) apply (iprover intro!: ballI le_boolI elim: ballE le_boolE) done -theorem inf_bool_eq: "inf P Q \ P \ Q" - apply (rule order_antisym) - apply (rule le_boolI) - apply (rule conjI) - apply (rule le_boolE) - apply (rule inf_le1) - apply assumption+ - apply (rule le_boolE) - apply (rule inf_le2) - apply assumption+ - apply (rule le_infI) - apply (rule le_boolI) - apply (erule conjunct1) - apply (rule le_boolI) - apply (erule conjunct2) - done - -theorem sup_bool_eq: "sup P Q \ P \ Q" - apply (rule order_antisym) - apply (rule le_supI) - apply (rule le_boolI) - apply (erule disjI1) - apply (rule le_boolI) - apply (erule disjI2) - apply (rule le_boolI) - apply (erule disjE) - apply (rule le_boolE) - apply (rule sup_ge1) - apply assumption+ - apply (rule le_boolE) - apply (rule sup_ge2) - apply assumption+ - done - -theorem Sup_bool_eq: "Sup A \ (\x \ A. x)" +theorem Sup_bool_eq: "Sup A \ (\x\A. x)" apply (rule order_antisym) apply (rule Sup_least) apply (rule le_boolI) @@ -208,51 +159,8 @@ subsubsection {* Functions *} -text {* - Handy introduction and elimination rules for @{text "\"} - on unary and binary predicates -*} - -lemma predicate1I [Pure.intro!, intro!]: - assumes PQ: "\x. P x \ Q x" - shows "P \ Q" - apply (rule le_funI) - apply (rule le_boolI) - apply (rule PQ) - apply assumption - done - -lemma predicate1D [Pure.dest, dest]: "P \ Q \ P x \ Q x" - apply (erule le_funE) - apply (erule le_boolE) - apply assumption+ - done - -lemma predicate2I [Pure.intro!, intro!]: - assumes PQ: "\x y. P x y \ Q x y" - shows "P \ Q" - apply (rule le_funI)+ - apply (rule le_boolI) - apply (rule PQ) - apply assumption - done - -lemma predicate2D [Pure.dest, dest]: "P \ Q \ P x y \ Q x y" - apply (erule le_funE)+ - apply (erule le_boolE) - apply assumption+ - done - -lemma rev_predicate1D: "P x ==> P <= Q ==> Q x" - by (rule predicate1D) - -lemma rev_predicate2D: "P x y ==> P <= Q ==> Q x y" - by (rule predicate2D) - -defs - Inf_fun_def: "Inf A == (\x. Inf {y. EX f:A. y = f x})" - -instance "fun" :: (type, comp_lat) comp_lat +instance "fun" :: (type, complete_lattice) complete_lattice + Inf_fun_def: "Inf A \ (\x. Inf {y. \f\A. y = f x})" apply intro_classes apply (unfold Inf_fun_def) apply (rule le_funI) @@ -268,33 +176,7 @@ apply (iprover elim: le_funE) done -theorem inf_fun_eq: "inf f g = (\x. inf (f x) (g x))" - apply (rule order_antisym) - apply (rule le_funI) - apply (rule le_infI) - apply (rule le_funD [OF inf_le1]) - apply (rule le_funD [OF inf_le2]) - apply (rule le_infI) - apply (rule le_funI) - apply (rule inf_le1) - apply (rule le_funI) - apply (rule inf_le2) - done - -theorem sup_fun_eq: "sup f g = (\x. sup (f x) (g x))" - apply (rule order_antisym) - apply (rule le_supI) - apply (rule le_funI) - apply (rule sup_ge1) - apply (rule le_funI) - apply (rule sup_ge2) - apply (rule le_funI) - apply (rule le_supI) - apply (rule le_funD [OF sup_ge1]) - apply (rule le_funD [OF sup_ge2]) - done - -theorem Sup_fun_eq: "Sup A = (\x. Sup {y::'a::comp_lat. EX f:A. y = f x})" +theorem Sup_fun_eq: "Sup A = (\x. Sup {y. \f\A. y = f x})" apply (rule order_antisym) apply (rule Sup_least) apply (rule le_funI) @@ -308,34 +190,13 @@ apply simp done + subsubsection {* Sets *} -defs - Inf_set_def: "Inf S == \S" - -instance set :: (type) comp_lat +instance set :: (type) complete_lattice + Inf_set_def: "Inf S \ \S" by intro_classes (auto simp add: Inf_set_def) -theorem inf_set_eq: "inf A B = A \ B" - apply (rule subset_antisym) - apply (rule Int_greatest) - apply (rule inf_le1) - apply (rule inf_le2) - apply (rule le_infI) - apply (rule Int_lower1) - apply (rule Int_lower2) - done - -theorem sup_set_eq: "sup A B = A \ B" - apply (rule subset_antisym) - apply (rule le_supI) - apply (rule Un_upper1) - apply (rule Un_upper2) - apply (rule Un_least) - apply (rule sup_ge1) - apply (rule sup_ge2) - done - theorem Sup_set_eq: "Sup S = \S" apply (rule subset_antisym) apply (rule Sup_least) @@ -348,11 +209,11 @@ subsection {* Least and greatest fixed points *} definition - lfp :: "('a\comp_lat \ 'a) \ 'a" where + lfp :: "('a\complete_lattice \ 'a) \ 'a" where "lfp f = Inf {u. f u \ u}" --{*least fixed point*} definition - gfp :: "('a\comp_lat \ 'a) \ 'a" where + gfp :: "('a\complete_lattice \ 'a) \ 'a" where "gfp f = Sup {u. u \ f u}" --{*greatest fixed point*} @@ -403,10 +264,8 @@ by (rule lfp_induct [THEN subsetD, THEN CollectD, OF mono _ lfp]) (auto simp: inf_set_eq intro: indhyp) - -text{*Version of induction for binary relations*} -lemmas lfp_induct2 = lfp_induct_set [of "(a,b)", split_format (complete)] - +text {* Version of induction for binary relations *} +lemmas lfp_induct2 = lfp_induct_set [of "(a, b)", split_format (complete)] lemma lfp_ordinal_induct: assumes mono: "mono f" @@ -563,8 +422,6 @@ lemma gfp_mono: "(!!Z. f Z \ g Z) ==> gfp f \ gfp g" by (rule gfp_upperbound [THEN gfp_least], blast intro: order_trans) - - ML {* val lfp_def = thm "lfp_def";