|
1 |
|
2 theory Disagreement = Main + Swap + Atoms: |
|
3 |
|
4 consts |
|
5 ds :: "(string \<times> string) list \<Rightarrow> (string \<times> string) list \<Rightarrow> string set" |
|
6 defs |
|
7 ds_def: "ds xs ys \<equiv> { a . a \<in> (atms xs \<union> atms ys) \<and> (swapas xs a \<noteq> swapas ys a) }" |
|
8 |
|
9 lemma |
|
10 ds_elem: "\<lbrakk>swapas pi a\<noteq>a\<rbrakk>\<Longrightarrow>a\<in>ds [] pi" |
|
11 apply(simp add: ds_def) |
|
12 apply(auto simp add: swapas_pi_ineq_a) |
|
13 done |
|
14 |
|
15 lemma |
|
16 elem_ds: "\<lbrakk>a\<in>ds [] pi\<rbrakk>\<Longrightarrow>a\<noteq>swapas pi a" |
|
17 apply(simp add: ds_def) |
|
18 done |
|
19 |
|
20 lemma |
|
21 ds_sym: "ds pi1 pi2 = ds pi2 pi1" |
|
22 apply(simp only: ds_def) |
|
23 apply(auto) |
|
24 done |
|
25 |
|
26 lemma |
|
27 ds_trans: "c\<in>ds pi1 pi3\<longrightarrow>(c\<in>ds pi1 pi2 \<or> c\<in>ds pi2 pi3)" |
|
28 apply(auto) |
|
29 apply(simp only: ds_def) |
|
30 apply(auto) |
|
31 apply(drule a_not_in_atms[THEN mp])+ |
|
32 apply(simp) |
|
33 apply(drule a_not_in_atms[THEN mp]) |
|
34 apply(simp) |
|
35 apply(drule swapas_pi_ineq_a[THEN mp]) |
|
36 apply(assumption) |
|
37 done |
|
38 |
|
39 lemma ds_cancel_pi_left: |
|
40 "(c\<in> ds (pi1@pi) (pi2@pi)) \<longrightarrow> (swapas pi c\<in> ds pi1 pi2)" |
|
41 apply(simp only: ds_def) |
|
42 apply(auto) |
|
43 apply(simp_all add: swapas_append) |
|
44 apply(rule a_ineq_swapas_pi[THEN mp], clarify, drule a_not_in_atms[THEN mp], simp)+ |
|
45 done |
|
46 |
|
47 lemma ds_cancel_pi_right: |
|
48 "(swapas pi c\<in> ds pi1 pi2) \<longrightarrow> (c\<in> ds (pi1@pi) (pi2@pi))" |
|
49 apply(simp only: ds_def) |
|
50 apply(auto) |
|
51 apply(simp_all add: swapas_append) |
|
52 apply(rule a_ineq_swapas_pi[THEN mp],clarify, |
|
53 drule a_not_in_atms[THEN mp],drule a_not_in_atms[THEN mp],simp)+ |
|
54 done |
|
55 |
|
56 lemma ds_equality: |
|
57 "(ds [] pi)-{a,swapas pi a} = (ds [] ((a,swapas pi a)#pi))-{swapas pi a}" |
|
58 apply(simp only: ds_def) |
|
59 apply(auto) |
|
60 done |
|
61 |
|
62 lemma ds_7: |
|
63 "\<lbrakk>b\<noteq> swapas pi b;a\<in>ds [] ((b,swapas pi b)#pi)\<rbrakk>\<Longrightarrow>a\<in>ds [] pi" |
|
64 apply(simp only: ds_def) |
|
65 apply(case_tac "b=a") |
|
66 apply(auto) |
|
67 apply(rule swapas_pi_in_atms) |
|
68 apply(drule a_ineq_swapas_pi[THEN mp]) |
|
69 apply(assumption) |
|
70 apply(drule sym) |
|
71 apply(drule swapas_rev_pi_a) |
|
72 apply(simp) |
|
73 apply(case_tac "swapas pi b = a") |
|
74 apply(auto) |
|
75 apply(drule sym) |
|
76 apply(drule swapas_rev_pi_a) |
|
77 apply(simp) |
|
78 done |
|
79 |
|
80 lemma ds_cancel_pi_front: |
|
81 "ds (pi@pi1) (pi@pi2) = ds pi1 pi2" |
|
82 apply(simp only: ds_def) |
|
83 apply(auto) |
|
84 apply(simp_all add: swapas_append) |
|
85 apply(rule swapas_pi_ineq_a[THEN mp], clarify, drule a_not_in_atms[THEN mp], simp)+ |
|
86 apply(drule swapas_rev_pi_a, simp)+ |
|
87 done |
|
88 |
|
89 lemma ds_rev_pi_pi: |
|
90 "ds ((rev pi1)@pi1) pi2 = ds [] pi2" |
|
91 apply(simp only: ds_def) |
|
92 apply(auto) |
|
93 apply(simp_all add: swapas_append) |
|
94 apply(drule a_ineq_swapas_pi[THEN mp], assumption)+ |
|
95 done |
|
96 |
|
97 lemma ds_rev: |
|
98 "ds [] ((rev pi1)@pi2) = ds pi1 pi2" |
|
99 apply(subgoal_tac "ds pi1 pi2 = ds ((rev pi1)@pi1) ((rev pi1)@pi2)") |
|
100 apply(simp add: ds_rev_pi_pi) |
|
101 apply(simp only: ds_cancel_pi_front) |
|
102 done |
|
103 |
|
104 lemma ds_acabbc: |
|
105 "\<lbrakk>a\<noteq>b;b\<noteq>c;c\<noteq>a\<rbrakk>\<Longrightarrow>ds [] [(a, c), (a, b), (b, c)] = {a, b}" |
|
106 apply(simp only: ds_def) |
|
107 apply(auto) |
|
108 done |
|
109 |
|
110 lemma ds_baab: |
|
111 "\<lbrakk>a\<noteq>b\<rbrakk>\<Longrightarrow>ds [] [(b, a), (a, b)] = {}" |
|
112 apply(simp only: ds_def) |
|
113 apply(auto) |
|
114 done |
|
115 |
|
116 lemma ds_abab: |
|
117 "\<lbrakk>a\<noteq>b\<rbrakk>\<Longrightarrow>ds [] [(a, b), (a, b)] = {}" |
|
118 apply(simp only: ds_def) |
|
119 apply(auto) |
|
120 done |
|
121 |
|
122 (* disagreement set as list *) |
|
123 |
|
124 consts flatten :: "(string \<times> string)list \<Rightarrow> string list" |
|
125 primrec |
|
126 "flatten [] = []" |
|
127 "flatten (x#xs) = (fst x)#(snd x)#(flatten xs)" |
|
128 |
|
129 consts ds_list :: "(string \<times> string)list \<Rightarrow> (string \<times> string)list \<Rightarrow> string list" |
|
130 defs ds_list_def: "ds_list pi1 pi2 \<equiv> remdups ([x:(flatten (pi1@pi2)). x\<in>ds pi1 pi2])" |
|
131 |
|
132 lemma set_flatten_eq_atms: |
|
133 "set (flatten pi) = atms pi" |
|
134 apply(induct_tac pi) |
|
135 apply(auto) |
|
136 done |
|
137 |
|
138 lemma ds_list_equ_ds: |
|
139 "set (ds_list pi1 pi2) = ds pi1 pi2" |
|
140 apply(auto) |
|
141 apply(simp add: ds_list_def) |
|
142 apply(simp add: ds_list_def) |
|
143 apply(simp add: set_flatten_eq_atms) |
|
144 apply(simp add: ds_def) |
|
145 done |
|
146 |
|
147 end |