# HG changeset patch # User haftmann # Date 1291029314 -3600 # Node ID fa64f627856824ef83d3f2c0b258e8cd15b056c9 # Parent f1fc2a1547eb27f15bbab0d374d962c1edb5244c moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations; moved generic definitions about relations from Quotient.thy to Predicate; consistent use of R rather than E for relations; more natural deduction rules diff -r f1fc2a1547eb -r fa64f6278568 src/HOL/Quotient.thy --- a/src/HOL/Quotient.thy Mon Nov 29 12:14:46 2010 +0100 +++ b/src/HOL/Quotient.thy Mon Nov 29 12:15:14 2010 +0100 @@ -14,127 +14,11 @@ ("Tools/Quotient/quotient_tacs.ML") begin - text {* Basic definition for equivalence relations that are represented by predicates. *} -definition - "reflp E \ (\x. E x x)" - -lemma refl_reflp: - "refl A \ reflp (\x y. (x, y) \ A)" - by (simp add: refl_on_def reflp_def) - -definition - "symp E \ (\x y. E x y \ E y x)" - -lemma sym_symp: - "sym A \ symp (\x y. (x, y) \ A)" - by (simp add: sym_def symp_def) - -definition - "transp E \ (\x y z. E x y \ E y z \ E x z)" - -lemma trans_transp: - "trans A \ transp (\x y. (x, y) \ A)" - by (auto simp add: trans_def transp_def) - -definition - "equivp E \ (\x y. E x y = (E x = E y))" - -lemma equivp_reflp_symp_transp: - shows "equivp E = (reflp E \ symp E \ transp E)" - unfolding equivp_def reflp_def symp_def transp_def fun_eq_iff - by blast - -lemma equiv_equivp: - "equiv UNIV A \ equivp (\x y. (x, y) \ A)" - by (simp add: equiv_def equivp_reflp_symp_transp refl_reflp sym_symp trans_transp) - -lemma equivp_reflp: - shows "equivp E \ E x x" - by (simp only: equivp_reflp_symp_transp reflp_def) - -lemma equivp_symp: - shows "equivp E \ E x y \ E y x" - by (simp add: equivp_def) - -lemma equivp_transp: - shows "equivp E \ E x y \ E y z \ E x z" - by (simp add: equivp_def) - -lemma equivpI: - assumes "reflp R" "symp R" "transp R" - shows "equivp R" - using assms by (simp add: equivp_reflp_symp_transp) - -lemma identity_equivp: - shows "equivp (op =)" - unfolding equivp_def - by auto - -text {* Partial equivalences *} - -definition - "part_equivp E \ (\x. E x x) \ (\x y. E x y = (E x x \ E y y \ (E x = E y)))" - -lemma equivp_implies_part_equivp: - assumes a: "equivp E" - shows "part_equivp E" - using a - unfolding equivp_def part_equivp_def - by auto - -lemma part_equivp_symp: - assumes e: "part_equivp R" - and a: "R x y" - shows "R y x" - using e[simplified part_equivp_def] a - by (metis) - -lemma part_equivp_typedef: - shows "part_equivp R \ \d. d \ (\c. \x. R x x \ c = R x)" - unfolding part_equivp_def mem_def - apply clarify - apply (intro exI) - apply (rule conjI) - apply assumption - apply (rule refl) - done - -lemma part_equivp_refl_symp_transp: - shows "part_equivp E \ ((\x. E x x) \ symp E \ transp E)" -proof - assume "part_equivp E" - then show "(\x. E x x) \ symp E \ transp E" - unfolding part_equivp_def symp_def transp_def - by metis -next - assume a: "(\x. E x x) \ symp E \ transp E" - then have b: "(\x y. E x y \ E y x)" and c: "(\x y z. E x y \ E y z \ E x z)" - unfolding symp_def transp_def by (metis, metis) - have "(\x y. E x y = (E x x \ E y y \ E x = E y))" - proof (intro allI iffI conjI) - fix x y - assume d: "E x y" - then show "E x x" using b c by metis - show "E y y" using b c d by metis - show "E x = E y" unfolding fun_eq_iff using b c d by metis - next - fix x y - assume "E x x \ E y y \ E x = E y" - then show "E x y" using b c by metis - qed - then show "part_equivp E" unfolding part_equivp_def using a by metis -qed - -lemma part_equivpI: - assumes "\x. R x x" "symp R" "transp R" - shows "part_equivp R" - using assms by (simp add: part_equivp_refl_symp_transp) - text {* Composition of Relations *} abbreviation @@ -169,16 +53,16 @@ definition fun_rel :: "('a \ 'c \ bool) \ ('b \ 'd \ bool) \ ('a \ 'b) \ ('c \ 'd) \ bool" (infixr "===>" 55) where - "fun_rel E1 E2 = (\f g. \x y. E1 x y \ E2 (f x) (g y))" + "fun_rel R1 R2 = (\f g. \x y. R1 x y \ R2 (f x) (g y))" lemma fun_relI [intro]: - assumes "\x y. E1 x y \ E2 (f x) (g y)" - shows "(E1 ===> E2) f g" + assumes "\x y. R1 x y \ R2 (f x) (g y)" + shows "(R1 ===> R2) f g" using assms by (simp add: fun_rel_def) lemma fun_relE: - assumes "(E1 ===> E2) f g" and "E1 x y" - obtains "E2 (f x) (g y)" + assumes "(R1 ===> R2) f g" and "R1 x y" + obtains "R2 (f x) (g y)" using assms by (simp add: fun_rel_def) lemma fun_rel_eq: @@ -189,27 +73,27 @@ subsection {* Quotient Predicate *} definition - "Quotient E Abs Rep \ - (\a. Abs (Rep a) = a) \ (\a. E (Rep a) (Rep a)) \ - (\r s. E r s = (E r r \ E s s \ (Abs r = Abs s)))" + "Quotient 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 Quotient_abs_rep: - assumes a: "Quotient E Abs Rep" + assumes a: "Quotient R Abs Rep" shows "Abs (Rep a) = a" using a unfolding Quotient_def by simp lemma Quotient_rep_reflp: - assumes a: "Quotient E Abs Rep" - shows "E (Rep a) (Rep a)" + assumes a: "Quotient R Abs Rep" + shows "R (Rep a) (Rep a)" using a unfolding Quotient_def by blast lemma Quotient_rel: - assumes a: "Quotient E Abs Rep" - shows " E r s = (E r r \ E s s \ (Abs r = Abs s))" + assumes a: "Quotient R Abs Rep" + shows " R r s = (R r r \ R s s \ (Abs r = Abs s))" using a unfolding Quotient_def by blast @@ -228,22 +112,20 @@ by blast lemma Quotient_rel_abs: - assumes a: "Quotient E Abs Rep" - shows "E r s \ Abs r = Abs s" + assumes a: "Quotient R Abs Rep" + shows "R r s \ Abs r = Abs s" using a unfolding Quotient_def by blast lemma Quotient_symp: - assumes a: "Quotient E Abs Rep" - shows "symp E" - using a unfolding Quotient_def symp_def - by metis + assumes a: "Quotient R Abs Rep" + shows "symp R" + using a unfolding Quotient_def using sympI by metis lemma Quotient_transp: - assumes a: "Quotient E Abs Rep" - shows "transp E" - using a unfolding Quotient_def transp_def - by metis + assumes a: "Quotient R Abs Rep" + shows "transp R" + using a unfolding Quotient_def using transpI by metis lemma identity_quotient: shows "Quotient (op =) id id" @@ -291,8 +173,7 @@ and a: "R xa xb" "R ya yb" shows "R xa ya = R xb yb" using a Quotient_symp[OF q] Quotient_transp[OF q] - unfolding symp_def transp_def - by blast + by (blast elim: sympE transpE) lemma lambda_prs: assumes q1: "Quotient R1 Abs1 Rep1" @@ -300,7 +181,7 @@ shows "(Rep1 ---> Abs2) (\x. Rep2 (f (Abs1 x))) = (\x. f x)" unfolding fun_eq_iff using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] - by (simp add:) + by simp lemma lambda_prs1: assumes q1: "Quotient R1 Abs1 Rep1" @@ -308,7 +189,7 @@ shows "(Rep1 ---> Abs2) (\x. (Abs1 ---> Rep2) f x) = (\x. f x)" unfolding fun_eq_iff using Quotient_abs_rep[OF q1] Quotient_abs_rep[OF q2] - by (simp add:) + by simp lemma rep_abs_rsp: assumes q: "Quotient R Abs Rep" @@ -392,9 +273,7 @@ apply(simp add: in_respects fun_rel_def) apply(rule impI) using a equivp_reflp_symp_transp[of "R2"] - apply(simp add: reflp_def) - apply(simp) - apply(simp) + apply (auto elim: equivpE reflpE) done lemma bex_reg_eqv_range: @@ -406,7 +285,7 @@ apply(simp add: Respects_def in_respects fun_rel_def) apply(rule impI) using a equivp_reflp_symp_transp[of "R2"] - apply(simp add: reflp_def) + apply (auto elim: equivpE reflpE) done (* Next four lemmas are unused *)