author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Mon, 10 May 2010 12:04:40 +0200 | |
changeset 2085 | 78ffb5b00e4f |
permissions | -rw-r--r-- |
2085
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
1 |
theory Pair |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
2 |
imports Quotient_Product "../../../Nominal/FSet" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
3 |
begin |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
4 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
5 |
fun alpha :: "('a \<times> 'a) \<Rightarrow> ('a \<times> 'a) \<Rightarrow> bool" (infix "\<approx>" 100) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
6 |
where |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
7 |
"(a, b) \<approx> (c, d) = (a = c \<and> b = d \<or> a = d \<and> b = c)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
8 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
9 |
lemma alpha_refl: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
10 |
shows "z \<approx> z" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
11 |
by (case_tac z, auto) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
12 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
13 |
lemma alpha_equivp: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
14 |
shows "equivp op \<approx>" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
15 |
unfolding equivp_reflp_symp_transp reflp_def symp_def transp_def |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
16 |
by auto |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
17 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
18 |
quotient_type |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
19 |
'a pair_set = "'a \<times> 'a" / alpha |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
20 |
by (auto intro: alpha_equivp) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
21 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
22 |
quotient_definition |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
23 |
"Two :: 'a \<Rightarrow> 'a \<Rightarrow> 'a pair_set" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
24 |
is |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
25 |
"Pair :: 'a \<Rightarrow> 'a \<Rightarrow> ('a \<times> 'a)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
26 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
27 |
fun |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
28 |
memb_both_lists |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
29 |
where |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
30 |
"memb_both_lists a (b, c) = (memb a b \<and> memb a c)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
31 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
32 |
quotient_definition |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
33 |
"mem_fsets :: 'a \<Rightarrow> 'a fset pair_set \<Rightarrow> bool" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
34 |
is memb_both_lists |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
35 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
36 |
lemma prod_hlp: "prod_fun abs_fset abs_fset (prod_fun rep_fset rep_fset x) = x" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
37 |
by (cases x, auto simp add: Quotient_abs_rep[OF Quotient_fset]) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
38 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
39 |
lemma prod_hlp2: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
40 |
"prod_rel list_eq list_eq (prod_fun rep_fset rep_fset z) (prod_fun rep_fset rep_fset z)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
41 |
by (cases z, simp) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
42 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
43 |
lemma [quot_thm]: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
44 |
shows "Quotient ((op \<approx>) OOO (prod_rel list_eq list_eq)) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
45 |
(abs_pair_set \<circ> prod_fun abs_fset abs_fset) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
46 |
(prod_fun rep_fset rep_fset \<circ> rep_pair_set)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
47 |
unfolding Quotient_def comp_def |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
48 |
apply (intro conjI allI) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
49 |
apply (simp add: prod_hlp Quotient_abs_rep[OF Quotient_pair_set]) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
50 |
apply rule |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
51 |
apply (rule alpha_refl) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
52 |
apply rule |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
53 |
apply (rule prod_hlp2) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
54 |
apply (rule alpha_refl) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
55 |
apply (intro iffI conjI) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
56 |
sorry |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
57 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
58 |
lemma [quot_respect]: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
59 |
"(op = ===> op \<approx> OOO prod_rel list_eq list_eq ===> op =) memb_both_lists memb_both_lists" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
60 |
apply (intro fun_relI) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
61 |
apply clarify |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
62 |
apply (simp only: memb_both_lists.simps) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
63 |
sorry |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
64 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
65 |
lemma [quot_respect]: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
66 |
"(list_eq ===> list_eq ===> op \<approx> OOO prod_rel list_eq list_eq) Pair Pair" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
67 |
apply (intro fun_relI) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
68 |
apply rule |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
69 |
apply (rule alpha_refl) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
70 |
apply rule |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
71 |
prefer 2 |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
72 |
apply (rule alpha_refl) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
73 |
apply simp |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
74 |
done |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
75 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
76 |
lemma [quot_preserve]: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
77 |
"(rep_fset ---> rep_fset ---> abs_pair_set \<circ> prod_fun abs_fset abs_fset) Pair = Two" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
78 |
by (simp add: expand_fun_eq Quotient_abs_rep[OF Quotient_fset] Two_def) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
79 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
80 |
lemma "mem_fsets a (Two b c) = (a |\<in>| b \<and> a |\<in>| c)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
81 |
by (lifting memb_both_lists.simps) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
82 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
83 |
(* Doing it in 2 steps *) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
84 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
85 |
quotient_definition |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
86 |
"mem_lists :: 'a \<Rightarrow> 'a list pair_set \<Rightarrow> bool" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
87 |
is memb_both_lists |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
88 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
89 |
lemma [quot_respect]: "(op = ===> op \<approx> ===> op =) memb_both_lists memb_both_lists" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
90 |
by auto |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
91 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
92 |
lemma [quot_respect]: "(op = ===> op = ===> op \<approx>) Pair Pair" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
93 |
by auto |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
94 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
95 |
lemma step1: "mem_lists a (Two b c) = (memb a b \<and> memb a c)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
96 |
by (lifting memb_both_lists.simps) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
97 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
98 |
lemma step2: "mem_fsets a (Two b c) = (a |\<in>| b \<and> a |\<in>| c)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
99 |
(* apply (lifting step1) ??? *) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
100 |
oops |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
101 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
102 |
(* Doing it in 2 steps the other way *) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
103 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
104 |
quotient_definition |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
105 |
"memb_both_fsets :: 'a \<Rightarrow> 'a fset \<times> 'a fset \<Rightarrow> bool" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
106 |
is memb_both_lists |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
107 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
108 |
lemma [quot_respect]: |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
109 |
"(op = ===> prod_rel list_eq list_eq ===> op =) memb_both_lists memb_both_lists" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
110 |
by (auto simp add: memb_def[symmetric]) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
111 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
112 |
lemma bla: "memb_both_fsets a (b, c) = (a |\<in>| b \<and> a |\<in>| c)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
113 |
by (lifting memb_both_lists.simps) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
114 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
115 |
lemma step2: "mem_fsets a (Two b c) = (a |\<in>| b \<and> a |\<in>| c)" |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
116 |
(* ??? *) |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
117 |
oops |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
118 |
|
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
119 |
end |
78ffb5b00e4f
Membership in a pair of lists.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
diff
changeset
|
120 |