author | Chengsong |
Sat, 24 Sep 2022 00:49:10 +0100 | |
changeset 603 | 370fe1dde7c7 |
parent 563 | c92a41d9c4da |
permissions | -rw-r--r-- |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
theory BasicIdentities |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
imports "Lexer" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
begin |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
datatype rrexp = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
RZERO |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
| RONE |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
| RCHAR char |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
| RSEQ rrexp rrexp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
| RALTS "rrexp list" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
| RSTAR rrexp |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
12 |
| RNTIMES rrexp nat |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
abbreviation |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
"RALT r1 r2 \<equiv> RALTS [r1, r2]" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
fun |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
rnullable :: "rrexp \<Rightarrow> bool" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
"rnullable (RZERO) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
| "rnullable (RONE) = True" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
| "rnullable (RCHAR c) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
| "rnullable (RALTS rs) = (\<exists>r \<in> set rs. rnullable r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
| "rnullable (RSEQ r1 r2) = (rnullable r1 \<and> rnullable r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
| "rnullable (RSTAR r) = True" |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
27 |
| "rnullable (RNTIMES r n) = (if n = 0 then True else rnullable r)" |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
fun |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
rder :: "char \<Rightarrow> rrexp \<Rightarrow> rrexp" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
"rder c (RZERO) = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
| "rder c (RONE) = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
| "rder c (RCHAR d) = (if c = d then RONE else RZERO)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
| "rder c (RALTS rs) = RALTS (map (rder c) rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
| "rder c (RSEQ r1 r2) = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
(if rnullable r1 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
38 |
then RALT (RSEQ (rder c r1) r2) (rder c r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
else RSEQ (rder c r1) r2)" |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
40 |
| "rder c (RSTAR r) = RSEQ (rder c r) (RSTAR r)" |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
41 |
| "rder c (RNTIMES r n) = (if n = 0 then RZERO else RSEQ (rder c r) (RNTIMES r (n - 1)))" |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
43 |
fun |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
44 |
rders :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
"rders r [] = r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
| "rders r (c#s) = rders (rder c r) s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
fun rdistinct :: "'a list \<Rightarrow>'a set \<Rightarrow> 'a list" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
50 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
51 |
"rdistinct [] acc = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
52 |
| "rdistinct (x#xs) acc = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
53 |
(if x \<in> acc then rdistinct xs acc |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
54 |
else x # (rdistinct xs ({x} \<union> acc)))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
55 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
56 |
lemma rdistinct1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
57 |
assumes "a \<in> acc" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
58 |
shows "a \<notin> set (rdistinct rs acc)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
59 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
60 |
apply(induct rs arbitrary: acc a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
61 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
62 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
63 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
64 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
65 |
lemma rdistinct_does_the_job: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
66 |
shows "distinct (rdistinct rs s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
67 |
apply(induct rs s rule: rdistinct.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
68 |
apply(auto simp add: rdistinct1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
69 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
70 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
71 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
72 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
73 |
lemma rdistinct_concat: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
74 |
assumes "set rs \<subseteq> rset" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
75 |
shows "rdistinct (rs @ rsa) rset = rdistinct rsa rset" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
76 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
77 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
78 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
79 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
80 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
81 |
lemma distinct_not_exist: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
82 |
assumes "a \<notin> set rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
83 |
shows "rdistinct rs rset = rdistinct rs (insert a rset)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
84 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
85 |
apply(induct rs arbitrary: rset) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
86 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
87 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
88 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
89 |
lemma rdistinct_on_distinct: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
90 |
shows "distinct rs \<Longrightarrow> rdistinct rs {} = rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
91 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
92 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
93 |
using distinct_not_exist by fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
94 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
95 |
lemma distinct_rdistinct_append: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
96 |
assumes "distinct rs1" "\<forall>r \<in> set rs1. r \<notin> acc" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
97 |
shows "rdistinct (rs1 @ rsa) acc = rs1 @ (rdistinct rsa (acc \<union> set rs1))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
98 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
99 |
apply(induct rs1 arbitrary: rsa acc) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
100 |
apply(auto)[1] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
101 |
apply(auto)[1] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
102 |
apply(drule_tac x="rsa" in meta_spec) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
103 |
apply(drule_tac x="{a} \<union> acc" in meta_spec) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
104 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
105 |
apply(drule meta_mp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
106 |
apply(auto)[1] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
107 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
108 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
109 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
110 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
111 |
lemma rdistinct_set_equality1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
112 |
shows "set (rdistinct rs acc) = set rs - acc" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
113 |
apply(induct rs acc rule: rdistinct.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
114 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
115 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
116 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
117 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
118 |
lemma rdistinct_set_equality: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
119 |
shows "set (rdistinct rs {}) = set rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
120 |
by (simp add: rdistinct_set_equality1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
121 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
122 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
123 |
fun rflts :: "rrexp list \<Rightarrow> rrexp list" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
124 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
125 |
"rflts [] = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
126 |
| "rflts (RZERO # rs) = rflts rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
127 |
| "rflts ((RALTS rs1) # rs) = rs1 @ rflts rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
128 |
| "rflts (r1 # rs) = r1 # rflts rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
129 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
130 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
131 |
lemma rflts_def_idiot: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
132 |
shows "\<lbrakk> a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1\<rbrakk> \<Longrightarrow> rflts (a # rs) = a # rflts rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
133 |
apply(case_tac a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
134 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
135 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
136 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
137 |
lemma rflts_def_idiot2: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
138 |
shows "\<lbrakk>a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1; a \<in> set rs\<rbrakk> \<Longrightarrow> a \<in> set (rflts rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
139 |
apply(induct rs rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
140 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
141 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
142 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
143 |
lemma flts_append: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
144 |
shows "rflts (rs1 @ rs2) = rflts rs1 @ rflts rs2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
145 |
apply(induct rs1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
146 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
147 |
apply(case_tac a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
148 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
149 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
150 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
151 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
152 |
fun rsimp_ALTs :: " rrexp list \<Rightarrow> rrexp" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
153 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
154 |
"rsimp_ALTs [] = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
155 |
| "rsimp_ALTs [r] = r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
156 |
| "rsimp_ALTs rs = RALTS rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
157 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
158 |
lemma rsimpalts_conscons: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
159 |
shows "rsimp_ALTs (r1 # rsa @ r2 # rsb) = RALTS (r1 # rsa @ r2 # rsb)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
160 |
by (metis Nil_is_append_conv list.exhaust rsimp_ALTs.simps(3)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
161 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
162 |
lemma rsimp_alts_equal: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
163 |
shows "rsimp_ALTs (rsa @ a # rsb @ a # rsc) = RALTS (rsa @ a # rsb @ a # rsc) " |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
164 |
by (metis append_Cons append_Nil neq_Nil_conv rsimpalts_conscons) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
165 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
166 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
167 |
fun rsimp_SEQ :: " rrexp \<Rightarrow> rrexp \<Rightarrow> rrexp" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
168 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
169 |
"rsimp_SEQ RZERO _ = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
170 |
| "rsimp_SEQ _ RZERO = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
171 |
| "rsimp_SEQ RONE r2 = r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
172 |
| "rsimp_SEQ r1 r2 = RSEQ r1 r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
173 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
174 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
175 |
fun rsimp :: "rrexp \<Rightarrow> rrexp" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
176 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
177 |
"rsimp (RSEQ r1 r2) = rsimp_SEQ (rsimp r1) (rsimp r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
178 |
| "rsimp (RALTS rs) = rsimp_ALTs (rdistinct (rflts (map rsimp rs)) {}) " |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
179 |
| "rsimp r = r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
180 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
181 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
182 |
fun |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
183 |
rders_simp :: "rrexp \<Rightarrow> string \<Rightarrow> rrexp" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
184 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
185 |
"rders_simp r [] = r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
186 |
| "rders_simp r (c#s) = rders_simp (rsimp (rder c r)) s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
187 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
188 |
fun rsize :: "rrexp \<Rightarrow> nat" where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
189 |
"rsize RZERO = 1" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
190 |
| "rsize (RONE) = 1" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
191 |
| "rsize (RCHAR c) = 1" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
192 |
| "rsize (RALTS rs) = Suc (sum_list (map rsize rs))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
193 |
| "rsize (RSEQ r1 r2) = Suc (rsize r1 + rsize r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
194 |
| "rsize (RSTAR r) = Suc (rsize r)" |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
195 |
| "rsize (RNTIMES r n) = Suc (rsize r) + n" |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
196 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
197 |
abbreviation rsizes where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
198 |
"rsizes rs \<equiv> sum_list (map rsize rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
199 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
200 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
201 |
lemma rder_rsimp_ALTs_commute: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
202 |
shows " (rder x (rsimp_ALTs rs)) = rsimp_ALTs (map (rder x) rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
203 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
204 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
205 |
apply(case_tac rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
206 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
207 |
apply auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
208 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
209 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
210 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
211 |
lemma rsimp_aalts_smaller: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
212 |
shows "rsize (rsimp_ALTs rs) \<le> rsize (RALTS rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
213 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
214 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
215 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
216 |
apply(case_tac "rs = []") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
217 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
218 |
apply(subgoal_tac "\<exists>rsp ap. rs = ap # rsp") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
219 |
apply(erule exE)+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
220 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
221 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
222 |
by(meson neq_Nil_conv) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
223 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
224 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
225 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
226 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
227 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
228 |
lemma rSEQ_mono: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
229 |
shows "rsize (rsimp_SEQ r1 r2) \<le>rsize (RSEQ r1 r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
230 |
apply auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
231 |
apply(induct r1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
232 |
apply auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
233 |
apply(case_tac "r2") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
234 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
235 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
236 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
237 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
238 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
239 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
240 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
241 |
apply(case_tac r2) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
242 |
apply simp_all |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
243 |
apply(case_tac r2) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
244 |
apply simp_all |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
245 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
246 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
247 |
lemma ralts_cap_mono: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
248 |
shows "rsize (RALTS rs) \<le> Suc (rsizes rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
249 |
by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
250 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
251 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
252 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
253 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
254 |
lemma rflts_mono: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
255 |
shows "rsizes (rflts rs) \<le> rsizes rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
256 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
257 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
258 |
apply(case_tac "a = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
259 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
260 |
apply(case_tac "\<exists>rs1. a = RALTS rs1") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
261 |
apply(erule exE) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
262 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
263 |
apply(subgoal_tac "rflts (a # rs) = a # (rflts rs)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
264 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
265 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
266 |
using rflts_def_idiot apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
267 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
268 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
269 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
270 |
lemma rdistinct_smaller: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
271 |
shows "rsizes (rdistinct rs ss) \<le> rsizes rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
272 |
apply (induct rs arbitrary: ss) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
273 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
274 |
by (simp add: trans_le_add2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
275 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
276 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
277 |
lemma rsimp_alts_mono : |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
278 |
shows "\<And>x. (\<And>xa. xa \<in> set x \<Longrightarrow> rsize (rsimp xa) \<le> rsize xa) \<Longrightarrow> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
279 |
rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {})) \<le> Suc (rsizes x)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
280 |
apply(subgoal_tac "rsize (rsimp_ALTs (rdistinct (rflts (map rsimp x)) {} )) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
281 |
\<le> rsize (RALTS (rdistinct (rflts (map rsimp x)) {} ))") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
282 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
283 |
using rsimp_aalts_smaller apply auto[1] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
284 |
apply(subgoal_tac "rsize (RALTS (rdistinct (rflts (map rsimp x)) {})) \<le>Suc (rsizes (rdistinct (rflts (map rsimp x)) {}))") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
285 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
286 |
using ralts_cap_mono apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
287 |
apply(subgoal_tac "rsizes (rdistinct (rflts (map rsimp x)) {}) \<le> rsizes (rflts (map rsimp x))") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
288 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
289 |
using rdistinct_smaller apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
290 |
apply(subgoal_tac "rsizes (rflts (map rsimp x)) \<le> rsizes (map rsimp x)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
291 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
292 |
using rflts_mono apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
293 |
apply(subgoal_tac "rsizes (map rsimp x) \<le> rsizes x") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
294 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
295 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
296 |
apply (simp add: sum_list_mono) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
297 |
by linarith |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
298 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
299 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
300 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
301 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
302 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
303 |
lemma rsimp_mono: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
304 |
shows "rsize (rsimp r) \<le> rsize r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
305 |
apply(induct r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
306 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
307 |
apply(subgoal_tac "rsize (rsimp_SEQ (rsimp r1) (rsimp r2)) \<le> rsize (RSEQ (rsimp r1) (rsimp r2))") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
308 |
apply force |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
309 |
using rSEQ_mono |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
310 |
apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
311 |
using rsimp_alts_mono by auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
312 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
313 |
lemma idiot: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
314 |
shows "rsimp_SEQ RONE r = r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
315 |
apply(case_tac r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
316 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
317 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
318 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
319 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
320 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
321 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
322 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
323 |
lemma idiot2: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
324 |
shows " \<lbrakk>r1 \<noteq> RZERO; r1 \<noteq> RONE;r2 \<noteq> RZERO\<rbrakk> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
325 |
\<Longrightarrow> rsimp_SEQ r1 r2 = RSEQ r1 r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
326 |
apply(case_tac r1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
327 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
328 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
329 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
330 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
331 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
332 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
333 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
334 |
apply simp_all |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
335 |
apply(case_tac r2) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
336 |
apply simp_all |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
337 |
apply(case_tac r2) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
338 |
apply simp_all |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
339 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
340 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
341 |
lemma rders__onechar: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
342 |
shows " (rders_simp r [c]) = (rsimp (rders r [c]))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
343 |
by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
344 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
345 |
lemma rders_append: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
346 |
"rders c (s1 @ s2) = rders (rders c s1) s2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
347 |
apply(induct s1 arbitrary: c s2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
348 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
349 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
350 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
351 |
lemma rders_simp_append: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
352 |
"rders_simp c (s1 @ s2) = rders_simp (rders_simp c s1) s2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
353 |
apply(induct s1 arbitrary: c s2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
354 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
355 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
356 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
357 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
358 |
lemma rders_simp_one_char: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
359 |
shows "rders_simp r [c] = rsimp (rder c r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
360 |
apply auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
361 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
362 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
363 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
364 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
365 |
fun nonalt :: "rrexp \<Rightarrow> bool" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
366 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
367 |
"nonalt (RALTS rs) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
368 |
| "nonalt r = True" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
369 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
370 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
371 |
fun good :: "rrexp \<Rightarrow> bool" where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
372 |
"good RZERO = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
373 |
| "good (RONE) = True" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
374 |
| "good (RCHAR c) = True" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
375 |
| "good (RALTS []) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
376 |
| "good (RALTS [r]) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
377 |
| "good (RALTS (r1 # r2 # rs)) = ((distinct ( (r1 # r2 # rs))) \<and>(\<forall>r' \<in> set (r1 # r2 # rs). good r' \<and> nonalt r'))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
378 |
| "good (RSEQ RZERO _) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
379 |
| "good (RSEQ RONE _) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
380 |
| "good (RSEQ _ RZERO) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
381 |
| "good (RSEQ r1 r2) = (good r1 \<and> good r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
382 |
| "good (RSTAR r) = True" |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
383 |
| "good (RNTIMES r n) = True" |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
384 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
385 |
lemma k0a: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
386 |
shows "rflts [RALTS rs] = rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
387 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
388 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
389 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
390 |
lemma bbbbs: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
391 |
assumes "good r" "r = RALTS rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
392 |
shows "rsimp_ALTs (rflts [r]) = RALTS rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
393 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
394 |
by (metis good.simps(4) good.simps(5) k0a rsimp_ALTs.elims) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
395 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
396 |
lemma bbbbs1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
397 |
shows "nonalt r \<or> (\<exists> rs. r = RALTS rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
398 |
by (meson nonalt.elims(3)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
399 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
400 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
401 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
402 |
lemma good0: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
403 |
assumes "rs \<noteq> Nil" "\<forall>r \<in> set rs. nonalt r" "distinct rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
404 |
shows "good (rsimp_ALTs rs) \<longleftrightarrow> (\<forall>r \<in> set rs. good r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
405 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
406 |
apply(induct rs rule: rsimp_ALTs.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
407 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
408 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
409 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
410 |
lemma flts1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
411 |
assumes "good r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
412 |
shows "rflts [r] \<noteq> []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
413 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
414 |
apply(induct r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
415 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
416 |
using good.simps(4) by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
417 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
418 |
lemma flts2: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
419 |
assumes "good r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
420 |
shows "\<forall>r' \<in> set (rflts [r]). good r' \<and> nonalt r'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
421 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
422 |
apply(induct r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
423 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
424 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
425 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
426 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
427 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
428 |
apply(auto)[1] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
429 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
430 |
apply (metis flts1 good.simps(5) good.simps(6) k0a neq_Nil_conv) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
431 |
apply (metis flts1 good.simps(5) good.simps(6) k0a neq_Nil_conv) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
432 |
apply fastforce |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
433 |
apply(simp) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
434 |
by simp |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
435 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
436 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
437 |
lemma flts3: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
438 |
assumes "\<forall>r \<in> set rs. good r \<or> r = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
439 |
shows "\<forall>r \<in> set (rflts rs). good r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
440 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
441 |
apply(induct rs arbitrary: rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
442 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
443 |
by (metis UnE flts2 k0a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
444 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
445 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
446 |
lemma k0: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
447 |
shows "rflts (r # rs1) = rflts [r] @ rflts rs1" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
448 |
apply(induct r arbitrary: rs1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
449 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
450 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
451 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
452 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
453 |
lemma good_SEQ: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
454 |
assumes "r1 \<noteq> RZERO" "r2 \<noteq> RZERO" " r1 \<noteq> RONE" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
455 |
shows "good (RSEQ r1 r2) = (good r1 \<and> good r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
456 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
457 |
apply(case_tac r1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
458 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
459 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
460 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
461 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
462 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
463 |
apply(case_tac r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
464 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
465 |
apply(case_tac r2) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
466 |
apply(simp_all) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
467 |
apply(case_tac r2) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
468 |
apply(simp_all) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
469 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
470 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
471 |
lemma rsize0: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
472 |
shows "0 < rsize r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
473 |
apply(induct r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
474 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
475 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
476 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
477 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
478 |
fun nonnested :: "rrexp \<Rightarrow> bool" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
479 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
480 |
"nonnested (RALTS []) = True" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
481 |
| "nonnested (RALTS ((RALTS rs1) # rs2)) = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
482 |
| "nonnested (RALTS (r # rs2)) = nonnested (RALTS rs2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
483 |
| "nonnested r = True" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
484 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
485 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
486 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
487 |
lemma k00: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
488 |
shows "rflts (rs1 @ rs2) = rflts rs1 @ rflts rs2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
489 |
apply(induct rs1 arbitrary: rs2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
490 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
491 |
by (metis append.assoc k0) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
492 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
493 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
494 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
495 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
496 |
lemma k0b: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
497 |
assumes "nonalt r" "r \<noteq> RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
498 |
shows "rflts [r] = [r]" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
499 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
500 |
apply(case_tac r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
501 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
502 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
503 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
504 |
lemma nn1qq: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
505 |
assumes "nonnested (RALTS rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
506 |
shows "\<nexists> rs1. RALTS rs1 \<in> set rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
507 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
508 |
apply(induct rs rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
509 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
510 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
511 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
512 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
513 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
514 |
lemma n0: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
515 |
shows "nonnested (RALTS rs) \<longleftrightarrow> (\<forall>r \<in> set rs. nonalt r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
516 |
apply(induct rs ) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
517 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
518 |
apply (metis list.set_intros(1) nn1qq nonalt.elims(3)) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
519 |
apply (metis nonalt.elims(2) nonnested.simps(3) nonnested.simps(4) nonnested.simps(5) nonnested.simps(6) nonnested.simps(7) nonnested.simps(8)) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
520 |
using bbbbs1 apply fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
521 |
by (metis bbbbs1 list.set_intros(2) nn1qq) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
522 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
523 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
524 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
525 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
526 |
lemma nn1c: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
527 |
assumes "\<forall>r \<in> set rs. nonnested r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
528 |
shows "\<forall>r \<in> set (rflts rs). nonalt r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
529 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
530 |
apply(induct rs rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
531 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
532 |
using n0 by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
533 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
534 |
lemma nn1bb: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
535 |
assumes "\<forall>r \<in> set rs. nonalt r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
536 |
shows "nonnested (rsimp_ALTs rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
537 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
538 |
apply(induct rs rule: rsimp_ALTs.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
539 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
540 |
using nonalt.simps(1) nonnested.elims(3) apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
541 |
using n0 by auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
542 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
543 |
lemma bsimp_ASEQ0: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
544 |
shows "rsimp_SEQ r1 RZERO = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
545 |
apply(induct r1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
546 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
547 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
548 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
549 |
lemma nn1b: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
550 |
shows "nonnested (rsimp r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
551 |
apply(induct r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
552 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
553 |
apply(case_tac "rsimp r1 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
554 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
555 |
apply(case_tac "rsimp r2 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
556 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
557 |
apply(subst bsimp_ASEQ0) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
558 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
559 |
apply(case_tac "\<exists>bs. rsimp r1 = RONE") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
560 |
apply(auto)[1] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
561 |
using idiot apply fastforce |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
562 |
apply (simp add: idiot2) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
563 |
by (metis (mono_tags, lifting) image_iff list.set_map nn1bb nn1c rdistinct_set_equality) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
564 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
565 |
lemma nonalt_flts_rd: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
566 |
shows "\<lbrakk>xa \<in> set (rdistinct (rflts (map rsimp rs)) {})\<rbrakk> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
567 |
\<Longrightarrow> nonalt xa" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
568 |
by (metis Diff_empty ex_map_conv nn1b nn1c rdistinct_set_equality1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
569 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
570 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
571 |
lemma rsimpalts_implies1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
572 |
shows " rsimp_ALTs (a # rdistinct rs {a}) = RZERO \<Longrightarrow> a = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
573 |
using rsimp_ALTs.elims by auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
574 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
575 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
576 |
lemma rsimpalts_implies2: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
577 |
shows "rsimp_ALTs (a # rdistinct rs rset) = RZERO \<Longrightarrow> rdistinct rs rset = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
578 |
by (metis append_butlast_last_id rrexp.distinct(7) rsimpalts_conscons) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
579 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
580 |
lemma rsimpalts_implies21: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
581 |
shows "rsimp_ALTs (a # rdistinct rs {a}) = RZERO \<Longrightarrow> rdistinct rs {a} = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
582 |
using rsimpalts_implies2 by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
583 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
584 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
585 |
lemma bsimp_ASEQ2: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
586 |
shows "rsimp_SEQ RONE r2 = r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
587 |
apply(induct r2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
588 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
589 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
590 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
591 |
lemma elem_smaller_than_set: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
592 |
shows "xa \<in> set list \<Longrightarrow> rsize xa < Suc (rsizes list)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
593 |
apply(induct list) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
594 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
595 |
by (metis image_eqI le_imp_less_Suc list.set_map member_le_sum_list) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
596 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
597 |
lemma rsimp_list_mono: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
598 |
shows "rsizes (map rsimp rs) \<le> rsizes rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
599 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
600 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
601 |
by (simp add: add_mono_thms_linordered_semiring(1) rsimp_mono) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
602 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
603 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
604 |
(*says anything coming out of simp+flts+db will be good*) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
605 |
lemma good2_obv_simplified: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
606 |
shows " \<lbrakk>\<forall>y. rsize y < Suc (rsizes rs) \<longrightarrow> good (rsimp y) \<or> rsimp y = RZERO; |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
607 |
xa \<in> set (rdistinct (rflts (map rsimp rs)) {}); good (rsimp xa) \<or> rsimp xa = RZERO\<rbrakk> \<Longrightarrow> good xa" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
608 |
apply(subgoal_tac " \<forall>xa' \<in> set (map rsimp rs). good xa' \<or> xa' = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
609 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
610 |
apply (simp add: elem_smaller_than_set) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
611 |
by (metis Diff_empty flts3 rdistinct_set_equality1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
612 |
|
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
613 |
thm Diff_empty flts3 rdistinct_set_equality1 |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
614 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
615 |
lemma good1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
616 |
shows "good (rsimp a) \<or> rsimp a = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
617 |
apply(induct a taking: rsize rule: measure_induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
618 |
apply(case_tac x) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
619 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
620 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
621 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
622 |
prefer 3 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
623 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
624 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
625 |
apply(simp only:) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
626 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
627 |
apply (smt (verit, ccfv_threshold) add_mono_thms_linordered_semiring(1) elem_smaller_than_set good0 good2_obv_simplified le_eq_less_or_eq nonalt_flts_rd order_less_trans plus_1_eq_Suc rdistinct_does_the_job rdistinct_smaller rflts_mono rsimp_ALTs.simps(1) rsimp_list_mono) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
628 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
629 |
apply(subgoal_tac "good (rsimp x41) \<or> rsimp x41 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
630 |
apply(subgoal_tac "good (rsimp x42) \<or> rsimp x42 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
631 |
apply(case_tac "rsimp x41 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
632 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
633 |
apply(case_tac "rsimp x42 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
634 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
635 |
using bsimp_ASEQ0 apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
636 |
apply(subgoal_tac "good (rsimp x41)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
637 |
apply(subgoal_tac "good (rsimp x42)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
638 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
639 |
apply (metis bsimp_ASEQ2 good_SEQ idiot2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
640 |
apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
641 |
apply fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
642 |
using less_add_Suc2 apply blast |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
643 |
using less_iff_Suc_add apply blast |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
644 |
using good.simps(45) rsimp.simps(7) by presburger |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
645 |
|
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
646 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
647 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
648 |
fun |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
649 |
RL :: "rrexp \<Rightarrow> string set" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
650 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
651 |
"RL (RZERO) = {}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
652 |
| "RL (RONE) = {[]}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
653 |
| "RL (RCHAR c) = {[c]}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
654 |
| "RL (RSEQ r1 r2) = (RL r1) ;; (RL r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
655 |
| "RL (RALTS rs) = (\<Union> (set (map RL rs)))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
656 |
| "RL (RSTAR r) = (RL r)\<star>" |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
657 |
| "RL (RNTIMES r n) = (RL r) ^^ n" |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
658 |
|
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
659 |
lemma pow_rempty_iff: |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
660 |
shows "[] \<in> (RL r) ^^ n \<longleftrightarrow> (if n = 0 then True else [] \<in> (RL r))" |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
661 |
by (induct n) (auto simp add: Sequ_def) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
662 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
663 |
lemma RL_rnullable: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
664 |
shows "rnullable r = ([] \<in> RL r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
665 |
apply(induct r) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
666 |
apply(auto simp add: Sequ_def pow_rempty_iff) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
667 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
668 |
|
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
669 |
lemma concI_if_Nil1: "[] \<in> A \<Longrightarrow> xs : B \<Longrightarrow> xs \<in> A ;; B" |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
670 |
by (metis append_Nil concI) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
671 |
|
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
672 |
|
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
673 |
lemma empty_pow_add: |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
674 |
fixes A::"string set" |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
675 |
assumes "[] \<in> A" "s \<in> A ^^ n" |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
676 |
shows "s \<in> A ^^ (n + m)" |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
677 |
using assms |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
678 |
apply(induct m arbitrary: n) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
679 |
apply(auto simp add: Sequ_def) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
680 |
done |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
681 |
|
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
682 |
(* |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
683 |
lemma der_pow: |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
684 |
shows "Der c (A ^^ n) = (if n = 0 then {} else (Der c A) ;; (A ^^ (n - 1)))" |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
685 |
apply(induct n arbitrary: A) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
686 |
apply(auto) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
687 |
by (smt (verit, best) Suc_pred concE concI concI_if_Nil2 conc_pow_comm lang_pow.simps(2)) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
688 |
*) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
689 |
|
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
690 |
lemma RL_rder: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
691 |
shows "RL (rder c r) = Der c (RL r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
692 |
apply(induct r) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
693 |
apply(auto simp add: Sequ_def Der_def)[5] |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
694 |
apply (metis append_Cons) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
695 |
using RL_rnullable apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
696 |
apply (metis append_eq_Cons_conv) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
697 |
apply (metis append_Cons) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
698 |
apply (metis RL_rnullable append_eq_Cons_conv) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
699 |
apply simp |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
700 |
apply(simp) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
701 |
done |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
702 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
703 |
lemma RL_rsimp_RSEQ: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
704 |
shows "RL (rsimp_SEQ r1 r2) = (RL r1 ;; RL r2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
705 |
apply(induct r1 r2 rule: rsimp_SEQ.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
706 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
707 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
708 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
709 |
lemma RL_rsimp_RALTS: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
710 |
shows "RL (rsimp_ALTs rs) = (\<Union> (set (map RL rs)))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
711 |
apply(induct rs rule: rsimp_ALTs.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
712 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
713 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
714 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
715 |
lemma RL_rsimp_rdistinct: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
716 |
shows "(\<Union> (set (map RL (rdistinct rs {})))) = (\<Union> (set (map RL rs)))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
717 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
718 |
apply (metis Diff_iff rdistinct_set_equality1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
719 |
by (metis Diff_empty rdistinct_set_equality1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
720 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
721 |
lemma RL_rsimp_rflts: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
722 |
shows "(\<Union> (set (map RL (rflts rs)))) = (\<Union> (set (map RL rs)))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
723 |
apply(induct rs rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
724 |
apply(simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
725 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
726 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
727 |
lemma RL_rsimp: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
728 |
shows "RL r = RL (rsimp r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
729 |
apply(induct r rule: rsimp.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
730 |
apply(auto simp add: Sequ_def RL_rsimp_RSEQ) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
731 |
using RL_rsimp_RALTS RL_rsimp_rdistinct RL_rsimp_rflts apply auto[1] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
732 |
by (smt (verit, del_insts) RL_rsimp_RALTS RL_rsimp_rdistinct RL_rsimp_rflts UN_E image_iff list.set_map) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
733 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
734 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
735 |
lemma qqq1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
736 |
shows "RZERO \<notin> set (rflts (map rsimp rs))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
737 |
by (metis ex_map_conv flts3 good.simps(1) good1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
738 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
739 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
740 |
fun nonazero :: "rrexp \<Rightarrow> bool" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
741 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
742 |
"nonazero RZERO = False" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
743 |
| "nonazero r = True" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
744 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
745 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
746 |
lemma flts_single1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
747 |
assumes "nonalt r" "nonazero r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
748 |
shows "rflts [r] = [r]" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
749 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
750 |
apply(induct r) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
751 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
752 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
753 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
754 |
lemma nonalt0_flts_keeps: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
755 |
shows "(a \<noteq> RZERO) \<and> (\<forall>rs. a \<noteq> RALTS rs) \<Longrightarrow> rflts (a # xs) = a # rflts xs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
756 |
apply(case_tac a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
757 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
758 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
759 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
760 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
761 |
lemma nonalt0_fltseq: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
762 |
shows "\<forall>r \<in> set rs. r \<noteq> RZERO \<and> nonalt r \<Longrightarrow> rflts rs = rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
763 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
764 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
765 |
apply(case_tac "a = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
766 |
apply fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
767 |
apply(case_tac "\<exists>rs1. a = RALTS rs1") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
768 |
apply(erule exE) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
769 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
770 |
using nonalt0_flts_keeps by presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
771 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
772 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
773 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
774 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
775 |
lemma goodalts_nonalt: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
776 |
shows "good (RALTS rs) \<Longrightarrow> rflts rs = rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
777 |
apply(induct x == "RALTS rs" arbitrary: rs rule: good.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
778 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
779 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
780 |
using good.simps(5) apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
781 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
782 |
apply(case_tac "r1 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
783 |
using good.simps(1) apply force |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
784 |
apply(case_tac "r2 = RZERO") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
785 |
using good.simps(1) apply force |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
786 |
apply(subgoal_tac "rflts (r1 # r2 # rs) = r1 # r2 # rflts rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
787 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
788 |
apply (metis nonalt.simps(1) rflts_def_idiot) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
789 |
apply(subgoal_tac "\<forall>r \<in> set rs. r \<noteq> RZERO \<and> nonalt r") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
790 |
apply(subgoal_tac "rflts rs = rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
791 |
apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
792 |
using nonalt0_fltseq apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
793 |
using good.simps(1) by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
794 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
795 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
796 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
797 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
798 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
799 |
lemma test: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
800 |
assumes "good r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
801 |
shows "rsimp r = r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
802 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
803 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
804 |
apply(induct rule: good.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
805 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
806 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
807 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
808 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
809 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
810 |
apply(subgoal_tac "distinct (r1 # r2 # rs)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
811 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
812 |
using good.simps(6) apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
813 |
apply(subgoal_tac "rflts (r1 # r2 # rs ) = r1 # r2 # rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
814 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
815 |
using goodalts_nonalt apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
816 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
817 |
apply(subgoal_tac "r1 \<noteq> r2") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
818 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
819 |
apply (meson distinct_length_2_or_more) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
820 |
apply(subgoal_tac "r1 \<notin> set rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
821 |
apply(subgoal_tac "r2 \<notin> set rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
822 |
apply(subgoal_tac "\<forall>r \<in> set rs. rsimp r = r") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
823 |
apply(subgoal_tac "map rsimp rs = rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
824 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
825 |
apply(subgoal_tac "\<forall>r \<in> {r1, r2}. r \<notin> set rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
826 |
apply (metis distinct_not_exist rdistinct_on_distinct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
827 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
828 |
apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
829 |
apply (meson map_idI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
830 |
apply (metis good.simps(6) insert_iff list.simps(15)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
831 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
832 |
apply (meson distinct.simps(2)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
833 |
apply (simp add: distinct_length_2_or_more) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
834 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
835 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
836 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
837 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
838 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
839 |
lemma rsimp_idem: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
840 |
shows "rsimp (rsimp r) = rsimp r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
841 |
using test good1 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
842 |
by force |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
843 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
844 |
corollary rsimp_inner_idem4: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
845 |
shows "rsimp r = RALTS rs \<Longrightarrow> rflts rs = rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
846 |
by (metis good1 goodalts_nonalt rrexp.simps(12)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
847 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
848 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
849 |
lemma head_one_more_simp: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
850 |
shows "map rsimp (r # rs) = map rsimp (( rsimp r) # rs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
851 |
by (simp add: rsimp_idem) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
852 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
853 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
854 |
lemma der_simp_nullability: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
855 |
shows "rnullable r = rnullable (rsimp r)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
856 |
using RL_rnullable RL_rsimp by auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
857 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
858 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
859 |
lemma no_alt_short_list_after_simp: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
860 |
shows "RALTS rs = rsimp r \<Longrightarrow> rsimp_ALTs rs = RALTS rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
861 |
by (metis bbbbs good1 k0a rrexp.simps(12)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
862 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
863 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
864 |
lemma no_further_dB_after_simp: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
865 |
shows "RALTS rs = rsimp r \<Longrightarrow> rdistinct rs {} = rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
866 |
apply(subgoal_tac "good (RALTS rs)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
867 |
apply(subgoal_tac "distinct rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
868 |
using rdistinct_on_distinct apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
869 |
apply (metis distinct.simps(1) distinct.simps(2) empty_iff good.simps(6) list.exhaust set_empty2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
870 |
using good1 by fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
871 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
872 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
873 |
lemma idem_after_simp1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
874 |
shows "rsimp_ALTs (rdistinct (rflts [rsimp aa]) {}) = rsimp aa" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
875 |
apply(case_tac "rsimp aa") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
876 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
877 |
apply (metis no_alt_short_list_after_simp no_further_dB_after_simp) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
878 |
apply(simp) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
879 |
apply(simp) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
880 |
done |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
881 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
882 |
lemma identity_wwo0: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
883 |
shows "rsimp (rsimp_ALTs (RZERO # rs)) = rsimp (rsimp_ALTs rs)" |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
884 |
apply (metis idem_after_simp1 list.exhaust list.simps(8) list.simps(9) rflts.simps(2) rsimp.simps(2) rsimp.simps(3) rsimp_ALTs.simps(1) rsimp_ALTs.simps(2) rsimp_ALTs.simps(3)) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
885 |
done |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
886 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
887 |
lemma distinct_removes_last: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
888 |
shows "\<lbrakk>a \<in> set as\<rbrakk> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
889 |
\<Longrightarrow> rdistinct as rset = rdistinct (as @ [a]) rset" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
890 |
and "rdistinct (ab # as @ [ab]) rset1 = rdistinct (ab # as) rset1" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
891 |
apply(induct as arbitrary: rset ab rset1 a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
892 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
893 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
894 |
apply(case_tac "aa \<in> rset") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
895 |
apply(case_tac "a = aa") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
896 |
apply (metis append_Cons) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
897 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
898 |
apply(case_tac "a \<in> set as") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
899 |
apply (metis append_Cons rdistinct.simps(2) set_ConsD) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
900 |
apply(case_tac "a = aa") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
901 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
902 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
903 |
apply (metis append_Cons) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
904 |
apply(case_tac "ab \<in> rset1") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
905 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
906 |
apply(subgoal_tac "rdistinct (ab # (a # as) @ [ab]) rset1 = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
907 |
ab # (rdistinct ((a # as) @ [ab]) (insert ab rset1))") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
908 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
909 |
apply force |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
910 |
apply(simp only:) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
911 |
apply(subgoal_tac "rdistinct (ab # a # as) rset1 = ab # (rdistinct (a # as) (insert ab rset1))") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
912 |
apply(simp only:) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
913 |
apply(subgoal_tac "rdistinct ((a # as) @ [ab]) (insert ab rset1) = rdistinct (a # as) (insert ab rset1)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
914 |
apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
915 |
apply(case_tac "a \<in> insert ab rset1") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
916 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
917 |
apply (metis insertI1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
918 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
919 |
apply (meson insertI1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
920 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
921 |
apply(subgoal_tac "rdistinct ((a # as) @ [ab]) rset1 = rdistinct (a # as) rset1") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
922 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
923 |
by (metis append_Cons insert_iff insert_is_Un rdistinct.simps(2)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
924 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
925 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
926 |
lemma distinct_removes_middle: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
927 |
shows "\<lbrakk>a \<in> set as\<rbrakk> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
928 |
\<Longrightarrow> rdistinct (as @ as2) rset = rdistinct (as @ [a] @ as2) rset" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
929 |
and "rdistinct (ab # as @ [ab] @ as3) rset1 = rdistinct (ab # as @ as3) rset1" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
930 |
apply(induct as arbitrary: rset rset1 ab as2 as3 a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
931 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
932 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
933 |
apply(case_tac "a \<in> rset") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
934 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
935 |
apply metis |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
936 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
937 |
apply (metis insertI1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
938 |
apply(case_tac "a = ab") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
939 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
940 |
apply(case_tac "ab \<in> rset") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
941 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
942 |
apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
943 |
apply (meson insertI1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
944 |
apply(case_tac "a \<in> rset") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
945 |
apply (metis (no_types, opaque_lifting) Un_insert_left append_Cons insert_iff rdistinct.simps(2) sup_bot_left) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
946 |
apply(case_tac "ab \<in> rset") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
947 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
948 |
apply (meson insert_iff) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
949 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
950 |
by (metis insertI1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
951 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
952 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
953 |
lemma distinct_removes_middle3: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
954 |
shows "\<lbrakk>a \<in> set as\<rbrakk> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
955 |
\<Longrightarrow> rdistinct (as @ a #as2) rset = rdistinct (as @ as2) rset" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
956 |
using distinct_removes_middle(1) by fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
957 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
958 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
959 |
lemma distinct_removes_list: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
960 |
shows "\<lbrakk> \<forall>r \<in> set rs. r \<in> set as\<rbrakk> \<Longrightarrow> rdistinct (as @ rs) {} = rdistinct as {}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
961 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
962 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
963 |
apply(subgoal_tac "rdistinct (as @ a # rs) {} = rdistinct (as @ rs) {}") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
964 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
965 |
apply (metis append_Cons append_Nil distinct_removes_middle(1)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
966 |
by presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
967 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
968 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
969 |
lemma spawn_simp_rsimpalts: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
970 |
shows "rsimp (rsimp_ALTs rs) = rsimp (rsimp_ALTs (map rsimp rs))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
971 |
apply(cases rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
972 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
973 |
apply(case_tac list) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
974 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
975 |
apply(subst rsimp_idem[symmetric]) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
976 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
977 |
apply(subgoal_tac "rsimp_ALTs rs = RALTS rs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
978 |
apply(simp only:) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
979 |
apply(subgoal_tac "rsimp_ALTs (map rsimp rs) = RALTS (map rsimp rs)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
980 |
apply(simp only:) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
981 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
982 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
983 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
984 |
using rsimp_ALTs.simps(3) apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
985 |
apply auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
986 |
apply(subst rsimp_idem)+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
987 |
by (metis comp_apply rsimp_idem) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
988 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
989 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
990 |
lemma simp_singlealt_flatten: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
991 |
shows "rsimp (RALTS [RALTS rsa]) = rsimp (RALTS (rsa @ []))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
992 |
apply(induct rsa) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
993 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
994 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
995 |
by (metis idem_after_simp1 list.simps(9) rsimp.simps(2)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
996 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
997 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
998 |
lemma good1_rsimpalts: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
999 |
shows "rsimp r = RALTS rs \<Longrightarrow> rsimp_ALTs rs = RALTS rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1000 |
by (metis no_alt_short_list_after_simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1001 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1002 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1003 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1004 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1005 |
lemma good1_flatten: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1006 |
shows "\<lbrakk> rsimp r = (RALTS rs1)\<rbrakk> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1007 |
\<Longrightarrow> rflts (rsimp_ALTs rs1 # map rsimp rsb) = rflts (rs1 @ map rsimp rsb)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1008 |
apply(subst good1_rsimpalts) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1009 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1010 |
apply(subgoal_tac "rflts (rs1 @ map rsimp rsb) = rs1 @ rflts (map rsimp rsb)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1011 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1012 |
using flts_append rsimp_inner_idem4 by presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1013 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1014 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1015 |
lemma flatten_rsimpalts: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1016 |
shows "rflts (rsimp_ALTs (rdistinct (rflts (map rsimp rsa)) {}) # map rsimp rsb) = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1017 |
rflts ( (rdistinct (rflts (map rsimp rsa)) {}) @ map rsimp rsb)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1018 |
apply(case_tac "map rsimp rsa") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1019 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1020 |
apply(case_tac "list") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1021 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1022 |
apply(case_tac a) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1023 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1024 |
apply(rename_tac rs1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1025 |
apply (metis good1_flatten map_eq_Cons_D no_further_dB_after_simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1026 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1027 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1028 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1029 |
apply(subgoal_tac "\<forall>r \<in> set( rflts (map rsimp rsa)). good r") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1030 |
apply(case_tac "rdistinct (rflts (map rsimp rsa)) {}") |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1031 |
apply simp |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1032 |
apply auto[1] |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1033 |
apply simp |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1034 |
apply(simp) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1035 |
apply(case_tac "lista") |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1036 |
apply simp_all |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1037 |
|
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1038 |
apply (metis append_Cons append_Nil good1_flatten rflts.simps(2) rsimp.simps(2) rsimp_ALTs.elims) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1039 |
by (metis (no_types, opaque_lifting) append_Cons append_Nil good1_flatten rflts.simps(2) rsimp.simps(2) rsimp_ALTs.elims) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1040 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1041 |
lemma last_elem_out: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1042 |
shows "\<lbrakk>x \<notin> set xs; x \<notin> rset \<rbrakk> \<Longrightarrow> rdistinct (xs @ [x]) rset = rdistinct xs rset @ [x]" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1043 |
apply(induct xs arbitrary: rset) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1044 |
apply simp+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1045 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1046 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1047 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1048 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1049 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1050 |
lemma rdistinct_concat_general: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1051 |
shows "rdistinct (rs1 @ rs2) {} = (rdistinct rs1 {}) @ (rdistinct rs2 (set rs1))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1052 |
apply(induct rs1 arbitrary: rs2 rule: rev_induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1053 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1054 |
apply(drule_tac x = "x # rs2" in meta_spec) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1055 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1056 |
apply(case_tac "x \<in> set xs") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1057 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1058 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1059 |
apply (simp add: distinct_removes_middle3 insert_absorb) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1060 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1061 |
by (simp add: last_elem_out) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1062 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1063 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1064 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1065 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1066 |
lemma distinct_once_enough: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1067 |
shows "rdistinct (rs @ rsa) {} = rdistinct (rdistinct rs {} @ rsa) {}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1068 |
apply(subgoal_tac "distinct (rdistinct rs {})") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1069 |
apply(subgoal_tac |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1070 |
" rdistinct (rdistinct rs {} @ rsa) {} = rdistinct rs {} @ (rdistinct rsa (set rs))") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1071 |
apply(simp only:) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1072 |
using rdistinct_concat_general apply blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1073 |
apply (simp add: distinct_rdistinct_append rdistinct_set_equality1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1074 |
by (simp add: rdistinct_does_the_job) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1075 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1076 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1077 |
lemma simp_flatten: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1078 |
shows "rsimp (RALTS ((RALTS rsa) # rsb)) = rsimp (RALTS (rsa @ rsb))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1079 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1080 |
apply(subst flatten_rsimpalts) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1081 |
apply(simp add: flts_append) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1082 |
by (metis Diff_empty distinct_once_enough flts_append nonalt0_fltseq nonalt_flts_rd qqq1 rdistinct_set_equality1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1083 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1084 |
lemma basic_rsimp_SEQ_property1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1085 |
shows "rsimp_SEQ RONE r = r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1086 |
by (simp add: idiot) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1087 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1088 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1089 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1090 |
lemma basic_rsimp_SEQ_property3: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1091 |
shows "rsimp_SEQ r RZERO = RZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1092 |
using rsimp_SEQ.elims by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1093 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1094 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1095 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1096 |
fun vsuf :: "char list \<Rightarrow> rrexp \<Rightarrow> char list list" where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1097 |
"vsuf [] _ = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1098 |
|"vsuf (c#cs) r1 = (if (rnullable r1) then (vsuf cs (rder c r1)) @ [c # cs] |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1099 |
else (vsuf cs (rder c r1)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1100 |
) " |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1101 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1102 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1103 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1104 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1105 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1106 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1107 |
fun star_update :: "char \<Rightarrow> rrexp \<Rightarrow> char list list \<Rightarrow> char list list" where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1108 |
"star_update c r [] = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1109 |
|"star_update c r (s # Ss) = (if (rnullable (rders r s)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1110 |
then (s@[c]) # [c] # (star_update c r Ss) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1111 |
else (s@[c]) # (star_update c r Ss) )" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1112 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1113 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1114 |
fun star_updates :: "char list \<Rightarrow> rrexp \<Rightarrow> char list list \<Rightarrow> char list list" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1115 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1116 |
"star_updates [] r Ss = Ss" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1117 |
| "star_updates (c # cs) r Ss = star_updates cs r (star_update c r Ss)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1118 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1119 |
lemma stupdates_append: shows |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1120 |
"star_updates (s @ [c]) r Ss = star_update c r (star_updates s r Ss)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1121 |
apply(induct s arbitrary: Ss) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1122 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1123 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1124 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1125 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1126 |
lemma flts_removes0: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1127 |
shows " rflts (rs @ [RZERO]) = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1128 |
rflts rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1129 |
apply(induct rs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1130 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1131 |
by (metis append_Cons rflts.simps(2) rflts.simps(3) rflts_def_idiot) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1132 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1133 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1134 |
lemma rflts_spills_last: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1135 |
shows "rflts (rs1 @ [RALTS rs]) = rflts rs1 @ rs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1136 |
apply (induct rs1 rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1137 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1138 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1139 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1140 |
lemma flts_keeps1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1141 |
shows "rflts (rs @ [RONE]) = rflts rs @ [RONE]" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1142 |
apply (induct rs rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1143 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1144 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1145 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1146 |
lemma flts_keeps_others: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1147 |
shows "\<lbrakk>a \<noteq> RZERO; \<nexists>rs1. a = RALTS rs1\<rbrakk> \<Longrightarrow>rflts (rs @ [a]) = rflts rs @ [a]" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1148 |
apply(induct rs rule: rflts.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1149 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1150 |
by (meson k0b nonalt.elims(3)) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1151 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1152 |
lemma spilled_alts_contained: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1153 |
shows "\<lbrakk>a = RALTS rs ; a \<in> set rs1\<rbrakk> \<Longrightarrow> \<forall>r \<in> set rs. r \<in> set (rflts rs1)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1154 |
apply(induct rs1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1155 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1156 |
apply(case_tac "a = aa") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1157 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1158 |
apply(subgoal_tac " a \<in> set rs1") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1159 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1160 |
apply (meson set_ConsD) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1161 |
apply(case_tac aa) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1162 |
using rflts.simps(2) apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1163 |
apply fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1164 |
apply fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1165 |
apply fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1166 |
apply fastforce |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1167 |
apply fastforce |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1168 |
by simp |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1169 |
|
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1170 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1171 |
lemma distinct_removes_duplicate_flts: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1172 |
shows " a \<in> set rsa |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1173 |
\<Longrightarrow> rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1174 |
rdistinct (rflts (map rsimp rsa)) {}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1175 |
apply(subgoal_tac "rsimp a \<in> set (map rsimp rsa)") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1176 |
prefer 2 |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1177 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1178 |
apply(induct "rsimp a") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1179 |
apply simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1180 |
using flts_removes0 apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1181 |
apply(subgoal_tac " rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1182 |
rdistinct (rflts (map rsimp rsa @ [RONE])) {}") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1183 |
apply (simp only:) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1184 |
apply(subst flts_keeps1) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1185 |
apply (metis distinct_removes_last(1) flts_append in_set_conv_decomp rflts.simps(4)) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1186 |
apply presburger |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1187 |
apply(subgoal_tac " rdistinct (rflts (map rsimp rsa @ [rsimp a])) {} = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1188 |
rdistinct ((rflts (map rsimp rsa)) @ [RCHAR x]) {}") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1189 |
apply (simp only:) |
563
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1190 |
prefer 2 |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1191 |
apply (metis flts_append rflts.simps(1) rflts.simps(5)) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1192 |
apply (metis distinct_removes_last(1) rflts_def_idiot2 rrexp.distinct(25) rrexp.distinct(3)) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1193 |
apply (metis distinct_removes_last(1) flts_append rflts.simps(1) rflts.simps(6) rflts_def_idiot2 rrexp.distinct(31) rrexp.distinct(5)) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1194 |
apply (metis distinct_removes_list rflts_spills_last spilled_alts_contained) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1195 |
apply (metis distinct_removes_last(1) flts_append good.simps(1) good.simps(44) rflts.simps(1) rflts.simps(7) rflts_def_idiot2 rrexp.distinct(37)) |
c92a41d9c4da
updated paper and theories to include n-times
Christian Urban <christian.urban@kcl.ac.uk>
parents:
496
diff
changeset
|
1196 |
by (metis distinct_removes_last(1) flts_append rflts.simps(1) rflts.simps(8) rflts_def_idiot2 rrexp.distinct(11) rrexp.distinct(39)) |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1197 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1198 |
(*some basic facts about rsimp*) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1199 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1200 |
unused_thms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1201 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1202 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1203 |
end |