equal
deleted
inserted
replaced
7 theory Quotient_Sum |
7 theory Quotient_Sum |
8 imports Main Quotient_Syntax |
8 imports Main Quotient_Syntax |
9 begin |
9 begin |
10 |
10 |
11 fun |
11 fun |
12 sum_rel |
12 sum_rel :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a + 'b \<Rightarrow> 'a + 'b \<Rightarrow> bool" |
13 where |
13 where |
14 "sum_rel R1 R2 (Inl a1) (Inl b1) = R1 a1 b1" |
14 "sum_rel R1 R2 (Inl a1) (Inl b1) = R1 a1 b1" |
15 | "sum_rel R1 R2 (Inl a1) (Inr b2) = False" |
15 | "sum_rel R1 R2 (Inl a1) (Inr b2) = False" |
16 | "sum_rel R1 R2 (Inr a2) (Inl b1) = False" |
16 | "sum_rel R1 R2 (Inr a2) (Inl b1) = False" |
17 | "sum_rel R1 R2 (Inr a2) (Inr b2) = R2 a2 b2" |
17 | "sum_rel R1 R2 (Inr a2) (Inr b2) = R2 a2 b2" |
18 |
18 |
19 fun |
19 primrec |
20 sum_map |
20 sum_map :: "('a \<Rightarrow> 'c) \<Rightarrow> ('b \<Rightarrow> 'd) \<Rightarrow> 'a + 'b \<Rightarrow> 'c + 'd" |
21 where |
21 where |
22 "sum_map f1 f2 (Inl a) = Inl (f1 a)" |
22 "sum_map f1 f2 (Inl a) = Inl (f1 a)" |
23 | "sum_map f1 f2 (Inr a) = Inr (f2 a)" |
23 | "sum_map f1 f2 (Inr a) = Inr (f2 a)" |
24 |
24 |
25 declare [[map sum = (sum_map, sum_rel)]] |
25 declare [[map sum = (sum_map, sum_rel)]] |
60 |
60 |
61 lemma sum_Inl_rsp[quot_respect]: |
61 lemma sum_Inl_rsp[quot_respect]: |
62 assumes q1: "Quotient R1 Abs1 Rep1" |
62 assumes q1: "Quotient R1 Abs1 Rep1" |
63 assumes q2: "Quotient R2 Abs2 Rep2" |
63 assumes q2: "Quotient R2 Abs2 Rep2" |
64 shows "(R1 ===> sum_rel R1 R2) Inl Inl" |
64 shows "(R1 ===> sum_rel R1 R2) Inl Inl" |
65 by simp |
65 by auto |
66 |
66 |
67 lemma sum_Inr_rsp[quot_respect]: |
67 lemma sum_Inr_rsp[quot_respect]: |
68 assumes q1: "Quotient R1 Abs1 Rep1" |
68 assumes q1: "Quotient R1 Abs1 Rep1" |
69 assumes q2: "Quotient R2 Abs2 Rep2" |
69 assumes q2: "Quotient R2 Abs2 Rep2" |
70 shows "(R2 ===> sum_rel R1 R2) Inr Inr" |
70 shows "(R2 ===> sum_rel R1 R2) Inr Inr" |
71 by simp |
71 by auto |
72 |
72 |
73 lemma sum_Inl_prs[quot_preserve]: |
73 lemma sum_Inl_prs[quot_preserve]: |
74 assumes q1: "Quotient R1 Abs1 Rep1" |
74 assumes q1: "Quotient R1 Abs1 Rep1" |
75 assumes q2: "Quotient R2 Abs2 Rep2" |
75 assumes q2: "Quotient R2 Abs2 Rep2" |
76 shows "(Rep1 ---> sum_map Abs1 Abs2) Inl = Inl" |
76 shows "(Rep1 ---> sum_map Abs1 Abs2) Inl = Inl" |