(* Title: HOL/Quotient.thy Author: Cezary Kaliszyk and Christian Urban *)
section‹Definition of Quotient Types›
theory Quotient imports Lifting
keywords "print_quotmapsQ3""print_quotientsQ3""print_quotconsts" :: diag and "quotient_type" :: thy_goal_defn and"/"and "quotient_definition" :: thy_goal_defn and "copy_bnf" :: thy_defn and "lift_bnf" :: thy_goal_defn begin
text‹ Basic definition for equivalence relations that are represented by predicates. ›
definition "Quotient3 R Abs Rep ⟷ (∀a. Abs (Rep a) = a) ∧ (∀a. R (Rep a) (Rep a)) ∧ (∀r s. R r s ⟷ R r r ∧ R s s ∧ Abs r = Abs s)"
lemma Quotient3I: assumes"∧a. Abs (Rep a) = a" and"∧a. R (Rep a) (Rep a)" and"∧r s. R r s ⟷ R r r ∧ R s s ∧ Abs r = Abs s" shows"Quotient3 R Abs Rep" using assms unfolding Quotient3_def by blast
context fixes R Abs Rep assumes a: "Quotient3 R Abs Rep" begin
lemma Quotient3_abs_rep: "Abs (Rep a) = a" using a unfolding Quotient3_def by simp
lemma Quotient3_rep_reflp: "R (Rep a) (Rep a)" using a unfolding Quotient3_def by blast
lemma Quotient3_rel: "R r r ∧ R s s ∧ Abs r = Abs s ⟷ R r s"🍋‹orientation does not loop on rewriting› using a unfolding Quotient3_def by blast
lemma Quotient3_refl1: "R r s ==> R r r" using a unfolding Quotient3_def by fast
lemma Quotient3_refl2: "R r s ==> R s s" using a unfolding Quotient3_def by fast
lemma Quotient3_rel_rep: "R (Rep a) (Rep b) ⟷ a = b" using a unfolding Quotient3_def by metis
lemma Quotient3_rep_abs: "R r r ==> R (Rep (Abs r)) r" using a unfolding Quotient3_def by blast
lemma Quotient3_rel_abs: "R r s ==> Abs r = Abs s" using a unfolding Quotient3_def by blast
lemma Quotient3_symp: "symp R" using a unfolding Quotient3_def using sympI by metis
lemma Quotient3_transp: "transp R" using a unfolding Quotient3_def using transpI by (metis (full_types))
lemma Quotient3_part_equivp: "part_equivp R" by (metis Quotient3_rep_reflp Quotient3_symp Quotient3_transp part_equivpI)
lemma equals_rsp: assumes b: "R xa xb""R ya yb" shows"R xa ya = R xb yb" using b Quotient3_symp Quotient3_transp by (blast elim: sympE transpE)
lemma rep_abs_rsp: assumes b: "R x1 x2" shows"R x1 (Rep (Abs x2))" using b Quotient3_rel Quotient3_abs_rep Quotient3_rep_reflp by metis
lemma rep_abs_rsp_left: assumes b: "R x1 x2" shows"R (Rep (Abs x1)) x2" using b Quotient3_rel Quotient3_abs_rep Quotient3_rep_reflp by metis
end
lemma identity_quotient3: "Quotient3 (=) id id" unfolding Quotient3_def id_def by blast
lemma fun_quotient3: assumes q1: "Quotient3 R1 abs1 rep1" and q2: "Quotient3 R2 abs2 rep2" shows"Quotient3 (R1 ===> R2) (rep1 ---> abs2) (abs1 ---> rep2)" proof - have"(rep1 ---> abs2) ((abs1 ---> rep2) a) = a"for a using q1 q2 by (simp add: Quotient3_def fun_eq_iff) moreover have"(R1 ===> R2) ((abs1 ---> rep2) a) ((abs1 ---> rep2) a)"for a by (rule rel_funI)
(use q1 q2 Quotient3_rel_abs [of R1 abs1 rep1] Quotient3_rel_rep [of R2 abs2 rep2] in‹simp (no_asm) add: Quotient3_def, simp›) moreover have"(R1 ===> R2) r s = ((R1 ===> R2) r r ∧ (R1 ===> R2) s s ∧ (rep1 ---> abs2) r = (rep1 ---> abs2) s)"for r s proof - have"(R1 ===> R2) r s ==> (R1 ===> R2) r r"unfolding rel_fun_def using Quotient3_part_equivp[OF q1] Quotient3_part_equivp[OF q2] by (metis (full_types) part_equivp_def) moreoverhave"(R1 ===> R2) r s ==> (R1 ===> R2) s s"unfolding rel_fun_def using Quotient3_part_equivp[OF q1] Quotient3_part_equivp[OF q2] by (metis (full_types) part_equivp_def) moreoverhave"(R1 ===> R2) r s ==> (rep1 ---> abs2) r = (rep1 ---> abs2) s" by (auto simp add: rel_fun_def fun_eq_iff)
(use q1 q2 in‹unfold Quotient3_def, metis›) moreoverhave"((R1 ===> R2) r r ∧ (R1 ===> R2) s s ∧ (rep1 ---> abs2) r = (rep1 ---> abs2) s) ==> (R1 ===> R2) r s" by (auto simp add: rel_fun_def fun_eq_iff)
(use q1 q2 in‹unfold Quotient3_def, metis map_fun_apply›) ultimatelyshow ?thesis by blast qed ultimatelyshow ?thesis by (intro Quotient3I) (assumption+) qed
lemma lambda_prs: assumes q1: "Quotient3 R1 Abs1 Rep1" and q2: "Quotient3 R2 Abs2 Rep2" shows"(Rep1 ---> Abs2) (λx. Rep2 (f (Abs1 x))) = (λx. f x)" unfolding fun_eq_iff using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] by simp
lemma lambda_prs1: assumes q1: "Quotient3 R1 Abs1 Rep1" and q2: "Quotient3 R2 Abs2 Rep2" shows"(Rep1 ---> Abs2) (λx. (Abs1 ---> Rep2) f x) = (λx. f x)" unfolding fun_eq_iff using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] by simp
text‹ In the following theorem R1 can be instantiated with anything, but we know some of the types of the Rep and Abs functions; so by solving Quotient assumptions we can get a unique R1 that will be provable; which is why we need to use ‹apply_rsp›and not the primed version›
lemma apply_rspQ3: fixes f g::"'a ==> 'c" assumes q: "Quotient3 R1 Abs1 Rep1" and a: "(R1 ===> R2) f g""R1 x y" shows"R2 (f x) (g y)" using a by (auto elim: rel_funE)
lemma apply_rspQ3'': assumes"Quotient3 R Abs Rep" and"(R ===> S) f f" shows"S (f (Rep x)) (f (Rep x))" proof - from assms(1) have"R (Rep x) (Rep x)"by (rule Quotient3_rep_reflp) thenshow ?thesis using assms(2) by (auto intro: apply_rsp') qed
subsection‹lemmas for regularisation of ball and bex›
lemma ball_reg_eqv: fixes P :: "'a ==> bool" assumes a: "equivp R" shows"Ball (Respects R) P = (All P)" using a unfolding equivp_def by (auto simp add: in_respects)
lemma bex_reg_eqv: fixes P :: "'a ==> bool" assumes a: "equivp R" shows"Bex (Respects R) P = (Ex P)" using a unfolding equivp_def by (auto simp add: in_respects)
lemma ball_reg_right: assumes a: "∧x. x ∈ R ==> P x ⟶ Q x" shows"All P ⟶ Ball R Q" using a by fast
lemma bex_reg_left: assumes a: "∧x. x ∈ R ==> Q x ⟶ P x" shows"Bex R Q ⟶ Ex P" using a by fast
lemma ball_reg_left: assumes a: "equivp R" shows"(∧x. (Q x ⟶ P x)) ==> Ball (Respects R) Q ⟶ All P" using a by (metis equivp_reflp in_respects)
lemma bex_reg_right: assumes a: "equivp R" shows"(∧x. (Q x ⟶ P x)) ==> Ex Q ⟶ Bex (Respects R) P" using a by (metis equivp_reflp in_respects)
lemma ball_reg_eqv_range: fixes P::"'a ==> bool" and x::"'a" assumes a: "equivp R2" shows"(Ball (Respects (R1 ===> R2)) (λf. P (f x)) = All (λf. P (f x)))" proof (intro allI iffI) fix f assume"∀f ∈ Respects (R1 ===> R2). P (f x)" moreoverhave"(λy. f x) ∈ Respects (R1 ===> R2)" using a equivp_reflp_symp_transp[of "R2"] by(auto simp add: in_respects rel_fun_def elim: equivpE reflpE) ultimatelyshow"P (f x)" by auto qed auto
lemma bex_reg_eqv_range: assumes a: "equivp R2" shows"(Bex (Respects (R1 ===> R2)) (λf. P (f x)) = Ex (λf. P (f x)))" proof - have"(λy. f x) ∈ Respects (R1 ===> R2)"for f using a equivp_reflp_symp_transp[of "R2"] by (auto simp add: Respects_def in_respects rel_fun_def elim: equivpE reflpE) thenshow ?thesis by auto qed
(* Next four lemmas are unused *) lemma all_reg: assumes a: "∀x :: 'a. (P x ⟶ Q x)" and b: "All P" shows"All Q" using a b by fast
lemma ex_reg: assumes a: "∀x :: 'a. (P x ⟶ Q x)" and b: "Ex P" shows"Ex Q" using a b by fast
lemma ball_reg: assumes a: "∀x :: 'a. (x ∈ R ⟶ P x ⟶ Q x)" and b: "Ball R P" shows"Ball R Q" using a b by fast
lemma bex_reg: assumes a: "∀x :: 'a. (x ∈ R ⟶ P x ⟶ Q x)" and b: "Bex R P" shows"Bex R Q" using a b by fast
lemma ball_all_comm: assumes"∧y. (∀x∈P. A x y) ⟶ (∀x. B x y)" shows"(∀x∈P. ∀y. A x y) ⟶ (∀x. ∀y. B x y)" using assms by auto
lemma bex_ex_comm: assumes"(∃y. ∃x. A x y) ⟶ (∃y. ∃x∈P. B x y)" shows"(∃x. ∃y. A x y) ⟶ (∃x∈P. ∃y. B x y)" using assms by auto
subsection‹Bounded abstraction›
definition
Babs :: "'a set ==> ('a ==> 'b) ==> 'a ==> 'b" where "x ∈ p ==> Babs p m x = m x"
lemma babs_rsp: assumes q: "Quotient3 R1 Abs1 Rep1" and a: "(R1 ===> R2) f g" shows"(R1 ===> R2) (Babs (Respects R1) f) (Babs (Respects R1) g)" proof fix x y assume"R1 x y" thenhave"x ∈ Respects R1 ∧ y ∈ Respects R1" unfolding in_respects rel_fun_def using Quotient3_rel[OF q]by metis thenshow"R2 (Babs (Respects R1) f x) (Babs (Respects R1) g y)" using‹R1 x y› a by (simp add: Babs_def rel_fun_def) qed
lemma babs_prs: assumes q1: "Quotient3 R1 Abs1 Rep1" and q2: "Quotient3 R2 Abs2 Rep2" shows"((Rep1 ---> Abs2) (Babs (Respects R1) ((Abs1 ---> Rep2) f))) = f" proof - have"Abs2 (Babs (Respects R1) ((Abs1 ---> Rep2) f) (Rep1 x)) = f x"for x proof - have"Rep1 x ∈ Respects R1" by (simp add: in_respects Quotient3_rel_rep[OF q1]) thenshow ?thesis by (simp add: Babs_def Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2]) qed thenshow ?thesis by force qed
text‹If a user proves that a particular functional relation is an equivalence, this may be useful in regularising› lemma babs_reg_eqv: shows"equivp R ==> Babs (Respects R) P = P" by (simp add: fun_eq_iff Babs_def in_respects equivp_reflp)
(* 3 lemmas needed for proving repabs_inj *) lemma ball_rsp: assumes a: "(R ===> (=)) f g" shows"Ball (Respects R) f = Ball (Respects R) g" using a by (auto simp add: Ball_def in_respects elim: rel_funE)
lemma bex_rsp: assumes a: "(R ===> (=)) f g" shows"(Bex (Respects R) f = Bex (Respects R) g)" using a by (auto simp add: Bex_def in_respects elim: rel_funE)
lemma bex1_rsp: assumes a: "(R ===> (=)) f g" shows"Ex1 (λx. x ∈ Respects R ∧ f x) = Ex1 (λx. x ∈ Respects R ∧ g x)" using a by (auto elim: rel_funE simp add: Ex1_def in_respects)
text‹Two lemmas needed for cleaning of quantifiers›
lemma all_prs: assumes a: "Quotient3 R absf repf" shows"Ball (Respects R) ((absf ---> id) f) = All f" using a unfolding Quotient3_def Ball_def in_respects id_apply comp_def map_fun_def by metis
lemma ex_prs: assumes a: "Quotient3 R absf repf" shows"Bex (Respects R) ((absf ---> id) f) = Ex f" using a unfolding Quotient3_def Bex_def in_respects id_apply comp_def map_fun_def by metis
subsection‹‹Bex1_rel› quantifier›
definition
Bex1_rel :: "('a ==> 'a ==> bool) ==> ('a ==> bool) ==> bool" where "Bex1_rel R P ⟷ (∃x ∈ Respects R. P x) ∧ (∀x ∈ Respects R. ∀y ∈ Respects R. ((P x ∧ P y) ⟶ (R x y)))"
lemma bex1_rel_aux: "[∀xa ya. R xa ya ⟶ x xa = y ya; Bex1_rel R x]==> Bex1_rel R y" unfolding Bex1_rel_def by (metis in_respects)
lemma bex1_rel_aux2: "[∀xa ya. R xa ya ⟶ x xa = y ya; Bex1_rel R y]==> Bex1_rel R x" unfolding Bex1_rel_def by (metis in_respects)
lemma cond_prs: assumes a: "Quotient3 R absf repf" shows"absf (if a then repf b else repf c) = (if a then b else c)" using a unfolding Quotient3_def by auto
lemma if_prs: assumes q: "Quotient3 R Abs Rep" shows"(id ---> Rep ---> Rep ---> Abs) If = If" using Quotient3_abs_rep[OF q] by (auto simp add: fun_eq_iff)
lemma if_rsp: assumes q: "Quotient3 R Abs Rep" shows"((=) ===> R ===> R ===> R) If If" by force
lemma let_prs: assumes q1: "Quotient3 R1 Abs1 Rep1" and q2: "Quotient3 R2 Abs2 Rep2" shows"(Rep2 ---> (Abs2 ---> Rep1) ---> Abs1) Let = Let" using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] by (auto simp add: fun_eq_iff)
lemma let_rsp: shows"(R1 ===> (R1 ===> R2) ===> R2) Let Let" by (force elim: rel_funE)
lemma id_rsp: shows"(R ===> R) id id" by auto
lemma id_prs: assumes a: "Quotient3 R Abs Rep" shows"(Rep ---> Abs) id = id" by (simp add: fun_eq_iff Quotient3_abs_rep [OF a])
end
locale quot_type = fixes R :: "'a ==> 'a ==> bool" and Abs :: "'a set ==> 'b" and Rep :: "'b ==> 'a set" assumes equivp: "part_equivp R" and rep_prop: "∧y. ∃x. R x x ∧ Rep y = Collect (R x)" and rep_inverse: "∧x. Abs (Rep x) = x" and abs_inverse: "∧c. (∃x. ((R x x) ∧ (c = Collect (R x)))) ==> (Rep (Abs c)) = c" and rep_inject: "∧x y. (Rep x = Rep y) = (x = y)" begin
definition
abs :: "'a ==> 'b" where "abs x = Abs (Collect (R x))"
definition
rep :: "'b ==> 'a" where "rep a = (SOME x. x ∈ Rep a)"
lemma some_collect: assumes"R r r" shows"R (SOME x. x ∈ Collect (R r)) = R r" by simp (metis assms exE_some equivp[simplified part_equivp_def])
lemma Quotient: "Quotient3 R abs rep" unfolding Quotient3_def abs_def rep_def proof (intro conjI allI) fix a r s show x: "R (SOME x. x ∈ Rep a) (SOME x. x ∈ Rep a)"proof - obtain x where r: "R x x"and rep: "Rep a = Collect (R x)"using rep_prop[of a] by auto have"R (SOME x. x ∈ Rep a) x"using r rep some_collect by metis thenhave"R x (SOME x. x ∈ Rep a)"using part_equivp_symp[OF equivp] by fast thenshow"R (SOME x. x ∈ Rep a) (SOME x. x ∈ Rep a)" using part_equivp_transp[OF equivp] by (metis ‹R (SOME x. x ∈ Rep a) x›) qed have"Collect (R (SOME x. x ∈ Rep a)) = (Rep a)"by (metis some_collect rep_prop) thenshow"Abs (Collect (R (SOME x. x ∈ Rep a))) = a"using rep_inverse by auto have"R r r ==> R s s ==> Abs (Collect (R r)) = Abs (Collect (R s)) ⟷ R r = R s" proof - assume"R r r"and"R s s" thenhave"Abs (Collect (R r)) = Abs (Collect (R s)) ⟷ Collect (R r) = Collect (R s)" by (metis abs_inverse) alsohave"Collect (R r) = Collect (R s) ⟷ (λA x. x ∈ A) (Collect (R r)) = (λA x. x ∈ A) (Collect (R s))" by (rule iffI) simp_all finallyshow"Abs (Collect (R r)) = Abs (Collect (R s)) ⟷ R r = R s"by simp qed thenshow"R r s ⟷ R r r ∧ R s s ∧ (Abs (Collect (R r)) = Abs (Collect (R s)))" using equivp[simplified part_equivp_def] by metis qed
end
subsection‹Quotient composition›
lemma OOO_quotient3: fixes R1 :: "'a ==> 'a ==> bool" fixes Abs1 :: "'a ==> 'b"and Rep1 :: "'b ==> 'a" fixes Abs2 :: "'b ==> 'c"and Rep2 :: "'c ==> 'b" fixes R2' :: "'a ==> 'a ==> bool" fixes R2 :: "'b ==> 'b ==> bool" assumes R1: "Quotient3 R1 Abs1 Rep1" assumes R2: "Quotient3 R2 Abs2 Rep2" assumes Abs1: "∧x y. R2' x y ==> R1 x x ==> R1 y y ==> R2 (Abs1 x) (Abs1 y)" assumes Rep1: "∧x y. R2 x y ==> R2' (Rep1 x) (Rep1 y)" shows"Quotient3 (R1 OO R2' OO R1) (Abs2 ∘ Abs1) (Rep1 ∘ Rep2)" proof - have *: "(R1 OOO R2') r r ∧ (R1 OOO R2') s s ∧ (Abs2 ∘ Abs1) r = (Abs2 ∘ Abs1) s ⟷ (R1 OOO R2') r s"for r s proof (intro iffI conjI; clarify) show"(R1 OOO R2') r s" if r: "R1 r a""R2' a b""R1 b r"and eq: "(Abs2 ∘ Abs1) r = (Abs2 ∘ Abs1) s" and s: "R1 s c""R2' c d""R1 d s"for a b c d proof - have"R1 r (Rep1 (Abs1 r))" using r Quotient3_refl1 R1 rep_abs_rsp by fastforce moreoverhave"R2' (Rep1 (Abs1 r)) (Rep1 (Abs1 s))" using that by simp (metis (full_types) Rep1 Abs1 Quotient3_rel R2 Quotient3_refl1 [OF R1]
Quotient3_refl2 [OF R1] Quotient3_rel_abs [OF R1]) moreoverhave"R1 (Rep1 (Abs1 s)) s" by (metis s Quotient3_rel R1 rep_abs_rsp_left) ultimatelyshow ?thesis by (metis relcomppI) qed next fix x y assume xy: "R1 r x""R2' x y""R1 y s" thenhave"R2 (Abs1 x) (Abs1 y)" by (iprover dest: Abs1 elim: Quotient3_refl1 [OF R1] Quotient3_refl2 [OF R1]) thenhave"R2' (Rep1 (Abs1 x)) (Rep1 (Abs1 x))""R2' (Rep1 (Abs1 y)) (Rep1 (Abs1 y))" by (simp_all add: Quotient3_refl1 [OF R2] Quotient3_refl2 [OF R2] Rep1) with‹R1 r x›‹R1 y s›show"(R1 OOO R2') r r""(R1 OOO R2') s s" by (metis (full_types) Quotient3_def R1 relcompp.relcompI)+ show"(Abs2 ∘ Abs1) r = (Abs2 ∘ Abs1) s" using xy by simp (metis (full_types) Abs1 Quotient3_rel R1 R2) qed show ?thesis apply (rule Quotient3I) using * apply (simp_all add: o_def Quotient3_abs_rep [OF R2] Quotient3_abs_rep [OF R1]) apply (metis Quotient3_rep_reflp R1 R2 Rep1 relcompp.relcompI) done qed
lemma Quotient3_to_Quotient: assumes"Quotient3 R Abs Rep" and"T ≡ λx y. R x x ∧ Abs x = y" shows"Quotient R Abs Rep T" using assms unfolding Quotient3_def by (intro QuotientI) blast+
lemma Quotient3_to_Quotient_equivp: assumes q: "Quotient3 R Abs Rep" and T_def: "T ≡ λx y. Abs x = y" and eR: "equivp R" shows"Quotient R Abs Rep T" proof (intro QuotientI) show"Abs (Rep a) = a"for a using q by(rule Quotient3_abs_rep) show"R (Rep a) (Rep a)"for a using q by(rule Quotient3_rep_reflp) show"R r s = (R r r ∧ R s s ∧ Abs r = Abs s)"for r s using q by(rule Quotient3_rel[symmetric]) show"T = (λx y. R x x ∧ Abs x = y)" using T_def equivp_reflp[OF eR] by simp qed
subsection‹ML setup›
text‹Auxiliary data for the quotient package›
named_theorems quot_equiv "equivalence relation theorems" and quot_respect "respectfulness theorems" and quot_preserve "preservation theorems" and id_simps "identity simp rules for maps" and quot_thm "quotient theorems"
ML_file ‹Tools/Quotient/quotient_info.ML›
text‹Translation functions for the lifting process.›
ML_file ‹Tools/Quotient/quotient_term.ML›
text‹Definitions of the quotient types.›
ML_file ‹Tools/Quotient/quotient_type.ML›
text‹Definitions for quotient constants.›
ML_file ‹Tools/Quotient/quotient_def.ML›
text‹ An auxiliary constant for recording some information about the lifted theorem in a tactic. › definition
Quot_True :: "'a ==> bool" where "Quot_True x ⟷ True"
lemma shows QT_all: "Quot_True (All P) ==> Quot_True P" and QT_ex: "Quot_True (Ex P) ==> Quot_True P" and QT_ex1: "Quot_True (Ex1 P) ==> Quot_True P" and QT_lam: "Quot_True (λx. P x) ==> (∧x. Quot_True (P x))" and QT_ext: "(∧x. Quot_True (a x) ==> f x = g x) ==> (Quot_True a ==> f = g)" by (simp_all add: Quot_True_def ext)
lemma QT_imp: "Quot_True a ≡ Quot_True b" by (simp add: Quot_True_def)
contextincludes lifting_syntax begin
text‹Tactics for proving the lifted theorems›
ML_file ‹Tools/Quotient/quotient_tacs.ML›
method_setup lifting_setup = ‹Attrib.thm >> (fn thm => fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.lift_procedure_tac ctxt [] thm))› ‹set up the three goals for the quotient lifting procedure›
method_setup descending = ‹Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.descend_tac ctxt []))› ‹decend theorems to the raw level›
method_setup descending_setup = ‹Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.descend_procedure_tac ctxt []))› ‹set up the three goals for the decending theorems›
method_setup partiality_descending = ‹Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.partiality_descend_tac ctxt []))› ‹decend theorems to the raw level›
method_setup partiality_descending_setup = ‹Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.partiality_descend_procedure_tac ctxt []))› ‹set up the three goals for the decending theorems›
method_setup regularize = ‹Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.regularize_tac ctxt))› ‹prove the regularization goals from the quotient lifting procedure›
method_setup injection = ‹Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.all_injection_tac ctxt))› ‹prove the rep/abs injection goals from the quotient lifting procedure›
method_setup cleaning = ‹Scan.succeed (fn ctxt => SIMPLE_METHOD' (Quotient_Tacs.clean_tac ctxt))› ‹prove the cleaning goals from the quotient lifting procedure›
attribute_setup quot_lifted = ‹Scan.succeed Quotient_Tacs.lifted_attrib› ‹lift theorems to quotient types›
no_notation rel_conj (infixr‹OOO› 75)
section‹Lifting of BNFs›
lemma sum_insert_Inl_unit: "x ∈ A ==> (∧y. x = Inr y ==> Inr y ∈ B) ==> x ∈ insert (Inl ()) B" by (cases x) (simp_all)
lemma lift_sum_unit_vimage_commute: "insert (Inl ()) (Inr ` f -` A) = map_sum id f -` insert (Inl ()) (Inr ` A)" by (auto simp: map_sum_def split: sum.splits)
lemma insert_Inl_int_map_sum_unit: "insert (Inl ()) A ∩ range (map_sum id f) ≠ {}" by (auto simp: map_sum_def split: sum.splits)
lemma image_map_sum_unit_subset: "A ⊆ insert (Inl ()) (Inr ` B) ==> map_sum id f ` A ⊆ insert (Inl ()) (Inr ` f ` B)" by auto
lemma subset_lift_sum_unitD: "A ⊆ insert (Inl ()) (Inr ` B) ==> Inr x ∈ A ==> x ∈B" unfolding insert_def by auto
lemma subset_vimage_image_subset: "A ⊆ f -` B ==> f ` A ⊆ B" by auto
lemma relcompp_mem_Grp_neq_bot: "A ∩ range f ≠ {} ==> (λx y. x ∈ A ∧ y ∈ A) OO (Grp UNIV f)-1-1≠ bot" unfolding Grp_def relcompp_apply fun_eq_iff by blast
lemma comp_projr_Inr: "projr ∘ Inr = id" by auto
lemma in_rel_sum_in_image_projr: "B ⊆ {(x,y). rel_sum ((=) :: unit ==> unit ==> bool) A x y} ==> Inr ` C = fst ` B ==> snd ` B = Inr ` D ==> map_prod projr projr ` B ⊆ {(x,y). A x y}" by (force simp: projr_def image_iff dest!: spec[of _ "Inl ()"] split: sum.splits)
lemma subset_rel_sumI: "B ⊆ {(x,y). A x y} ==> rel_sum ((=) :: unit => unit => bool) A (if x ∈ B then Inr (fst x) else Inl ()) (if x ∈ B then Inr (snd x) else Inl ())" by auto
lemma rel_fun_rel_OO1: "(rel_fun Q (rel_fun R (=))) A B ==> conversep Q OO A OO R ≤ B" by (auto simp: rel_fun_def)
lemma rel_fun_rel_OO2: "(rel_fun Q (rel_fun R (=))) A B ==> Q OO B OO conversep R ≤ A" by (auto simp: rel_fun_def)
lemma rel_sum_eq2_nonempty: "rel_sum (=) A OO rel_sum (=) B ≠ bot" by (auto simp: fun_eq_iff relcompp_apply intro!: exI[of _ "Inl _"])
lemma rel_sum_eq3_nonempty: "rel_sum (=) A OO (rel_sum (=) B OO rel_sum (=) C) ≠ bot" by (auto simp: fun_eq_iff relcompp_apply intro!: exI[of _ "Inl _"])
lemma hypsubst: "A = B ==> x ∈ B ==> (x ∈ A ==> P) ==> P"by simp
lemma Quotient_crel_quotient: "Quotient R Abs Rep T ==> equivp R ==> T ≡ (λx y. Abs x = y)" by (drule Quotient_cr_rel) (auto simp: fun_eq_iff equivp_reflp intro!: eq_reflection)
lemma Quotient_crel_typedef: "Quotient (eq_onp P) Abs Rep T ==> T ≡ (λx y. x = Rep y)" unfolding Quotient_def by (auto 0 4 simp: fun_eq_iff eq_onp_def intro: sym intro!: eq_reflection)
lemma Quotient_crel_typecopy: "Quotient (=) Abs Rep T ==> T ≡ (λx y. x = Rep y)" by (subst (asm) eq_onp_True[symmetric]) (rule Quotient_crel_typedef)
lemma equivp_add_relconj: assumes equiv: "equivp R""equivp R'"and le: "S OO T OO U ≤ R OO STU OO R'" shows"R OO S OO T OO U OO R' ≤ R OO STU OO R'" proof - have trans: "R OO R ≤ R""R' OO R' ≤ R'" using equiv unfolding equivp_reflp_symp_transp transp_relcompp by blast+ have"R OO S OO T OO U OO R' = R OO (S OO T OO U) OO R'" unfolding relcompp_assoc .. alsohave"…≤ R OO (R OO STU OO R') OO R'" by (intro le relcompp_mono order_refl) alsohave"…≤ (R OO R) OO STU OO (R' OO R')" unfolding relcompp_assoc .. alsohave"…≤ R OO STU OO R'" by (intro trans relcompp_mono order_refl) finallyshow ?thesis . qed
lemma Grp_conversep_eq_onp: "((BNF_Def.Grp UNIV f)-1-1 OO BNF_Def.Grp UNIV f) = eq_onp (λx. x ∈ range f)" by (auto simp: fun_eq_iff Grp_def eq_onp_def image_iff)
lemma Grp_conversep_nonempty: "(BNF_Def.Grp UNIV f)-1-1 OO BNF_Def.Grp UNIV f ≠ bot" by (auto simp: fun_eq_iff Grp_def)
lemma relcomppI2: "r a b ==> s b c ==> t c d ==> (r OO s OO t) a d" by (auto)
lemma rel_conj_eq_onp: "equivp R ==> rel_conj R (eq_onp P) ≤ R" by (auto simp: eq_onp_def transp_def equivp_def)
lemma Quotient_Quotient3: "Quotient R Abs Rep T ==> Quotient3 R Abs Rep" unfolding Quotient_def Quotient3_def by blast
lemma Quotient_reflp_imp_equivp: "Quotient R Abs Rep T ==> reflp R ==> equivp R" using Quotient_symp Quotient_transp equivpI by blast
lemma Quotient_eq_onp_typedef: "Quotient (eq_onp P) Abs Rep cr ==> type_definition Rep Abs {x. P x}" unfolding Quotient_def eq_onp_def by unfold_locales auto
lemma Quotient_eq_onp_type_copy: "Quotient (=) Abs Rep cr ==> type_definition Rep Abs UNIV" unfolding Quotient_def eq_onp_def by unfold_locales auto
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.