23 rel_conj :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" (infixr "OOO" 75) |
23 rel_conj :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" (infixr "OOO" 75) |
24 where |
24 where |
25 "r1 OOO r2 \<equiv> r1 OO r2 OO r1" |
25 "r1 OOO r2 \<equiv> r1 OO r2 OO r1" |
26 |
26 |
27 lemma eq_comp_r: |
27 lemma eq_comp_r: |
28 shows "((op =) OOO R) = R" |
28 shows "((=) OOO R) = R" |
29 by (auto simp add: fun_eq_iff) |
29 by (auto simp add: fun_eq_iff) |
30 |
30 |
31 context includes lifting_syntax |
31 context includes lifting_syntax |
32 begin |
32 begin |
33 |
33 |
362 by (simp add: fun_eq_iff Babs_def in_respects equivp_reflp) |
362 by (simp add: fun_eq_iff Babs_def in_respects equivp_reflp) |
363 |
363 |
364 |
364 |
365 (* 3 lemmas needed for proving repabs_inj *) |
365 (* 3 lemmas needed for proving repabs_inj *) |
366 lemma ball_rsp: |
366 lemma ball_rsp: |
367 assumes a: "(R ===> (op =)) f g" |
367 assumes a: "(R ===> (=)) f g" |
368 shows "Ball (Respects R) f = Ball (Respects R) g" |
368 shows "Ball (Respects R) f = Ball (Respects R) g" |
369 using a by (auto simp add: Ball_def in_respects elim: rel_funE) |
369 using a by (auto simp add: Ball_def in_respects elim: rel_funE) |
370 |
370 |
371 lemma bex_rsp: |
371 lemma bex_rsp: |
372 assumes a: "(R ===> (op =)) f g" |
372 assumes a: "(R ===> (=)) f g" |
373 shows "(Bex (Respects R) f = Bex (Respects R) g)" |
373 shows "(Bex (Respects R) f = Bex (Respects R) g)" |
374 using a by (auto simp add: Bex_def in_respects elim: rel_funE) |
374 using a by (auto simp add: Bex_def in_respects elim: rel_funE) |
375 |
375 |
376 lemma bex1_rsp: |
376 lemma bex1_rsp: |
377 assumes a: "(R ===> (op =)) f g" |
377 assumes a: "(R ===> (=)) f g" |
378 shows "Ex1 (\<lambda>x. x \<in> Respects R \<and> f x) = Ex1 (\<lambda>x. x \<in> Respects R \<and> g x)" |
378 shows "Ex1 (\<lambda>x. x \<in> Respects R \<and> f x) = Ex1 (\<lambda>x. x \<in> Respects R \<and> g x)" |
379 using a by (auto elim: rel_funE simp add: Ex1_def in_respects) |
379 using a by (auto elim: rel_funE simp add: Ex1_def in_respects) |
380 |
380 |
381 (* 2 lemmas needed for cleaning of quantifiers *) |
381 (* 2 lemmas needed for cleaning of quantifiers *) |
382 lemma all_prs: |
382 lemma all_prs: |
436 apply (metis in_respects) |
436 apply (metis in_respects) |
437 done |
437 done |
438 |
438 |
439 lemma bex1_rel_rsp: |
439 lemma bex1_rel_rsp: |
440 assumes a: "Quotient3 R absf repf" |
440 assumes a: "Quotient3 R absf repf" |
441 shows "((R ===> op =) ===> op =) (Bex1_rel R) (Bex1_rel R)" |
441 shows "((R ===> (=)) ===> (=)) (Bex1_rel R) (Bex1_rel R)" |
442 apply (simp add: rel_fun_def) |
442 apply (simp add: rel_fun_def) |
443 apply clarify |
443 apply clarify |
444 apply rule |
444 apply rule |
445 apply (simp_all add: bex1_rel_aux bex1_rel_aux2) |
445 apply (simp_all add: bex1_rel_aux bex1_rel_aux2) |
446 apply (erule bex1_rel_aux2) |
446 apply (erule bex1_rel_aux2) |
507 |
507 |
508 subsection \<open>Various respects and preserve lemmas\<close> |
508 subsection \<open>Various respects and preserve lemmas\<close> |
509 |
509 |
510 lemma quot_rel_rsp: |
510 lemma quot_rel_rsp: |
511 assumes a: "Quotient3 R Abs Rep" |
511 assumes a: "Quotient3 R Abs Rep" |
512 shows "(R ===> R ===> op =) R R" |
512 shows "(R ===> R ===> (=)) R R" |
513 apply(rule rel_funI)+ |
513 apply(rule rel_funI)+ |
514 apply(rule equals_rsp[OF a]) |
514 apply(rule equals_rsp[OF a]) |
515 apply(assumption)+ |
515 apply(assumption)+ |
516 done |
516 done |
517 |
517 |
518 lemma o_prs: |
518 lemma o_prs: |
519 assumes q1: "Quotient3 R1 Abs1 Rep1" |
519 assumes q1: "Quotient3 R1 Abs1 Rep1" |
520 and q2: "Quotient3 R2 Abs2 Rep2" |
520 and q2: "Quotient3 R2 Abs2 Rep2" |
521 and q3: "Quotient3 R3 Abs3 Rep3" |
521 and q3: "Quotient3 R3 Abs3 Rep3" |
522 shows "((Abs2 ---> Rep3) ---> (Abs1 ---> Rep2) ---> (Rep1 ---> Abs3)) op \<circ> = op \<circ>" |
522 shows "((Abs2 ---> Rep3) ---> (Abs1 ---> Rep2) ---> (Rep1 ---> Abs3)) (\<circ>) = (\<circ>)" |
523 and "(id ---> (Abs1 ---> id) ---> Rep1 ---> id) op \<circ> = op \<circ>" |
523 and "(id ---> (Abs1 ---> id) ---> Rep1 ---> id) (\<circ>) = (\<circ>)" |
524 using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] Quotient3_abs_rep[OF q3] |
524 using Quotient3_abs_rep[OF q1] Quotient3_abs_rep[OF q2] Quotient3_abs_rep[OF q3] |
525 by (simp_all add: fun_eq_iff) |
525 by (simp_all add: fun_eq_iff) |
526 |
526 |
527 lemma o_rsp: |
527 lemma o_rsp: |
528 "((R2 ===> R3) ===> (R1 ===> R2) ===> (R1 ===> R3)) op \<circ> op \<circ>" |
528 "((R2 ===> R3) ===> (R1 ===> R2) ===> (R1 ===> R3)) (\<circ>) (\<circ>)" |
529 "(op = ===> (R1 ===> op =) ===> R1 ===> op =) op \<circ> op \<circ>" |
529 "((=) ===> (R1 ===> (=)) ===> R1 ===> (=)) (\<circ>) (\<circ>)" |
530 by (force elim: rel_funE)+ |
530 by (force elim: rel_funE)+ |
531 |
531 |
532 lemma cond_prs: |
532 lemma cond_prs: |
533 assumes a: "Quotient3 R absf repf" |
533 assumes a: "Quotient3 R absf repf" |
534 shows "absf (if a then repf b else repf c) = (if a then b else c)" |
534 shows "absf (if a then repf b else repf c) = (if a then b else c)" |
540 using Quotient3_abs_rep[OF q] |
540 using Quotient3_abs_rep[OF q] |
541 by (auto simp add: fun_eq_iff) |
541 by (auto simp add: fun_eq_iff) |
542 |
542 |
543 lemma if_rsp: |
543 lemma if_rsp: |
544 assumes q: "Quotient3 R Abs Rep" |
544 assumes q: "Quotient3 R Abs Rep" |
545 shows "(op = ===> R ===> R ===> R) If If" |
545 shows "((=) ===> R ===> R ===> R) If If" |
546 by force |
546 by force |
547 |
547 |
548 lemma let_prs: |
548 lemma let_prs: |
549 assumes q1: "Quotient3 R1 Abs1 Rep1" |
549 assumes q1: "Quotient3 R1 Abs1 Rep1" |
550 and q2: "Quotient3 R2 Abs2 Rep2" |
550 and q2: "Quotient3 R2 Abs2 Rep2" |
710 lemma OOO_eq_quotient3: |
710 lemma OOO_eq_quotient3: |
711 fixes R1 :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
711 fixes R1 :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
712 fixes Abs1 :: "'a \<Rightarrow> 'b" and Rep1 :: "'b \<Rightarrow> 'a" |
712 fixes Abs1 :: "'a \<Rightarrow> 'b" and Rep1 :: "'b \<Rightarrow> 'a" |
713 fixes Abs2 :: "'b \<Rightarrow> 'c" and Rep2 :: "'c \<Rightarrow> 'b" |
713 fixes Abs2 :: "'b \<Rightarrow> 'c" and Rep2 :: "'c \<Rightarrow> 'b" |
714 assumes R1: "Quotient3 R1 Abs1 Rep1" |
714 assumes R1: "Quotient3 R1 Abs1 Rep1" |
715 assumes R2: "Quotient3 op= Abs2 Rep2" |
715 assumes R2: "Quotient3 (=) Abs2 Rep2" |
716 shows "Quotient3 (R1 OOO op=) (Abs2 \<circ> Abs1) (Rep1 \<circ> Rep2)" |
716 shows "Quotient3 (R1 OOO (=)) (Abs2 \<circ> Abs1) (Rep1 \<circ> Rep2)" |
717 using assms |
717 using assms |
718 by (rule OOO_quotient3) auto |
718 by (rule OOO_quotient3) auto |
719 |
719 |
720 subsection \<open>Quotient3 to Quotient\<close> |
720 subsection \<open>Quotient3 to Quotient\<close> |
721 |
721 |