author | Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at> |
Fri, 21 Dec 2018 15:30:24 +0100 | |
changeset 291 | 93db7414931d |
parent 290 | 6e1c03614d36 |
child 292 | 293e9c6f22e1 |
permissions | -rwxr-xr-x |
173
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
1 |
(* Title: thys/Abacus.thy |
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
2 |
Author: Jian Xu, Xingyuan Zhang, and Christian Urban |
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
3 |
*) |
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
4 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
5 |
chapter {* Abacus Machines *} |
173
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
6 |
|
163
67063c5365e1
changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
115
diff
changeset
|
7 |
theory Abacus |
173
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
8 |
imports Turing_Hoare Abacus_Mopup |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
begin |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
|
111
dfc629cd11de
made uncomputable compatible with abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
11 |
declare replicate_Suc[simp add] |
dfc629cd11de
made uncomputable compatible with abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
12 |
|
165
582916f289ea
took out all deadcode from abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
13 |
(* Abacus instructions *) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
datatype abc_inst = |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
Inc nat |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
| Dec nat nat |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
18 |
| Goto nat |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
type_synonym abc_prog = "abc_inst list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
21 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
type_synonym abc_state = nat |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
24 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
The memory of Abacus machine is defined as a list of contents, with |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
every units addressed by index into the list. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
type_synonym abc_lm = "nat list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
Fetching contents out of memory. Units not represented by list elements are considered |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
as having content @{text "0"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
fun abc_lm_v :: "abc_lm \<Rightarrow> nat \<Rightarrow> nat" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
"abc_lm_v lm n = (if (n < length lm) then (lm!n) else 0)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
Set the content of memory unit @{text "n"} to value @{text "v"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
@{text "am"} is the Abacus memory before setting. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
If address @{text "n"} is outside to scope of @{text "am"}, @{text "am"} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
is extended so that @{text "n"} becomes in scope. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
fun abc_lm_s :: "abc_lm \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> abc_lm" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
"abc_lm_s am n v = (if (n < length am) then (am[n:=v]) else |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
am@ (replicate (n - length am) 0) @ [v])" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
The configuration of Abaucs machines consists of its current state and its |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
current memory: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
type_synonym abc_conf = "abc_state \<times> abc_lm" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
Fetch instruction out of Abacus program: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
fun abc_fetch :: "nat \<Rightarrow> abc_prog \<Rightarrow> abc_inst option" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
"abc_fetch s p = (if (s < length p) then Some (p ! s) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
65 |
else None)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
Single step execution of Abacus machine. If no instruction is feteched, |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
configuration does not change. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
fun abc_step_l :: "abc_conf \<Rightarrow> abc_inst option \<Rightarrow> abc_conf" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
"abc_step_l (s, lm) a = (case a of |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
74 |
None \<Rightarrow> (s, lm) | |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
75 |
Some (Inc n) \<Rightarrow> (let nv = abc_lm_v lm n in |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
76 |
(s + 1, abc_lm_s lm n (nv + 1))) | |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
77 |
Some (Dec n e) \<Rightarrow> (let nv = abc_lm_v lm n in |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
78 |
if (nv = 0) then (e, abc_lm_s lm n 0) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
79 |
else (s + 1, abc_lm_s lm n (nv - 1))) | |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
80 |
Some (Goto n) \<Rightarrow> (n, lm) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
82 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
83 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
84 |
Multi-step execution of Abacus machine. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
fun abc_steps_l :: "abc_conf \<Rightarrow> abc_prog \<Rightarrow> nat \<Rightarrow> abc_conf" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
88 |
"abc_steps_l (s, lm) p 0 = (s, lm)" | |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
"abc_steps_l (s, lm) p (Suc n) = |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
abc_steps_l (abc_step_l (s, lm) (abc_fetch s p)) p n" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
section {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
Compiling Abacus machines into Truing machines |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
94 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
95 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
96 |
subsection {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
97 |
Compiling functions |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
98 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
99 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
100 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
101 |
@{text "findnth n"} returns the TM which locates the represention of |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
102 |
memory cell @{text "n"} on the tape and changes representation of zero |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
103 |
on the way. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
104 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
105 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
106 |
fun findnth :: "nat \<Rightarrow> instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
107 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
108 |
"findnth 0 = []" | |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
109 |
"findnth (Suc n) = (findnth n @ [(W1, 2 * n + 1), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
110 |
(R, 2 * n + 2), (R, 2 * n + 3), (R, 2 * n + 2)])" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
111 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
@{text "tinc_b"} returns the TM which increments the representation |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
of the memory cell under rw-head by one and move the representation |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
of cells afterwards to the right accordingly. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
117 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
definition tinc_b :: "instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
"tinc_b \<equiv> [(W1, 1), (R, 2), (W1, 3), (R, 2), (W1, 3), (R, 4), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
(L, 7), (W0, 5), (R, 6), (W0, 5), (W1, 3), (R, 6), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
(L, 8), (L, 7), (R, 9), (L, 7), (R, 10), (W0, 9)]" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
124 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
@{text "tinc ss n"} returns the TM which simulates the execution of |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
Abacus instruction @{text "Inc n"}, assuming that TM is located at |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
location @{text "ss"} in the final TM complied from the whole |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
128 |
Abacus program. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
129 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
130 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
131 |
fun tinc :: "nat \<Rightarrow> nat \<Rightarrow> instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
132 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
"tinc ss n = shift (findnth n @ shift tinc_b (2 * n)) (ss - 1)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
134 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
135 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
136 |
@{text "tinc_b"} returns the TM which decrements the representation |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
137 |
of the memory cell under rw-head by one and move the representation |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
138 |
of cells afterwards to the left accordingly. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
139 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
140 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
141 |
definition tdec_b :: "instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
142 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
"tdec_b \<equiv> [(W1, 1), (R, 2), (L, 14), (R, 3), (L, 4), (R, 3), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
144 |
(R, 5), (W0, 4), (R, 6), (W0, 5), (L, 7), (L, 8), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
145 |
(L, 11), (W0, 7), (W1, 8), (R, 9), (L, 10), (R, 9), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
(R, 5), (W0, 10), (L, 12), (L, 11), (R, 13), (L, 11), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
(R, 17), (W0, 13), (L, 15), (L, 14), (R, 16), (L, 14), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
148 |
(R, 0), (W0, 16)]" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
149 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
150 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
151 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
@{text "tdec ss n label"} returns the TM which simulates the execution of |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
Abacus instruction @{text "Dec n label"}, assuming that TM is located at |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
location @{text "ss"} in the final TM complied from the whole |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
155 |
Abacus program. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
156 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
157 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
fun tdec :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
where |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
160 |
"tdec ss n e = shift (findnth n) (ss - 1) @ adjust (shift (shift tdec_b (2 * n)) (ss - 1)) e" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
@{text "tgoto f(label)"} returns the TM simulating the execution of Abacus instruction |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
164 |
@{text "Goto label"}, where @{text "f(label)"} is the corresponding location of |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
165 |
@{text "label"} in the final TM compiled from the overall Abacus program. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
168 |
fun tgoto :: "nat \<Rightarrow> instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
169 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
"tgoto n = [(Nop, n), (Nop, n)]" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
171 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
172 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
173 |
The layout of the final TM compiled from an Abacus program is represented |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
174 |
as a list of natural numbers, where the list element at index @{text "n"} represents the |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
175 |
starting state of the TM simulating the execution of @{text "n"}-th instruction |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
in the Abacus program. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
type_synonym layout = "nat list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
180 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
@{text "length_of i"} is the length of the |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
TM simulating the Abacus instruction @{text "i"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
184 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
185 |
fun length_of :: "abc_inst \<Rightarrow> nat" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
186 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
187 |
"length_of i = (case i of |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
188 |
Inc n \<Rightarrow> 2 * n + 9 | |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
189 |
Dec n e \<Rightarrow> 2 * n + 16 | |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
190 |
Goto n \<Rightarrow> 1)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
192 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
@{text "layout_of ap"} returns the layout of Abacus program @{text "ap"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
fun layout_of :: "abc_prog \<Rightarrow> layout" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
where "layout_of ap = map length_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
197 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
198 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
@{text "start_of layout n"} looks out the starting state of @{text "n"}-th |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
TM in the finall TM. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
203 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
204 |
fun start_of :: "nat list \<Rightarrow> nat \<Rightarrow> nat" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
205 |
where |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
206 |
"start_of ly x = (Suc (sum_list (take x ly))) " |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
209 |
@{text "ci lo ss i"} complies Abacus instruction @{text "i"} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
210 |
assuming the TM of @{text "i"} starts from state @{text "ss"} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
211 |
within the overal layout @{text "lo"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
213 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
fun ci :: "layout \<Rightarrow> nat \<Rightarrow> abc_inst \<Rightarrow> instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
"ci ly ss (Inc n) = tinc ss n" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
217 |
| "ci ly ss (Dec n e) = tdec ss n (start_of ly e)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
218 |
| "ci ly ss (Goto n) = tgoto (start_of ly n)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
219 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
220 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
221 |
@{text "tpairs_of ap"} transfroms Abacus program @{text "ap"} pairing |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
222 |
every instruction with its starting state. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
223 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
224 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
225 |
fun tpairs_of :: "abc_prog \<Rightarrow> (nat \<times> abc_inst) list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
226 |
where "tpairs_of ap = (zip (map (start_of (layout_of ap)) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
227 |
[0..<(length ap)]) ap)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
228 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
229 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
230 |
@{text "tms_of ap"} returns the list of TMs, where every one of them simulates |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
231 |
the corresponding Abacus intruction in @{text "ap"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
232 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
233 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
234 |
fun tms_of :: "abc_prog \<Rightarrow> (instr list) list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
where "tms_of ap = map (\<lambda> (n, tm). ci (layout_of ap) n tm) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
236 |
(tpairs_of ap)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
237 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
238 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
239 |
@{text "tm_of ap"} returns the final TM machine compiled from Abacus program @{text "ap"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
240 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
241 |
fun tm_of :: "abc_prog \<Rightarrow> instr list" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
242 |
where "tm_of ap = concat (tms_of ap)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
243 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
244 |
lemma length_findnth: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
245 |
"length (findnth n) = 4 * n" |
165
582916f289ea
took out all deadcode from abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
246 |
by (induct n, auto) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
247 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
248 |
lemma ci_length : "length (ci ns n ai) div 2 = length_of ai" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
249 |
apply(auto simp: ci.simps tinc_b_def tdec_b_def length_findnth |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
250 |
split: abc_inst.splits simp del: adjust.simps) |
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
251 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
252 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
253 |
|
165
582916f289ea
took out all deadcode from abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
254 |
subsection {* Representation of Abacus memory by TM tapes *} |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
255 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
256 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
257 |
@{text "crsp acf tcf"} meams the abacus configuration @{text "acf"} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
258 |
is corretly represented by the TM configuration @{text "tcf"}. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
259 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
260 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
261 |
fun crsp :: "layout \<Rightarrow> abc_conf \<Rightarrow> config \<Rightarrow> cell list \<Rightarrow> bool" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
262 |
where |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
263 |
"crsp ly (as, lm) (s, l, r) inres = |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
264 |
(s = start_of ly as \<and> (\<exists> x. r = <lm> @ Bk\<up>x) \<and> |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
265 |
l = Bk # Bk # inres)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
266 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
267 |
declare crsp.simps[simp del] |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
269 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
270 |
The type of invarints expressing correspondence between |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
271 |
Abacus configuration and TM configuration. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
272 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
273 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
274 |
type_synonym inc_inv_t = "abc_conf \<Rightarrow> config \<Rightarrow> cell list \<Rightarrow> bool" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
275 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
276 |
declare tms_of.simps[simp del] tm_of.simps[simp del] |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
277 |
layout_of.simps[simp del] abc_fetch.simps [simp del] |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
278 |
tpairs_of.simps[simp del] start_of.simps[simp del] |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
279 |
ci.simps [simp del] length_of.simps[simp del] |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
280 |
layout_of.simps[simp del] |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
281 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
282 |
text {* |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
283 |
The lemmas in this section lead to the correctness of |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
284 |
the compilation of @{text "Inc n"} instruction. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
285 |
*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
286 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
287 |
declare abc_step_l.simps[simp del] abc_steps_l.simps[simp del] |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
288 |
lemma start_of_nonzero[simp]: "start_of ly as > 0" "(start_of ly as = 0) = False" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
289 |
apply(auto simp: start_of.simps) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
290 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
291 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
292 |
lemma abc_steps_l_0: "abc_steps_l ac ap 0 = ac" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
293 |
by(case_tac ac, simp add: abc_steps_l.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
294 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
295 |
lemma abc_step_red: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
296 |
"abc_steps_l (as, am) ap stp = (bs, bm) \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
297 |
abc_steps_l (as, am) ap (Suc stp) = abc_step_l (bs, bm) (abc_fetch bs ap) " |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
298 |
proof(induct stp arbitrary: as am bs bm) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
299 |
case 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
300 |
thus "?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
301 |
by(simp add: abc_steps_l.simps abc_steps_l_0) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
302 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
303 |
case (Suc stp as am bs bm) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
304 |
have ind: "\<And>as am bs bm. abc_steps_l (as, am) ap stp = (bs, bm) \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
305 |
abc_steps_l (as, am) ap (Suc stp) = abc_step_l (bs, bm) (abc_fetch bs ap)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
306 |
by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
307 |
have h:" abc_steps_l (as, am) ap (Suc stp) = (bs, bm)" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
308 |
obtain as' am' where g: "abc_step_l (as, am) (abc_fetch as ap) = (as', am')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
309 |
by(case_tac "abc_step_l (as, am) (abc_fetch as ap)", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
310 |
then have "abc_steps_l (as', am') ap (Suc stp) = abc_step_l (bs, bm) (abc_fetch bs ap)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
311 |
using h |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
312 |
by(rule_tac ind, simp add: abc_steps_l.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
313 |
thus "?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
314 |
using g |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
315 |
by(simp add: abc_steps_l.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
316 |
qed |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
317 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
318 |
lemma tm_shift_fetch: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
319 |
"\<lbrakk>fetch A s b = (ac, ns); ns \<noteq> 0 \<rbrakk> |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
320 |
\<Longrightarrow> fetch (shift A off) s b = (ac, ns + off)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
321 |
apply(case_tac b) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
322 |
apply(case_tac [!] s, auto simp: fetch.simps shift.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
323 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
324 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
325 |
lemma tm_shift_eq_step: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
326 |
assumes exec: "step (s, l, r) (A, 0) = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
327 |
and notfinal: "s' \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
328 |
shows "step (s + off, l, r) (shift A off, off) = (s' + off, l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
329 |
using assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
330 |
apply(simp add: step.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
331 |
apply(case_tac "fetch A s (read r)", auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
332 |
apply(drule_tac [!] off = off in tm_shift_fetch, simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
333 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
334 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
335 |
declare step.simps[simp del] steps.simps[simp del] shift.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
336 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
337 |
lemma tm_shift_eq_steps: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
338 |
assumes exec: "steps (s, l, r) (A, 0) stp = (s', l', r')" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
339 |
and notfinal: "s' \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
shows "steps (s + off, l, r) (shift A off, off) stp = (s' + off, l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
341 |
using exec notfinal |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
342 |
proof(induct stp arbitrary: s' l' r', simp add: steps.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
343 |
fix stp s' l' r' |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
344 |
assume ind: "\<And>s' l' r'. \<lbrakk>steps (s, l, r) (A, 0) stp = (s', l', r'); s' \<noteq> 0\<rbrakk> |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
345 |
\<Longrightarrow> steps (s + off, l, r) (shift A off, off) stp = (s' + off, l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
346 |
and h: " steps (s, l, r) (A, 0) (Suc stp) = (s', l', r')" "s' \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
347 |
obtain s1 l1 r1 where g: "steps (s, l, r) (A, 0) stp = (s1, l1, r1)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
348 |
apply(case_tac "steps (s, l, r) (A, 0) stp") by blast |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
349 |
moreover then have "s1 \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
using h |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
351 |
apply(simp add: step_red) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
352 |
apply(case_tac "0 < s1", auto) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
353 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
354 |
ultimately have "steps (s + off, l, r) (shift A off, off) stp = |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
355 |
(s1 + off, l1, r1)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
356 |
apply(rule_tac ind, simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
357 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
358 |
thus "steps (s + off, l, r) (shift A off, off) (Suc stp) = (s' + off, l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
359 |
using h g assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
360 |
apply(simp add: step_red) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
361 |
apply(rule_tac tm_shift_eq_step, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
362 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
363 |
qed |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
364 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
365 |
lemma startof_ge1[simp]: "Suc 0 \<le> start_of ly as" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
366 |
apply(simp add: start_of.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
367 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
368 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
369 |
lemma start_of_Suc1: "\<lbrakk>ly = layout_of ap; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
370 |
abc_fetch as ap = Some (Inc n)\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
371 |
\<Longrightarrow> start_of ly (Suc as) = start_of ly as + 2 * n + 9" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
372 |
apply(auto simp: start_of.simps layout_of.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
373 |
length_of.simps abc_fetch.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
374 |
take_Suc_conv_app_nth split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
375 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
376 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
377 |
lemma start_of_Suc2: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
378 |
"\<lbrakk>ly = layout_of ap; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
379 |
abc_fetch as ap = Some (Dec n e)\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
380 |
start_of ly (Suc as) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
381 |
start_of ly as + 2 * n + 16" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
382 |
apply(auto simp: start_of.simps layout_of.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
383 |
length_of.simps abc_fetch.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
384 |
take_Suc_conv_app_nth split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
385 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
386 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
387 |
lemma start_of_Suc3: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
388 |
"\<lbrakk>ly = layout_of ap; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
389 |
abc_fetch as ap = Some (Goto n)\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
390 |
start_of ly (Suc as) = start_of ly as + 1" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
391 |
apply(auto simp: start_of.simps layout_of.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
392 |
length_of.simps abc_fetch.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
393 |
take_Suc_conv_app_nth split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
394 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
395 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
396 |
lemma length_ci_inc: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
397 |
"length (ci ly ss (Inc n)) = 4*n + 18" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
398 |
apply(auto simp: ci.simps length_findnth tinc_b_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
399 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
400 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
401 |
lemma length_ci_dec: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
402 |
"length (ci ly ss (Dec n e)) = 4*n + 32" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
403 |
apply(auto simp: ci.simps length_findnth tdec_b_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
404 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
405 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
406 |
lemma length_ci_goto: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
407 |
"length (ci ly ss (Goto n )) = 2" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
408 |
apply(auto simp: ci.simps length_findnth tdec_b_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
409 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
410 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
411 |
lemma take_Suc_last[elim]: "Suc as \<le> length xs \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
412 |
take (Suc as) xs = take as xs @ [xs ! as]" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
413 |
apply(induct xs arbitrary: as, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
414 |
apply(case_tac as, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
415 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
416 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
417 |
lemma concat_suc: "Suc as \<le> length xs \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
418 |
concat (take (Suc as) xs) = concat (take as xs) @ xs! as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
419 |
apply(subgoal_tac "take (Suc as) xs = take as xs @ [xs ! as]", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
420 |
by auto |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
421 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
422 |
lemma concat_drop_suc_iff: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
423 |
"Suc n < length tps \<Longrightarrow> concat (drop (Suc n) tps) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
424 |
tps ! Suc n @ concat (drop (Suc (Suc n)) tps)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
425 |
apply(induct tps arbitrary: n, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
426 |
apply(case_tac tps, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
427 |
apply(case_tac n, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
428 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
429 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
430 |
declare append_assoc[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
431 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
432 |
lemma tm_append: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
433 |
"\<lbrakk>n < length tps; tp = tps ! n\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
434 |
\<exists> tp1 tp2. concat tps = tp1 @ tp @ tp2 \<and> tp1 = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
435 |
concat (take n tps) \<and> tp2 = concat (drop (Suc n) tps)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
436 |
apply(rule_tac x = "concat (take n tps)" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
437 |
apply(rule_tac x = "concat (drop (Suc n) tps)" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
438 |
apply(auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
439 |
apply(induct n, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
440 |
apply(case_tac tps, simp, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
441 |
apply(subgoal_tac "concat (take n tps) @ (tps ! n) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
442 |
concat (take (Suc n) tps)") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
443 |
apply(simp only: append_assoc[THEN sym], simp only: append_assoc) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
444 |
apply(subgoal_tac " concat (drop (Suc n) tps) = tps ! Suc n @ |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
445 |
concat (drop (Suc (Suc n)) tps)") |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
446 |
apply (metis append_take_drop_id concat_append) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
447 |
apply(rule concat_drop_suc_iff,force) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
448 |
by (simp add: concat_suc) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
449 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
450 |
declare append_assoc[simp] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
451 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
452 |
lemma length_tms_of[simp]: "length (tms_of aprog) = length aprog" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
453 |
apply(auto simp: tms_of.simps tpairs_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
454 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
455 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
456 |
lemma ci_nth: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
457 |
"\<lbrakk>ly = layout_of aprog; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
458 |
abc_fetch as aprog = Some ins\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
459 |
\<Longrightarrow> ci ly (start_of ly as) ins = tms_of aprog ! as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
460 |
apply(simp add: tms_of.simps tpairs_of.simps |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
461 |
abc_fetch.simps del: map_append split: if_splits) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
462 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
463 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
464 |
lemma t_split:"\<lbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
465 |
ly = layout_of aprog; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
466 |
abc_fetch as aprog = Some ins\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
467 |
\<Longrightarrow> \<exists> tp1 tp2. concat (tms_of aprog) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
468 |
tp1 @ (ci ly (start_of ly as) ins) @ tp2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
469 |
\<and> tp1 = concat (take as (tms_of aprog)) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
470 |
tp2 = concat (drop (Suc as) (tms_of aprog))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
471 |
apply(insert tm_append[of "as" "tms_of aprog" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
472 |
"ci ly (start_of ly as) ins"], simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
473 |
apply(subgoal_tac "ci ly (start_of ly as) ins = (tms_of aprog) ! as") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
474 |
apply(subgoal_tac "length (tms_of aprog) = length aprog") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
475 |
apply(simp add: abc_fetch.simps split: if_splits, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
476 |
apply(rule_tac ci_nth, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
477 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
478 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
479 |
lemma div_apart: "\<lbrakk>x mod (2::nat) = 0; y mod 2 = 0\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
480 |
\<Longrightarrow> (x + y) div 2 = x div 2 + y div 2" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
481 |
by(auto) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
482 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
483 |
lemma length_layout_of[simp]: "length (layout_of aprog) = length aprog" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
484 |
by(auto simp: layout_of.simps) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
485 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
486 |
lemma length_tms_of_elem_even[intro]: "n < length ap \<Longrightarrow> length (tms_of ap ! n) mod 2 = 0" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
487 |
apply(cases "ap ! n") |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
488 |
by (auto simp: tms_of.simps tpairs_of.simps ci.simps length_findnth tinc_b_def tdec_b_def) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
489 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
490 |
lemma compile_mod2: "length (concat (take n (tms_of ap))) mod 2 = 0" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
491 |
proof(induct n) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
492 |
case 0 |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
493 |
then show ?case by (auto simp add: take_Suc_conv_app_nth) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
494 |
next |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
495 |
case (Suc n) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
496 |
hence "n < length (tms_of ap) \<Longrightarrow> is_even (length (concat (take (Suc n) (tms_of ap))))" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
497 |
unfolding take_Suc_conv_app_nth by fastforce |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
498 |
with Suc show ?case by(cases "n < length (tms_of ap)", auto) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
499 |
qed |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
500 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
501 |
lemma tpa_states: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
502 |
"\<lbrakk>tp = concat (take as (tms_of ap)); |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
503 |
as \<le> length ap\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
504 |
start_of (layout_of ap) as = Suc (length tp div 2)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
505 |
proof(induct as arbitrary: tp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
506 |
case 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
507 |
thus "?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
508 |
by(simp add: start_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
509 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
510 |
case (Suc as tp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
511 |
have ind: "\<And>tp. \<lbrakk>tp = concat (take as (tms_of ap)); as \<le> length ap\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
512 |
start_of (layout_of ap) as = Suc (length tp div 2)" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
513 |
have tp: "tp = concat (take (Suc as) (tms_of ap))" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
514 |
have le: "Suc as \<le> length ap" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
515 |
have a: "start_of (layout_of ap) as = Suc (length (concat (take as (tms_of ap))) div 2)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
516 |
using le |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
517 |
by(rule_tac ind, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
518 |
from a tp le show "?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
519 |
apply(simp add: start_of.simps take_Suc_conv_app_nth) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
520 |
apply(subgoal_tac "length (concat (take as (tms_of ap))) mod 2= 0") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
521 |
apply(subgoal_tac " length (tms_of ap ! as) mod 2 = 0") |
163
67063c5365e1
changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
115
diff
changeset
|
522 |
apply(simp add: Abacus.div_apart) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
523 |
apply(simp add: layout_of.simps ci_length tms_of.simps tpairs_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
524 |
apply(auto intro: compile_mod2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
525 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
526 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
527 |
|
173
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
528 |
declare fetch.simps[simp] |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
529 |
lemma append_append_fetch: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
530 |
"\<lbrakk>length tp1 mod 2 = 0; length tp mod 2 = 0; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
531 |
length tp1 div 2 < a \<and> a \<le> length tp1 div 2 + length tp div 2\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
532 |
\<Longrightarrow>fetch (tp1 @ tp @ tp2) a b = fetch tp (a - length tp1 div 2) b " |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
533 |
apply(subgoal_tac "\<exists> x. a = length tp1 div 2 + x", erule exE, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
534 |
apply(case_tac x, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
535 |
apply(subgoal_tac "length tp1 div 2 + Suc nat = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
536 |
Suc (length tp1 div 2 + nat)") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
537 |
apply(simp only: fetch.simps nth_of.simps, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
538 |
apply(case_tac b, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
539 |
apply(subgoal_tac "2 * (length tp1 div 2) = length tp1", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
540 |
apply(subgoal_tac "2 * nat < length tp", simp add: nth_append, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
541 |
apply(subgoal_tac "2 * (length tp1 div 2) = length tp1", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
542 |
apply(subgoal_tac "2 * nat < length tp", simp add: nth_append, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
543 |
apply(auto simp: nth_append) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
544 |
apply(rule_tac x = "a - length tp1 div 2" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
545 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
546 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
547 |
lemma step_eq_fetch': |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
548 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
549 |
and compile: "tp = tm_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
550 |
and fetch: "abc_fetch as ap = Some ins" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
551 |
and range1: "s \<ge> start_of ly as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
552 |
and range2: "s < start_of ly (Suc as)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
553 |
shows "fetch tp s b = fetch (ci ly (start_of ly as) ins) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
554 |
(Suc s - start_of ly as) b " |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
555 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
556 |
have "\<exists>tp1 tp2. concat (tms_of ap) = tp1 @ ci ly (start_of ly as) ins @ tp2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
557 |
tp1 = concat (take as (tms_of ap)) \<and> tp2 = concat (drop (Suc as) (tms_of ap))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
558 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
559 |
by(rule_tac t_split, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
560 |
then obtain tp1 tp2 where a: "concat (tms_of ap) = tp1 @ ci ly (start_of ly as) ins @ tp2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
561 |
tp1 = concat (take as (tms_of ap)) \<and> tp2 = concat (drop (Suc as) (tms_of ap))" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
562 |
then have b: "start_of (layout_of ap) as = Suc (length tp1 div 2)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
563 |
using fetch |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
564 |
by(rule_tac tpa_states, simp, simp add: abc_fetch.simps split: if_splits) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
565 |
have "fetch (tp1 @ (ci ly (start_of ly as) ins) @ tp2) s b = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
566 |
fetch (ci ly (start_of ly as) ins) (s - length tp1 div 2) b" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
567 |
proof(rule_tac append_append_fetch) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
568 |
show "length tp1 mod 2 = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
569 |
using a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
570 |
by(auto, rule_tac compile_mod2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
571 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
572 |
show "length (ci ly (start_of ly as) ins) mod 2 = 0" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
573 |
by(case_tac ins, auto simp: ci.simps length_findnth tinc_b_def tdec_b_def) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
574 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
575 |
show "length tp1 div 2 < s \<and> s \<le> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
576 |
length tp1 div 2 + length (ci ly (start_of ly as) ins) div 2" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
577 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
578 |
have "length (ci ly (start_of ly as) ins) div 2 = length_of ins" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
579 |
using ci_length by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
580 |
moreover have "start_of ly (Suc as) = start_of ly as + length_of ins" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
581 |
using fetch layout |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
582 |
apply(simp add: start_of.simps abc_fetch.simps List.take_Suc_conv_app_nth |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
583 |
split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
584 |
apply(simp add: layout_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
585 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
586 |
ultimately show "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
587 |
using b layout range1 range2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
588 |
apply(simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
589 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
590 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
591 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
592 |
thus "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
593 |
using b layout a compile |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
594 |
apply(simp add: tm_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
595 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
596 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
597 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
598 |
lemma step_eq_fetch: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
599 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
600 |
and compile: "tp = tm_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
601 |
and abc_fetch: "abc_fetch as ap = Some ins" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
602 |
and fetch: "fetch (ci ly (start_of ly as) ins) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
603 |
(Suc s - start_of ly as) b = (ac, ns)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
604 |
and notfinal: "ns \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
605 |
shows "fetch tp s b = (ac, ns)" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
606 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
607 |
have "s \<ge> start_of ly as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
608 |
proof(cases "s \<ge> start_of ly as") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
609 |
case True thus "?thesis" by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
610 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
611 |
case False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
612 |
have "\<not> start_of ly as \<le> s" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
613 |
then have "Suc s - start_of ly as = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
614 |
by arith |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
615 |
then have "fetch (ci ly (start_of ly as) ins) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
616 |
(Suc s - start_of ly as) b = (Nop, 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
617 |
by(simp add: fetch.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
618 |
with notfinal fetch show "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
619 |
by(simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
620 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
621 |
moreover have "s < start_of ly (Suc as)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
622 |
proof(cases "s < start_of ly (Suc as)") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
623 |
case True thus "?thesis" by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
624 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
625 |
case False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
626 |
have h: "\<not> s < start_of ly (Suc as)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
627 |
by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
628 |
then have "s > start_of ly as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
629 |
using abc_fetch layout |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
630 |
apply(simp add: start_of.simps abc_fetch.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
631 |
apply(simp add: List.take_Suc_conv_app_nth, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
632 |
apply(subgoal_tac "layout_of ap ! as > 0") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
633 |
apply arith |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
634 |
apply(simp add: layout_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
635 |
apply(case_tac "ap!as", auto simp: length_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
636 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
637 |
from this and h have "fetch (ci ly (start_of ly as) ins) (Suc s - start_of ly as) b = (Nop, 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
638 |
using abc_fetch layout |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
639 |
apply(case_tac b, simp_all add: Suc_diff_le) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
640 |
apply(case_tac [!] ins, simp_all add: start_of_Suc2 start_of_Suc1 start_of_Suc3) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
641 |
by (simp_all only: length_ci_inc length_ci_dec length_ci_goto, auto) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
642 |
from fetch and notfinal this show "?thesis"by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
643 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
644 |
ultimately show "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
645 |
using assms |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
646 |
by(drule_tac b= b and ins = ins in step_eq_fetch', auto) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
647 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
648 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
649 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
650 |
lemma step_eq_in: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
651 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
652 |
and compile: "tp = tm_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
653 |
and fetch: "abc_fetch as ap = Some ins" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
654 |
and exec: "step (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
655 |
= (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
656 |
and notfinal: "s' \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
657 |
shows "step (s, l, r) (tp, 0) = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
658 |
using assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
659 |
apply(simp add: step.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
660 |
apply(case_tac "fetch (ci (layout_of ap) (start_of (layout_of ap) as) ins) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
661 |
(Suc s - start_of (layout_of ap) as) (read r)", simp) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
662 |
using layout |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
663 |
apply(drule_tac s = s and b = "read r" and ac = a in step_eq_fetch, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
664 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
665 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
666 |
lemma steps_eq_in: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
667 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
668 |
and compile: "tp = tm_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
669 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
670 |
and fetch: "abc_fetch as ap = Some ins" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
671 |
and exec: "steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
672 |
= (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
673 |
and notfinal: "s' \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
674 |
shows "steps (s, l, r) (tp, 0) stp = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
675 |
using exec notfinal |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
676 |
proof(induct stp arbitrary: s' l' r', simp add: steps.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
677 |
fix stp s' l' r' |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
678 |
assume ind: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
679 |
"\<And>s' l' r'. \<lbrakk>steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp = (s', l', r'); s' \<noteq> 0\<rbrakk> |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
680 |
\<Longrightarrow> steps (s, l, r) (tp, 0) stp = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
681 |
and h: "steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) (Suc stp) = (s', l', r')" "s' \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
682 |
obtain s1 l1 r1 where g: "steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp = |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
683 |
(s1, l1, r1)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
684 |
apply(case_tac "steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp") by blast |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
685 |
moreover hence "s1 \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
686 |
using h |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
687 |
apply(simp add: step_red) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
688 |
apply(case_tac "0 < s1", simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
689 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
690 |
ultimately have "steps (s, l, r) (tp, 0) stp = (s1, l1, r1)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
691 |
apply(rule_tac ind, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
692 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
693 |
thus "steps (s, l, r) (tp, 0) (Suc stp) = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
694 |
using h g assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
695 |
apply(simp add: step_red) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
696 |
apply(rule_tac step_eq_in, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
697 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
698 |
qed |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
699 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
700 |
lemma tm_append_fetch_first: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
701 |
"\<lbrakk>fetch A s b = (ac, ns); ns \<noteq> 0\<rbrakk> \<Longrightarrow> |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
702 |
fetch (A @ B) s b = (ac, ns)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
703 |
apply(case_tac b) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
704 |
apply(case_tac [!] s, auto simp: fetch.simps nth_append split: if_splits) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
705 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
706 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
707 |
lemma tm_append_first_step_eq: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
708 |
assumes "step (s, l, r) (A, off) = (s', l', r')" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
709 |
and "s' \<noteq> 0" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
710 |
shows "step (s, l, r) (A @ B, off) = (s', l', r')" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
711 |
using assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
712 |
apply(simp add: step.simps) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
713 |
apply(case_tac "fetch A (s - off) (read r)") |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
714 |
apply(frule_tac B = B and b = "read r" in tm_append_fetch_first, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
715 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
716 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
717 |
lemma tm_append_first_steps_eq: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
718 |
assumes "steps (s, l, r) (A, off) stp = (s', l', r')" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
719 |
and "s' \<noteq> 0" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
720 |
shows "steps (s, l, r) (A @ B, off) stp = (s', l', r')" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
721 |
using assms |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
722 |
proof(induct stp arbitrary: s' l' r', simp add: steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
723 |
fix stp s' l' r' |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
724 |
assume ind: "\<And>s' l' r'. \<lbrakk>steps (s, l, r) (A, off) stp = (s', l', r'); s' \<noteq> 0\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
725 |
\<Longrightarrow> steps (s, l, r) (A @ B, off) stp = (s', l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
726 |
and h: "steps (s, l, r) (A, off) (Suc stp) = (s', l', r')" "s' \<noteq> 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
727 |
obtain sa la ra where a: "steps (s, l, r) (A, off) stp = (sa, la, ra)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
728 |
apply(case_tac "steps (s, l, r) (A, off) stp") by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
729 |
hence "steps (s, l, r) (A @ B, off) stp = (sa, la, ra) \<and> sa \<noteq> 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
730 |
using h ind[of sa la ra] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
731 |
apply(case_tac sa, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
732 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
733 |
thus "steps (s, l, r) (A @ B, off) (Suc stp) = (s', l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
734 |
using h a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
735 |
apply(simp add: step_red) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
736 |
apply(rule_tac tm_append_first_step_eq, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
737 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
738 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
739 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
740 |
lemma tm_append_second_fetch_eq: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
741 |
assumes |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
742 |
even: "length A mod 2 = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
743 |
and off: "off = length A div 2" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
744 |
and fetch: "fetch B s b = (ac, ns)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
745 |
and notfinal: "ns \<noteq> 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
746 |
shows "fetch (A @ shift B off) (s + off) b = (ac, ns + off)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
747 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
748 |
apply(case_tac b) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
749 |
apply(case_tac [!] s, auto simp: fetch.simps nth_append shift.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
750 |
split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
751 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
752 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
753 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
754 |
lemma tm_append_second_step_eq: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
755 |
assumes |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
756 |
exec: "step0 (s, l, r) B = (s', l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
757 |
and notfinal: "s' \<noteq> 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
758 |
and off: "off = length A div 2" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
759 |
and even: "length A mod 2 = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
760 |
shows "step0 (s + off, l, r) (A @ shift B off) = (s' + off, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
761 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
762 |
apply(simp add: step.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
763 |
apply(case_tac "fetch B s (read r)") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
764 |
apply(frule_tac tm_append_second_fetch_eq, simp_all, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
765 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
766 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
767 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
768 |
lemma tm_append_second_steps_eq: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
769 |
assumes |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
770 |
exec: "steps (s, l, r) (B, 0) stp = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
771 |
and notfinal: "s' \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
772 |
and off: "off = length A div 2" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
773 |
and even: "length A mod 2 = 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
774 |
shows "steps (s + off, l, r) (A @ shift B off, 0) stp = (s' + off, l', r')" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
775 |
using exec notfinal |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
776 |
proof(induct stp arbitrary: s' l' r') |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
777 |
case 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
778 |
thus "steps0 (s + off, l, r) (A @ shift B off) 0 = (s' + off, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
779 |
by(simp add: steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
780 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
781 |
case (Suc stp s' l' r') |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
782 |
have ind: "\<And>s' l' r'. \<lbrakk>steps0 (s, l, r) B stp = (s', l', r'); s' \<noteq> 0\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
783 |
steps0 (s + off, l, r) (A @ shift B off) stp = (s' + off, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
784 |
by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
785 |
have h: "steps0 (s, l, r) B (Suc stp) = (s', l', r')" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
786 |
have k: "s' \<noteq> 0" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
787 |
obtain s'' l'' r'' where a: "steps0 (s, l, r) B stp = (s'', l'', r'')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
788 |
by (metis prod_cases3) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
789 |
then have b: "s'' \<noteq> 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
790 |
using h k |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
791 |
by(rule_tac notI, auto simp: step_red) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
792 |
from a b have c: "steps0 (s + off, l, r) (A @ shift B off) stp = (s'' + off, l'', r'')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
793 |
by(erule_tac ind, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
794 |
from c b h a k assms show "?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
795 |
apply(simp add: step_red) by(rule tm_append_second_step_eq, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
796 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
797 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
798 |
lemma tm_append_second_fetch0_eq: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
799 |
assumes |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
800 |
even: "length A mod 2 = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
801 |
and off: "off = length A div 2" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
802 |
and fetch: "fetch B s b = (ac, 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
803 |
and notfinal: "s \<noteq> 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
804 |
shows "fetch (A @ shift B off) (s + off) b = (ac, 0)" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
805 |
using assms |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
806 |
apply(case_tac b) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
807 |
apply(case_tac [!] s, auto simp: fetch.simps nth_append shift.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
808 |
split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
809 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
810 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
811 |
lemma tm_append_second_halt_eq: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
812 |
assumes |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
813 |
exec: "steps (Suc 0, l, r) (B, 0) stp = (0, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
814 |
and wf_B: "tm_wf (B, 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
815 |
and off: "off = length A div 2" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
816 |
and even: "length A mod 2 = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
817 |
shows "steps (Suc off, l, r) (A @ shift B off, 0) stp = (0, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
818 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
819 |
have "\<exists>n. \<not> is_final (steps0 (1, l, r) B n) \<and> steps0 (1, l, r) B (Suc n) = (0, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
820 |
using exec by(rule_tac before_final, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
821 |
then obtain n where a: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
822 |
"\<not> is_final (steps0 (1, l, r) B n) \<and> steps0 (1, l, r) B (Suc n) = (0, l', r')" .. |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
823 |
obtain s'' l'' r'' where b: "steps0 (1, l, r) B n = (s'', l'', r'') \<and> s'' >0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
824 |
using a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
825 |
by(case_tac "steps0 (1, l, r) B n", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
826 |
have c: "steps (Suc 0 + off, l, r) (A @ shift B off, 0) n = (s'' + off, l'', r'')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
827 |
using a b assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
828 |
by(rule_tac tm_append_second_steps_eq, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
829 |
obtain ac where d: "fetch B s'' (read r'') = (ac, 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
830 |
using b a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
831 |
by(case_tac "fetch B s'' (read r'')", auto simp: step_red step.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
832 |
then have "fetch (A @ shift B off) (s'' + off) (read r'') = (ac, 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
833 |
using assms b |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
834 |
by(rule_tac tm_append_second_fetch0_eq, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
835 |
then have e: "steps (Suc 0 + off, l, r) (A @ shift B off, 0) (Suc n) = (0, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
836 |
using a b assms c d |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
837 |
by(simp add: step_red step.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
838 |
from a have "n < stp" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
839 |
using exec |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
840 |
proof(cases "n < stp") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
841 |
case True thus "?thesis" by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
842 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
843 |
case False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
844 |
have "\<not> n < stp" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
845 |
then obtain d where "n = stp + d" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
846 |
by (metis add.comm_neutral less_imp_add_positive nat_neq_iff) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
847 |
thus "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
848 |
using a e exec |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
849 |
by(simp add: steps_add) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
850 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
851 |
then obtain d where "stp = Suc n + d" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
852 |
by(metis add_Suc less_iff_Suc_add) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
853 |
thus "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
854 |
using e |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
855 |
by(simp only: steps_add, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
856 |
qed |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
857 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
858 |
lemma tm_append_steps: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
859 |
assumes |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
860 |
aexec: "steps (s, l, r) (A, 0) stpa = (Suc (length A div 2), la, ra)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
861 |
and bexec: "steps (Suc 0, la, ra) (B, 0) stpb = (sb, lb, rb)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
862 |
and notfinal: "sb \<noteq> 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
863 |
and off: "off = length A div 2" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
864 |
and even: "length A mod 2 = 0" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
865 |
shows "steps (s, l, r) (A @ shift B off, 0) (stpa + stpb) = (sb + off, lb, rb)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
866 |
proof - |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
867 |
have "steps (s, l, r) (A@shift B off, 0) stpa = (Suc (length A div 2), la, ra)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
868 |
apply(rule_tac tm_append_first_steps_eq) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
869 |
apply(auto simp: assms) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
870 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
871 |
moreover have "steps (1 + off, la, ra) (A @ shift B off, 0) stpb = (sb + off, lb, rb)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
872 |
apply(rule_tac tm_append_second_steps_eq) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
873 |
apply(auto simp: assms bexec) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
874 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
875 |
ultimately show "steps (s, l, r) (A @ shift B off, 0) (stpa + stpb) = (sb + off, lb, rb)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
876 |
apply(simp add: steps_add off) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
877 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
878 |
qed |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
879 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
880 |
subsection {* Crsp of Inc*} |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
881 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
882 |
fun at_begin_fst_bwtn :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
883 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
884 |
"at_begin_fst_bwtn (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
885 |
(\<exists> lm1 tn rn. lm1 = (lm @ 0\<up>tn) \<and> length lm1 = s \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
886 |
(if lm1 = [] then l = Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
887 |
else l = [Bk]@<rev lm1>@Bk#Bk#ires) \<and> r = Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
888 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
889 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
890 |
fun at_begin_fst_awtn :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
891 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
892 |
"at_begin_fst_awtn (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
893 |
(\<exists> lm1 tn rn. lm1 = (lm @ 0\<up>tn) \<and> length lm1 = s \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
894 |
(if lm1 = [] then l = Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
895 |
else l = [Bk]@<rev lm1>@Bk#Bk#ires) \<and> r = [Oc]@Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
896 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
897 |
fun at_begin_norm :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
898 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
899 |
"at_begin_norm (as, lm) (s, l, r) ires= |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
900 |
(\<exists> lm1 lm2 rn. lm = lm1 @ lm2 \<and> length lm1 = s \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
901 |
(if lm1 = [] then l = Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
902 |
else l = Bk # <rev lm1> @ Bk # Bk # ires ) \<and> r = <lm2>@Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
903 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
904 |
fun in_middle :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
905 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
906 |
"in_middle (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
907 |
(\<exists> lm1 lm2 tn m ml mr rn. lm @ 0\<up>tn = lm1 @ [m] @ lm2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
908 |
\<and> length lm1 = s \<and> m + 1 = ml + mr \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
909 |
ml \<noteq> 0 \<and> tn = s + 1 - length lm \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
910 |
(if lm1 = [] then l = Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
911 |
else l = Oc\<up>ml@[Bk]@<rev lm1>@ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
912 |
Bk # Bk # ires) \<and> (r = Oc\<up>mr @ [Bk] @ <lm2>@ Bk\<up>rn \<or> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
913 |
(lm2 = [] \<and> r = Oc\<up>mr)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
914 |
)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
915 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
916 |
fun inv_locate_a :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
917 |
where "inv_locate_a (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
918 |
(at_begin_norm (as, lm) (s, l, r) ires \<or> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
919 |
at_begin_fst_bwtn (as, lm) (s, l, r) ires \<or> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
920 |
at_begin_fst_awtn (as, lm) (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
921 |
)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
922 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
923 |
fun inv_locate_b :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
924 |
where "inv_locate_b (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
925 |
(in_middle (as, lm) (s, l, r)) ires " |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
926 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
927 |
fun inv_after_write :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
928 |
where "inv_after_write (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
929 |
(\<exists> rn m lm1 lm2. lm = lm1 @ m # lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
930 |
(if lm1 = [] then l = Oc\<up>m @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
931 |
else Oc # l = Oc\<up>Suc m@ Bk # <rev lm1> @ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
932 |
Bk # Bk # ires) \<and> r = [Oc] @ <lm2> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
933 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
934 |
fun inv_after_move :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
935 |
where "inv_after_move (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
936 |
(\<exists> rn m lm1 lm2. lm = lm1 @ m # lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
937 |
(if lm1 = [] then l = Oc\<up>Suc m @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
938 |
else l = Oc\<up>Suc m@ Bk # <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
939 |
r = <lm2> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
940 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
941 |
fun inv_after_clear :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
942 |
where "inv_after_clear (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
943 |
(\<exists> rn m lm1 lm2 r'. lm = lm1 @ m # lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
944 |
(if lm1 = [] then l = Oc\<up>Suc m @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
945 |
else l = Oc\<up>Suc m @ Bk # <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
946 |
r = Bk # r' \<and> Oc # r' = <lm2> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
947 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
948 |
fun inv_on_right_moving :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
949 |
where "inv_on_right_moving (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
950 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
951 |
ml + mr = m \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
952 |
(if lm1 = [] then l = Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
953 |
else l = Oc\<up>ml @ [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
954 |
((r = Oc\<up>mr @ [Bk] @ <lm2> @ Bk\<up>rn) \<or> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
955 |
(r = Oc\<up>mr \<and> lm2 = [])))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
956 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
957 |
fun inv_on_left_moving_norm :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
958 |
where "inv_on_left_moving_norm (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
959 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
960 |
ml + mr = Suc m \<and> mr > 0 \<and> (if lm1 = [] then l = Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
961 |
else l = Oc\<up>ml @ Bk # <rev lm1> @ Bk # Bk # ires) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
962 |
\<and> (r = Oc\<up>mr @ Bk # <lm2> @ Bk\<up>rn \<or> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
963 |
(lm2 = [] \<and> r = Oc\<up>mr)))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
964 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
965 |
fun inv_on_left_moving_in_middle_B:: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
966 |
where "inv_on_left_moving_in_middle_B (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
967 |
(\<exists> lm1 lm2 rn. lm = lm1 @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
968 |
(if lm1 = [] then l = Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
969 |
else l = <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
970 |
r = Bk # <lm2> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
971 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
972 |
fun inv_on_left_moving :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
973 |
where "inv_on_left_moving (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
974 |
(inv_on_left_moving_norm (as, lm) (s, l, r) ires \<or> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
975 |
inv_on_left_moving_in_middle_B (as, lm) (s, l, r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
976 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
977 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
978 |
fun inv_check_left_moving_on_leftmost :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
979 |
where "inv_check_left_moving_on_leftmost (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
980 |
(\<exists> rn. l = ires \<and> r = [Bk, Bk] @ <lm> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
981 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
982 |
fun inv_check_left_moving_in_middle :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
983 |
where "inv_check_left_moving_in_middle (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
984 |
(\<exists> lm1 lm2 r' rn. lm = lm1 @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
985 |
(Oc # l = <rev lm1> @ Bk # Bk # ires) \<and> r = Oc # Bk # r' \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
986 |
r' = <lm2> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
987 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
988 |
fun inv_check_left_moving :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
989 |
where "inv_check_left_moving (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
990 |
(inv_check_left_moving_on_leftmost (as, lm) (s, l, r) ires \<or> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
991 |
inv_check_left_moving_in_middle (as, lm) (s, l, r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
992 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
993 |
fun inv_after_left_moving :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
994 |
where "inv_after_left_moving (as, lm) (s, l, r) ires= |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
995 |
(\<exists> rn. l = Bk # ires \<and> r = Bk # <lm> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
996 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
997 |
fun inv_stop :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
998 |
where "inv_stop (as, lm) (s, l, r) ires= |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
999 |
(\<exists> rn. l = Bk # Bk # ires \<and> r = <lm> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1000 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1001 |
lemma halt_lemma2': |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1002 |
"\<lbrakk>wf LE; \<forall> n. ((\<not> P (f n) \<and> Q (f n)) \<longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1003 |
(Q (f (Suc n)) \<and> (f (Suc n), (f n)) \<in> LE)); Q (f 0)\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1004 |
\<Longrightarrow> \<exists> n. P (f n)" |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
1005 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1006 |
apply(intro exCI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1007 |
apply(subgoal_tac "\<forall> n. Q (f n)", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1008 |
apply(drule_tac f = f in wf_inv_image) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1009 |
apply(simp add: inv_image_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1010 |
apply(erule wf_induct, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1011 |
apply(erule_tac x = x in allE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1012 |
apply(erule_tac x = n in allE, erule_tac x = n in allE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1013 |
apply(erule_tac x = "Suc x" in allE, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1014 |
apply(rule_tac allI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1015 |
apply(induct_tac n, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1016 |
apply(erule_tac x = na in allE, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1017 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1018 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1019 |
lemma halt_lemma2'': |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1020 |
"\<lbrakk>P (f n); \<not> P (f (0::nat))\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1021 |
\<exists> n. (P (f n) \<and> (\<forall> i < n. \<not> P (f i)))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1022 |
apply(induct n rule: nat_less_induct, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1023 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1024 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1025 |
lemma halt_lemma2''': |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1026 |
"\<lbrakk>\<forall>n. \<not> P (f n) \<and> Q (f n) \<longrightarrow> Q (f (Suc n)) \<and> (f (Suc n), f n) \<in> LE; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1027 |
Q (f 0); \<forall>i<na. \<not> P (f i)\<rbrakk> \<Longrightarrow> Q (f na)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1028 |
apply(induct na, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1029 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1030 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1031 |
lemma halt_lemma2: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1032 |
"\<lbrakk>wf LE; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1033 |
Q (f 0); \<not> P (f 0); |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1034 |
\<forall> n. ((\<not> P (f n) \<and> Q (f n)) \<longrightarrow> (Q (f (Suc n)) \<and> (f (Suc n), (f n)) \<in> LE))\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1035 |
\<Longrightarrow> \<exists> n. P (f n) \<and> Q (f n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1036 |
apply(insert halt_lemma2' [of LE P f Q], simp, erule_tac exE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1037 |
apply(subgoal_tac "\<exists> n. (P (f n) \<and> (\<forall> i < n. \<not> P (f i)))") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1038 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1039 |
apply(rule_tac x = na in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1040 |
apply(rule halt_lemma2''', simp, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1041 |
apply(erule_tac halt_lemma2'', simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1042 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1043 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1044 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1045 |
fun findnth_inv :: "layout \<Rightarrow> nat \<Rightarrow> inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1046 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1047 |
"findnth_inv ly n (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1048 |
(if s = 0 then False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1049 |
else if s \<le> Suc (2*n) then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1050 |
if s mod 2 = 1 then inv_locate_a (as, lm) ((s - 1) div 2, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1051 |
else inv_locate_b (as, lm) ((s - 1) div 2, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1052 |
else False)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1053 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1054 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1055 |
fun findnth_state :: "config \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1056 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1057 |
"findnth_state (s, l, r) n = (Suc (2*n) - s)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1058 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1059 |
fun findnth_step :: "config \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1060 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1061 |
"findnth_step (s, l, r) n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1062 |
(if s mod 2 = 1 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1063 |
(if (r \<noteq> [] \<and> hd r = Oc) then 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1064 |
else 1) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1065 |
else length r)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1066 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1067 |
fun findnth_measure :: "config \<times> nat \<Rightarrow> nat \<times> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1068 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1069 |
"findnth_measure (c, n) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1070 |
(findnth_state c n, findnth_step c n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1071 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1072 |
definition lex_pair :: "((nat \<times> nat) \<times> nat \<times> nat) set" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1073 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1074 |
"lex_pair \<equiv> less_than <*lex*> less_than" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1075 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1076 |
definition findnth_LE :: "((config \<times> nat) \<times> (config \<times> nat)) set" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1077 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1078 |
"findnth_LE \<equiv> (inv_image lex_pair findnth_measure)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1079 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1080 |
lemma wf_findnth_LE: "wf findnth_LE" |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
1081 |
by(auto simp: findnth_LE_def lex_pair_def) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1082 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1083 |
declare findnth_inv.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1084 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1085 |
lemma x_is_2n_arith[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1086 |
"\<lbrakk>x < Suc (Suc (2 * n)); Suc x mod 2 = Suc 0; \<not> x < 2 * n\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1087 |
\<Longrightarrow> x = 2*n" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1088 |
by arith |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1089 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1090 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1091 |
lemma between_sucs:"x < Suc n \<Longrightarrow> \<not> x < n \<Longrightarrow> x = n" by auto |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1092 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1093 |
lemma fetch_findnth[simp]: |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1094 |
"\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 = Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Oc = (R, Suc a)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1095 |
"\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 \<noteq> Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Oc = (R, a)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1096 |
"\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 \<noteq> Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Bk = (R, Suc a)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1097 |
"\<lbrakk>0 < a; a < Suc (2 * n); a mod 2 = Suc 0\<rbrakk> \<Longrightarrow> fetch (findnth n) a Bk = (W1, a)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1098 |
by(cases a;induct n;force simp: length_findnth nth_append dest!:between_sucs)+ |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1099 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1100 |
declare at_begin_norm.simps[simp del] at_begin_fst_bwtn.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1101 |
at_begin_fst_awtn.simps[simp del] in_middle.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1102 |
abc_lm_s.simps[simp del] abc_lm_v.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1103 |
ci.simps[simp del] inv_after_move.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1104 |
inv_on_left_moving_norm.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1105 |
inv_on_left_moving_in_middle_B.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1106 |
inv_after_clear.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1107 |
inv_after_write.simps[simp del] inv_on_left_moving.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1108 |
inv_on_right_moving.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1109 |
inv_check_left_moving.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1110 |
inv_check_left_moving_in_middle.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1111 |
inv_check_left_moving_on_leftmost.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1112 |
inv_after_left_moving.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1113 |
inv_stop.simps[simp del] inv_locate_a.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1114 |
inv_locate_b.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1115 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1116 |
lemma replicate_once[intro]: "\<exists>rn. [Bk] = Bk \<up> rn" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1117 |
by (metis replicate.simps) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1118 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1119 |
lemma at_begin_norm_Bk[intro]: "at_begin_norm (as, am) (q, aaa, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1120 |
\<Longrightarrow> at_begin_norm (as, am) (q, aaa, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1121 |
apply(simp add: at_begin_norm.simps, erule_tac exE, erule_tac exE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1122 |
apply(rule_tac x = lm1 in exI, simp, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1123 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1124 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1125 |
lemma at_begin_fst_bwtn_Bk[intro]: "at_begin_fst_bwtn (as, am) (q, aaa, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1126 |
\<Longrightarrow> at_begin_fst_bwtn (as, am) (q, aaa, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1127 |
apply(simp only: at_begin_fst_bwtn.simps, erule_tac exE, erule_tac exE, erule_tac exE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1128 |
apply(rule_tac x = "am @ 0\<up>tn" in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1129 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1130 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1131 |
lemma at_begin_fst_awtn_Bk[intro]: "at_begin_fst_awtn (as, am) (q, aaa, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1132 |
\<Longrightarrow> at_begin_fst_awtn (as, am) (q, aaa, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1133 |
apply(auto simp: at_begin_fst_awtn.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1134 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1135 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1136 |
lemma inv_locate_a_Bk[intro]: "inv_locate_a (as, am) (q, aaa, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1137 |
\<Longrightarrow> inv_locate_a (as, am) (q, aaa, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1138 |
apply(simp only: inv_locate_a.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1139 |
apply(erule disj_forward) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1140 |
defer |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1141 |
apply(erule disj_forward, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1142 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1143 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1144 |
lemma locate_a_2_locate_a[simp]: "inv_locate_a (as, am) (q, aaa, Bk # xs) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1145 |
\<Longrightarrow> inv_locate_a (as, am) (q, aaa, Oc # xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1146 |
apply(simp only: inv_locate_a.simps at_begin_norm.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1147 |
at_begin_fst_bwtn.simps at_begin_fst_awtn.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1148 |
apply(erule_tac disjE, erule exE, erule exE, erule exE, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1149 |
rule disjI2, rule disjI2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1150 |
defer |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1151 |
apply(erule_tac disjE, erule exE, erule exE, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1152 |
erule exE, rule disjI2, rule disjI2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1153 |
prefer 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1154 |
apply(simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1155 |
proof- |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1156 |
fix lm1 tn rn |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1157 |
assume k: "lm1 = am @ 0\<up>tn \<and> length lm1 = q \<and> (if lm1 = [] then aaa = Bk # Bk # |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1158 |
ires else aaa = [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> Bk # xs = Bk\<up>rn" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1159 |
thus "\<exists>lm1 tn rn. lm1 = am @ 0 \<up> tn \<and> length lm1 = q \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1160 |
(if lm1 = [] then aaa = Bk # Bk # ires else aaa = [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> Oc # xs = [Oc] @ Bk \<up> rn" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1161 |
(is "\<exists>lm1 tn rn. ?P lm1 tn rn") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1162 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1163 |
from k have "?P lm1 tn (rn - 1)" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1164 |
by (auto simp: Cons_replicate_eq) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1165 |
thus ?thesis by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1166 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1167 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1168 |
fix lm1 lm2 rn |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1169 |
assume h1: "am = lm1 @ lm2 \<and> length lm1 = q \<and> (if lm1 = [] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1170 |
then aaa = Bk # Bk # ires else aaa = Bk # <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1171 |
Bk # xs = <lm2> @ Bk\<up>rn" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1172 |
from h1 have h2: "lm2 = []" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1173 |
apply(auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1174 |
apply(case_tac [!] lm2, simp_all add: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1175 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1176 |
from h1 and h2 show "\<exists>lm1 tn rn. lm1 = am @ 0\<up>tn \<and> length lm1 = q \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1177 |
(if lm1 = [] then aaa = Bk # Bk # ires else aaa = [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1178 |
Oc # xs = [Oc] @ Bk\<up>rn" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1179 |
(is "\<exists>lm1 tn rn. ?P lm1 tn rn") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1180 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1181 |
from h1 and h2 have "?P lm1 0 (rn - 1)" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1182 |
apply(auto simp:tape_of_nat_def) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1183 |
by(case_tac "rn::nat", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1184 |
thus ?thesis by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1185 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1186 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1187 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1188 |
lemma inv_locate_a[simp]: "inv_locate_a (as, am) (q, aaa, []) ires \<Longrightarrow> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1189 |
inv_locate_a (as, am) (q, aaa, [Oc]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1190 |
apply(insert locate_a_2_locate_a [of as am q aaa "[]"]) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1191 |
apply(subgoal_tac "inv_locate_a (as, am) (q, aaa, [Bk]) ires", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1192 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1193 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1194 |
(*inv: from locate_b to locate_b*) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1195 |
lemma inv_locate_b[simp]: "inv_locate_b (as, am) (q, aaa, Oc # xs) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1196 |
\<Longrightarrow> inv_locate_b (as, am) (q, Oc # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1197 |
apply(simp only: inv_locate_b.simps in_middle.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1198 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1199 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1200 |
rule_tac x = tn in exI, rule_tac x = m in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1201 |
apply(rule_tac x = "Suc ml" in exI, rule_tac x = "mr - 1" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1202 |
rule_tac x = rn in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1203 |
apply(case_tac mr, simp_all, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1204 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1205 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1206 |
lemma tape_nat[simp]: "<[x::nat]> = Oc\<up>(Suc x)" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1207 |
apply(simp add: tape_of_nat_def tape_of_list_def) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1208 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1209 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1210 |
lemma inv_locate[simp]: "\<lbrakk>inv_locate_b (as, am) (q, aaa, Bk # xs) ires; \<exists>n. xs = Bk\<up>n\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1211 |
\<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1212 |
apply(simp add: inv_locate_b.simps inv_locate_a.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1213 |
apply(rule_tac disjI2, rule_tac disjI1) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1214 |
apply(simp only: in_middle.simps at_begin_fst_bwtn.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1215 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1216 |
apply(rule_tac x = "lm1 @ [m]" in exI, rule_tac x = tn in exI, simp split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1217 |
apply(case_tac mr, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1218 |
apply(case_tac "length am", simp_all, case_tac tn, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1219 |
apply(case_tac lm2, simp_all add: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1220 |
apply(case_tac am, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1221 |
apply(case_tac n, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1222 |
apply(case_tac n, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1223 |
apply(case_tac mr, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1224 |
apply(case_tac lm2, simp_all add: tape_of_nl_cons split: if_splits, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1225 |
apply(case_tac [!] n, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1226 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1227 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1228 |
lemma repeat_Bk_no_Oc[simp]: "(Oc # r = Bk \<up> rn) = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1229 |
apply(case_tac rn, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1230 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1231 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1232 |
lemma repeat_Bk[simp]: "(\<exists>rna. Bk \<up> rn = Bk # Bk \<up> rna) \<or> rn = 0" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1233 |
apply(case_tac rn, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1234 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1235 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1236 |
lemma inv_locate_b_Oc_via_a[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1237 |
"inv_locate_a (as, lm) (q, l, Oc # r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1238 |
\<Longrightarrow> inv_locate_b (as, lm) (q, Oc # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1239 |
apply(simp only: inv_locate_a.simps inv_locate_b.simps in_middle.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1240 |
at_begin_norm.simps at_begin_fst_bwtn.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1241 |
at_begin_fst_awtn.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1242 |
apply(erule disjE, erule exE, erule exE, erule exE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1243 |
apply(rule_tac x = lm1 in exI, rule_tac x = "tl lm2" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1244 |
apply(rule_tac x = 0 in exI, rule_tac x = "hd lm2" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1245 |
apply(case_tac lm2, auto simp: tape_of_nl_cons ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1246 |
apply(rule_tac x = 1 in exI, rule_tac x = a in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1247 |
apply(case_tac list, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1248 |
apply(case_tac rn, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1249 |
apply(rule_tac x = "lm @ replicate tn 0" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1250 |
rule_tac x = "[]" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1251 |
rule_tac x = "Suc tn" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1252 |
rule_tac x = 0 in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1253 |
apply(simp only: replicate_Suc[THEN sym] exp_ind) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1254 |
apply(rule_tac x = "Suc 0" in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1255 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1256 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1257 |
lemma length_equal: "xs = ys \<Longrightarrow> length xs = length ys" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1258 |
by auto |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1259 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1260 |
lemma inv_locate_a_Bk_via_b[simp]: "\<lbrakk>inv_locate_b (as, am) (q, aaa, Bk # xs) ires; |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1261 |
\<not> (\<exists>n. xs = Bk\<up>n)\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1262 |
\<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1263 |
apply(simp add: inv_locate_b.simps inv_locate_a.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1264 |
apply(rule_tac disjI1) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1265 |
apply(simp only: in_middle.simps at_begin_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1266 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1267 |
apply(rule_tac x = "lm1 @ [m]" in exI, rule_tac x = lm2 in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1268 |
apply(subgoal_tac "tn = 0", simp , auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1269 |
apply(case_tac [!] mr, simp_all, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1270 |
apply(simp add: tape_of_nl_cons) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1271 |
apply(drule_tac length_equal, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1272 |
apply(case_tac "length am", simp_all, erule_tac x = rn in allE, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1273 |
apply(drule_tac length_equal, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1274 |
apply(case_tac "(Suc (length lm1) - length am)", simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1275 |
apply(case_tac lm2, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1276 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1277 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1278 |
lemma locate_b_2_a[intro]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1279 |
"inv_locate_b (as, am) (q, aaa, Bk # xs) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1280 |
\<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1281 |
apply(case_tac "\<exists> n. xs = Bk\<up>n", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1282 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1283 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1284 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1285 |
lemma inv_locate_b_Bk[simp]: "inv_locate_b (as, am) (q, l, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1286 |
\<Longrightarrow> inv_locate_b (as, am) (q, l, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1287 |
apply(simp only: inv_locate_b.simps in_middle.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1288 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1289 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1290 |
rule_tac x = tn in exI, rule_tac x = m in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1291 |
rule_tac x = ml in exI, rule_tac x = mr in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1292 |
apply(auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1293 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1294 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1295 |
(*inv: from locate_b to after_write*) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1296 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1297 |
lemma div_rounding_down[simp]: "(2*q - Suc 0) div 2 = (q - 1)" "(Suc (2*q)) div 2 = q" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1298 |
by arith+ |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1299 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1300 |
lemma even_plus_one_odd[simp]: "x mod 2 = 0 \<Longrightarrow> Suc x mod 2 = Suc 0" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1301 |
by arith |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1302 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1303 |
lemma odd_plus_one_even[simp]: "x mod 2 = Suc 0 \<Longrightarrow> Suc x mod 2 = 0" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1304 |
by arith |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1305 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1306 |
lemma locate_b_2_locate_a[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1307 |
"\<lbrakk>q > 0; inv_locate_b (as, am) (q - Suc 0, aaa, Bk # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1308 |
\<Longrightarrow> inv_locate_a (as, am) (q, Bk # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1309 |
apply(insert locate_b_2_a [of as am "q - 1" aaa xs ires], simp) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1310 |
done |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1311 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1312 |
(*inv: from locate_b to after_write*) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1313 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1314 |
lemma findnth_inv_layout_of_via_crsp[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1315 |
"crsp (layout_of ap) (as, lm) (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1316 |
\<Longrightarrow> findnth_inv (layout_of ap) n (as, lm) (Suc 0, l, r) ires" |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1317 |
by(auto simp: crsp.simps findnth_inv.simps inv_locate_a.simps |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1318 |
at_begin_norm.simps at_begin_fst_awtn.simps at_begin_fst_bwtn.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1319 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1320 |
lemma findnth_correct_pre: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1321 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1322 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1323 |
and not0: "n > 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1324 |
and f: "f = (\<lambda> stp. (steps (Suc 0, l, r) (findnth n, 0) stp, n))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1325 |
and P: "P = (\<lambda> ((s, l, r), n). s = Suc (2 * n))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1326 |
and Q: "Q = (\<lambda> ((s, l, r), n). findnth_inv ly n (as, lm) (s, l, r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1327 |
shows "\<exists> stp. P (f stp) \<and> Q (f stp)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1328 |
proof(rule_tac LE = findnth_LE in halt_lemma2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1329 |
show "wf findnth_LE" by(intro wf_findnth_LE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1330 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1331 |
show "Q (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1332 |
using crsp layout |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1333 |
apply(simp add: f P Q steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1334 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1335 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1336 |
show "\<not> P (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1337 |
using not0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1338 |
apply(simp add: f P steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1339 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1340 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1341 |
show "\<forall>n. \<not> P (f n) \<and> Q (f n) \<longrightarrow> Q (f (Suc n)) \<and> (f (Suc n), f n) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1342 |
\<in> findnth_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1343 |
proof(rule_tac allI, rule_tac impI, simp add: f, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1344 |
case_tac "steps (Suc 0, l, r) (findnth n, 0) na", simp add: P) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1345 |
fix na a b c |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1346 |
assume "a \<noteq> Suc (2 * n) \<and> Q ((a, b, c), n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1347 |
thus "Q (step (a, b, c) (findnth n, 0), n) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1348 |
((step (a, b, c) (findnth n, 0), n), (a, b, c), n) \<in> findnth_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1349 |
apply(case_tac c, case_tac [2] aa) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1350 |
apply(simp_all add: step.simps findnth_LE_def Q findnth_inv.simps mod_2 lex_pair_def split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1351 |
apply(auto simp: mod_ex1 mod_ex2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1352 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1353 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1354 |
qed |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
1355 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1356 |
lemma inv_locate_a_via_crsp[simp]: |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1357 |
"crsp ly (as, lm) (s, l, r) ires \<Longrightarrow> inv_locate_a (as, lm) (0, l, r) ires" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1358 |
apply(auto simp: crsp.simps inv_locate_a.simps at_begin_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1359 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1360 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1361 |
lemma findnth_correct: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1362 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1363 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1364 |
shows "\<exists> stp l' r'. steps (Suc 0, l, r) (findnth n, 0) stp = (Suc (2 * n), l', r') |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1365 |
\<and> inv_locate_a (as, lm) (n, l', r') ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1366 |
using crsp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1367 |
apply(case_tac "n = 0") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1368 |
apply(rule_tac x = 0 in exI, auto simp: steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1369 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1370 |
apply(drule_tac findnth_correct_pre, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1371 |
apply(rule_tac x = stp in exI, simp add: findnth_inv.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1372 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1373 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1374 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1375 |
fun inc_inv :: "nat \<Rightarrow> inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1376 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1377 |
"inc_inv n (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1378 |
(let lm' = abc_lm_s lm n (Suc (abc_lm_v lm n)) in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1379 |
if s = 0 then False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1380 |
else if s = 1 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1381 |
inv_locate_a (as, lm) (n, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1382 |
else if s = 2 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1383 |
inv_locate_b (as, lm) (n, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1384 |
else if s = 3 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1385 |
inv_after_write (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1386 |
else if s = Suc 3 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1387 |
inv_after_move (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1388 |
else if s = Suc 4 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1389 |
inv_after_clear (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1390 |
else if s = Suc (Suc 4) then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1391 |
inv_on_right_moving (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1392 |
else if s = Suc (Suc 5) then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1393 |
inv_on_left_moving (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1394 |
else if s = Suc (Suc (Suc 5)) then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1395 |
inv_check_left_moving (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1396 |
else if s = Suc (Suc (Suc (Suc 5))) then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1397 |
inv_after_left_moving (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1398 |
else if s = Suc (Suc (Suc (Suc (Suc 5)))) then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1399 |
inv_stop (as, lm') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1400 |
else False)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1401 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1402 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1403 |
fun abc_inc_stage1 :: "config \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1404 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1405 |
"abc_inc_stage1 (s, l, r) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1406 |
(if s = 0 then 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1407 |
else if s \<le> 2 then 5 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1408 |
else if s \<le> 6 then 4 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1409 |
else if s \<le> 8 then 3 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1410 |
else if s = 9 then 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1411 |
else 1)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1412 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1413 |
fun abc_inc_stage2 :: "config \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1414 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1415 |
"abc_inc_stage2 (s, l, r) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1416 |
(if s = 1 then 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1417 |
else if s = 2 then 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1418 |
else if s = 3 then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1419 |
else if s = 4 then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1420 |
else if s = 5 then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1421 |
else if s = 6 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1422 |
if r \<noteq> [] then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1423 |
else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1424 |
else if s = 7 then length l |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1425 |
else if s = 8 then length l |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1426 |
else 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1427 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1428 |
fun abc_inc_stage3 :: "config \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1429 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1430 |
"abc_inc_stage3 (s, l, r) = ( |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1431 |
if s = 4 then 4 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1432 |
else if s = 5 then 3 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1433 |
else if s = 6 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1434 |
if r \<noteq> [] \<and> hd r = Oc then 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1435 |
else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1436 |
else if s = 3 then 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1437 |
else if s = 2 then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1438 |
else if s = 1 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1439 |
if (r \<noteq> [] \<and> hd r = Oc) then 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1440 |
else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1441 |
else 10 - s)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1442 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1443 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1444 |
definition inc_measure :: "config \<Rightarrow> nat \<times> nat \<times> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1445 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1446 |
"inc_measure c = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1447 |
(abc_inc_stage1 c, abc_inc_stage2 c, abc_inc_stage3 c)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1448 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1449 |
definition lex_triple :: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1450 |
"((nat \<times> (nat \<times> nat)) \<times> (nat \<times> (nat \<times> nat))) set" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1451 |
where "lex_triple \<equiv> less_than <*lex*> lex_pair" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1452 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1453 |
definition inc_LE :: "(config \<times> config) set" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1454 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1455 |
"inc_LE \<equiv> (inv_image lex_triple inc_measure)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1456 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1457 |
declare inc_inv.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1458 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1459 |
lemma wf_inc_le[intro]: "wf inc_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1460 |
by(auto intro:wf_inv_image simp: inc_LE_def lex_triple_def lex_pair_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1461 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1462 |
lemma inv_locate_b_2_after_write[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1463 |
"inv_locate_b (as, am) (n, aaa, Bk # xs) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1464 |
\<Longrightarrow> inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1465 |
(s, aaa, Oc # xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1466 |
apply(auto simp: in_middle.simps inv_after_write.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1467 |
abc_lm_v.simps abc_lm_s.simps inv_locate_b.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1468 |
apply(case_tac [!] mr, auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1469 |
apply(rule_tac x = rn in exI, rule_tac x = "Suc m" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1470 |
rule_tac x = "lm1" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1471 |
apply(rule_tac x = "lm2" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1472 |
apply(simp only: Suc_diff_le exp_ind) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1473 |
apply(subgoal_tac "lm2 = []", simp) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1474 |
apply(drule_tac length_equal, simp) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1475 |
by (metis (no_types, lifting) add_diff_inverse_nat append.assoc append_eq_append_conv length_append length_replicate list.inject) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1476 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1477 |
(*inv: from after_write to after_move*) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1478 |
lemma inv_after_move_Oc_via_write[simp]: "inv_after_write (as, lm) (x, l, Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1479 |
\<Longrightarrow> inv_after_move (as, lm) (y, Oc # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1480 |
apply(auto simp:inv_after_move.simps inv_after_write.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1481 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1482 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1483 |
lemma inv_after_write_Suc[simp]: "inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1484 |
)) (x, aaa, Bk # xs) ires = False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1485 |
"inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1486 |
(x, aaa, []) ires = False" |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1487 |
apply(auto simp: inv_after_write.simps ) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1488 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1489 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1490 |
(*inv: from after_move to after_clear*) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1491 |
lemma inv_after_clear_Bk_via_Oc[simp]: "inv_after_move (as, lm) (s, l, Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1492 |
\<Longrightarrow> inv_after_clear (as, lm) (s', l, Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1493 |
apply(auto simp: inv_after_move.simps inv_after_clear.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1494 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1495 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1496 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1497 |
lemma inv_after_move_2_inv_on_left_moving[simp]: |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1498 |
assumes "inv_after_move (as, lm) (s, l, Bk # r) ires" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1499 |
shows "(l = [] \<longrightarrow> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1500 |
inv_on_left_moving (as, lm) (s', [], Bk # Bk # r) ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1501 |
(l \<noteq> [] \<longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1502 |
inv_on_left_moving (as, lm) (s', tl l, hd l # Bk # r) ires)" |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1503 |
proof (cases l) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1504 |
case (Cons a list) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1505 |
from assms Cons show ?thesis |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1506 |
apply(simp only: inv_after_move.simps inv_on_left_moving.simps) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1507 |
apply(rule conjI, force, rule impI, rule disjI1, simp only: inv_on_left_moving_norm.simps) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1508 |
apply(erule exE)+ |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1509 |
apply(subgoal_tac "lm2 = []") |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1510 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1511 |
rule_tac x = m in exI, rule_tac x = m in exI, |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1512 |
rule_tac x = 1 in exI, |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1513 |
rule_tac x = "rn - 1" in exI) apply (auto split:if_splits) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1514 |
apply(case_tac [1-2] rn, simp_all) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1515 |
by(case_tac [!] lm2, simp_all add: tape_of_nl_cons split: if_splits) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1516 |
next |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1517 |
case Nil thus ?thesis using assms |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1518 |
unfolding inv_after_move.simps inv_on_left_moving.simps |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1519 |
by (auto split:if_splits) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1520 |
qed |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1521 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1522 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1523 |
lemma inv_after_move_2_inv_on_left_moving_B[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1524 |
"inv_after_move (as, lm) (s, l, []) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1525 |
\<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s', [], [Bk]) ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1526 |
(l \<noteq> [] \<longrightarrow> inv_on_left_moving (as, lm) (s', tl l, [hd l]) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1527 |
apply(simp only: inv_after_move.simps inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1528 |
apply(subgoal_tac "l \<noteq> []", rule conjI, simp, rule impI, rule disjI1, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1529 |
simp only: inv_on_left_moving_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1530 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1531 |
apply(subgoal_tac "lm2 = []") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1532 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1533 |
rule_tac x = m in exI, rule_tac x = m in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1534 |
rule_tac x = 1 in exI, rule_tac x = "rn - 1" in exI, simp, case_tac rn) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1535 |
apply(auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1536 |
apply(case_tac [!] lm2, auto simp: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1537 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1538 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1539 |
lemma inv_after_clear_2_inv_on_right_moving[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1540 |
"inv_after_clear (as, lm) (x, l, Bk # r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1541 |
\<Longrightarrow> inv_on_right_moving (as, lm) (y, Bk # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1542 |
apply(auto simp: inv_after_clear.simps inv_on_right_moving.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1543 |
apply(subgoal_tac "lm2 \<noteq> []") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1544 |
apply(rule_tac x = "lm1 @ [m]" in exI, rule_tac x = "tl lm2" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1545 |
rule_tac x = "hd lm2" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1546 |
apply(rule_tac x = 0 in exI, rule_tac x = "hd lm2" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1547 |
apply(simp, rule conjI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1548 |
apply(case_tac [!] "lm2::nat list", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1549 |
apply(case_tac rn, auto split: if_splits simp: tape_of_nl_cons) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1550 |
apply(case_tac [!] rn, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1551 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1552 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1553 |
(*inv: from on_right_moving to on_right_movign*) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1554 |
lemma inv_on_right_moving_Oc[simp]: "inv_on_right_moving (as, lm) (x, l, Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1555 |
\<Longrightarrow> inv_on_right_moving (as, lm) (y, Oc # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1556 |
apply(auto simp: inv_on_right_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1557 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1558 |
rule_tac x = "ml + mr" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1559 |
apply(rule_tac x = "Suc ml" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1560 |
rule_tac x = "mr - 1" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1561 |
apply(case_tac mr, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1562 |
apply(rule_tac x = lm1 in exI, rule_tac x = "[]" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1563 |
rule_tac x = "ml + mr" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1564 |
apply(rule_tac x = "Suc ml" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1565 |
rule_tac x = "mr - 1" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1566 |
apply(case_tac mr, auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1567 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1568 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1569 |
lemma inv_on_right_moving_2_inv_on_right_moving[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1570 |
"inv_on_right_moving (as, lm) (x, l, Bk # r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1571 |
\<Longrightarrow> inv_after_write (as, lm) (y, l, Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1572 |
apply(auto simp: inv_on_right_moving.simps inv_after_write.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1573 |
apply(case_tac mr, auto simp: split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1574 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1575 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1576 |
lemma inv_on_right_moving_singleton_Bk[simp]: "inv_on_right_moving (as, lm) (x, l, []) ires\<Longrightarrow> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1577 |
inv_on_right_moving (as, lm) (y, l, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1578 |
apply(auto simp: inv_on_right_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1579 |
apply(rule_tac x = lm1 in exI, rule_tac x = "[]" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1580 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1581 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1582 |
(*inv: from on_left_moving to on_left_moving*) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1583 |
lemma no_inv_on_left_moving_in_middle_B_Oc[simp]: "inv_on_left_moving_in_middle_B (as, lm) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1584 |
(s, l, Oc # r) ires = False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1585 |
apply(auto simp: inv_on_left_moving_in_middle_B.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1586 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1587 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1588 |
lemma no_inv_on_left_moving_norm_Bk[simp]: "inv_on_left_moving_norm (as, lm) (s, l, Bk # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1589 |
= False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1590 |
apply(auto simp: inv_on_left_moving_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1591 |
apply(case_tac [!] mr, auto simp: ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1592 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1593 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1594 |
lemma inv_on_left_moving_in_middle_B_Bk[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1595 |
"\<lbrakk>inv_on_left_moving_norm (as, lm) (s, l, Oc # r) ires; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1596 |
hd l = Bk; l \<noteq> []\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1597 |
inv_on_left_moving_in_middle_B (as, lm) (s, tl l, Bk # Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1598 |
apply(case_tac l, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1599 |
apply(simp only: inv_on_left_moving_norm.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1600 |
inv_on_left_moving_in_middle_B.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1601 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1602 |
apply(rule_tac x = lm1 in exI, rule_tac x = "m # lm2" in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1603 |
apply(case_tac [!] ml, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1604 |
apply(auto simp: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1605 |
apply(rule_tac [!] x = "Suc rn" in exI, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1606 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1607 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1608 |
lemma inv_on_left_moving_norm_Oc_Oc[simp]: "\<lbrakk>inv_on_left_moving_norm (as, lm) (s, l, Oc # r) ires; |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1609 |
hd l = Oc; l \<noteq> []\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1610 |
\<Longrightarrow> inv_on_left_moving_norm (as, lm) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1611 |
(s, tl l, Oc # Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1612 |
apply(simp only: inv_on_left_moving_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1613 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1614 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1615 |
rule_tac x = m in exI, rule_tac x = "ml - 1" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1616 |
rule_tac x = "Suc mr" in exI, rule_tac x = rn in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1617 |
apply(case_tac ml, auto simp: split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1618 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1619 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1620 |
lemma inv_on_left_moving_in_middle_B_Bk_Oc[simp]: "inv_on_left_moving_norm (as, lm) (s, [], Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1621 |
\<Longrightarrow> inv_on_left_moving_in_middle_B (as, lm) (s, [], Bk # Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1622 |
apply(auto simp: inv_on_left_moving_norm.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1623 |
inv_on_left_moving_in_middle_B.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1624 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1625 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1626 |
lemma inv_on_left_moving_Oc_cases[simp]:"inv_on_left_moving (as, lm) (s, l, Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1627 |
\<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s, [], Bk # Oc # r) ires) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1628 |
\<and> (l \<noteq> [] \<longrightarrow> inv_on_left_moving (as, lm) (s, tl l, hd l # Oc # r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1629 |
apply(simp add: inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1630 |
apply(case_tac "l \<noteq> []", rule conjI, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1631 |
apply(case_tac "hd l", simp, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1632 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1633 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1634 |
lemma from_on_left_moving_to_check_left_moving[simp]: "inv_on_left_moving_in_middle_B (as, lm) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1635 |
(s, Bk # list, Bk # r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1636 |
\<Longrightarrow> inv_check_left_moving_on_leftmost (as, lm) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1637 |
(s', list, Bk # Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1638 |
apply(auto simp: inv_on_left_moving_in_middle_B.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1639 |
inv_check_left_moving_on_leftmost.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1640 |
apply(case_tac [!] "rev lm1", simp_all) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1641 |
apply(case_tac [!] lista, simp_all add: tape_of_nat_def tape_of_list_def) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1642 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1643 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1644 |
lemma inv_check_left_moving_in_middle_no_Bk[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1645 |
"inv_check_left_moving_in_middle (as, lm) (s, l, Bk # r) ires= False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1646 |
by(auto simp: inv_check_left_moving_in_middle.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1647 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1648 |
lemma inv_check_left_moving_on_leftmost_Bk_Bk[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1649 |
"inv_on_left_moving_in_middle_B (as, lm) (s, [], Bk # r) ires\<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1650 |
inv_check_left_moving_on_leftmost (as, lm) (s', [], Bk # Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1651 |
apply(auto simp: inv_on_left_moving_in_middle_B.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1652 |
inv_check_left_moving_on_leftmost.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1653 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1654 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1655 |
lemma inv_check_left_moving_on_leftmost_no_Oc[simp]: "inv_check_left_moving_on_leftmost (as, lm) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1656 |
(s, list, Oc # r) ires= False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1657 |
by(auto simp: inv_check_left_moving_on_leftmost.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1658 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1659 |
lemma inv_check_left_moving_in_middle_Oc_Bk[simp]: "inv_on_left_moving_in_middle_B (as, lm) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1660 |
(s, Oc # list, Bk # r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1661 |
\<Longrightarrow> inv_check_left_moving_in_middle (as, lm) (s', list, Oc # Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1662 |
apply(auto simp: inv_on_left_moving_in_middle_B.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1663 |
inv_check_left_moving_in_middle.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1664 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1665 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1666 |
lemma inv_on_left_moving_2_check_left_moving[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1667 |
"inv_on_left_moving (as, lm) (s, l, Bk # r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1668 |
\<Longrightarrow> (l = [] \<longrightarrow> inv_check_left_moving (as, lm) (s', [], Bk # Bk # r) ires) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1669 |
\<and> (l \<noteq> [] \<longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1670 |
inv_check_left_moving (as, lm) (s', tl l, hd l # Bk # r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1671 |
apply(simp add: inv_on_left_moving.simps inv_check_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1672 |
apply(case_tac l, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1673 |
apply(case_tac a, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1674 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1675 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1676 |
lemma inv_on_left_moving_norm_no_empty[simp]: "inv_on_left_moving_norm (as, lm) (s, l, []) ires = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1677 |
apply(auto simp: inv_on_left_moving_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1678 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1679 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1680 |
lemma inv_on_left_moving_no_empty[simp]: "inv_on_left_moving (as, lm) (s, l, []) ires = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1681 |
apply(simp add: inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1682 |
apply(simp add: inv_on_left_moving_in_middle_B.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1683 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1684 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1685 |
lemma Bk_plus_one[intro]: "\<exists>rna. Bk # Bk \<up> rn = Bk \<up> rna" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1686 |
apply(rule_tac x = "Suc rn" in exI, simp) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1687 |
done |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1688 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1689 |
lemma |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1690 |
inv_check_left_moving_in_middle_2_on_left_moving_in_middle_B[simp]: |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1691 |
assumes "inv_check_left_moving_in_middle (as, lm) (s, Bk # list, Oc # r) ires" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1692 |
shows "inv_on_left_moving_in_middle_B (as, lm) (s', list, Bk # Oc # r) ires" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1693 |
using assms |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1694 |
apply(simp only: inv_check_left_moving_in_middle.simps |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1695 |
inv_on_left_moving_in_middle_B.simps) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1696 |
apply(erule_tac exE)+ |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1697 |
apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1698 |
rule_tac x = "[hd (rev lm1)] @ lm2" in exI, auto) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1699 |
apply(case_tac [!] "rev lm1",simp_all add: tape_of_nat_def tape_of_list_def tape_of_nat_list.simps) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1700 |
apply(case_tac [!] a, simp_all) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1701 |
apply(case_tac [1] lm2, auto simp:tape_of_nat_def) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1702 |
apply(case_tac [3] lm2, auto simp:tape_of_nat_def) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1703 |
apply(case_tac [!] lista, simp_all add: tape_of_nat_def) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1704 |
done |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1705 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1706 |
lemma inv_check_left_moving_in_middle_Bk_Oc[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1707 |
"inv_check_left_moving_in_middle (as, lm) (s, [], Oc # r) ires\<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1708 |
inv_check_left_moving_in_middle (as, lm) (s', [Bk], Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1709 |
apply(auto simp: inv_check_left_moving_in_middle.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1710 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1711 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1712 |
lemma inv_on_left_moving_norm_Oc_Oc_via_middle[simp]: "inv_check_left_moving_in_middle (as, lm) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1713 |
(s, Oc # list, Oc # r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1714 |
\<Longrightarrow> inv_on_left_moving_norm (as, lm) (s', list, Oc # Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1715 |
apply(auto simp: inv_check_left_moving_in_middle.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1716 |
inv_on_left_moving_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1717 |
apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1718 |
rule_tac x = lm2 in exI, rule_tac x = "hd (rev lm1)" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1719 |
apply(rule_tac conjI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1720 |
apply(case_tac "rev lm1", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1721 |
apply(rule_tac x = "hd (rev lm1) - 1" in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1722 |
apply(rule_tac [!] x = "Suc (Suc 0)" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1723 |
apply(case_tac [!] "rev lm1", simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1724 |
apply(case_tac [!] a, simp_all add: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1725 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1726 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1727 |
lemma inv_check_left_moving_Oc_cases[simp]: "inv_check_left_moving (as, lm) (s, l, Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1728 |
\<Longrightarrow> (l = [] \<longrightarrow> inv_on_left_moving (as, lm) (s', [], Bk # Oc # r) ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1729 |
(l \<noteq> [] \<longrightarrow> inv_on_left_moving (as, lm) (s', tl l, hd l # Oc # r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1730 |
apply(case_tac l, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1731 |
auto simp: inv_check_left_moving.simps inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1732 |
apply(case_tac a, simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1733 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1734 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1735 |
(*inv: check_left_moving to after_left_moving*) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1736 |
lemma inv_after_left_moving_Bk_via_check[simp]: "inv_check_left_moving (as, lm) (s, l, Bk # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1737 |
\<Longrightarrow> inv_after_left_moving (as, lm) (s', Bk # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1738 |
apply(auto simp: inv_check_left_moving.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1739 |
inv_check_left_moving_on_leftmost.simps inv_after_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1740 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1741 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1742 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1743 |
lemma inv_after_left_moving_Bk_empty_via_check[simp]:"inv_check_left_moving (as, lm) (s, l, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1744 |
\<Longrightarrow> inv_after_left_moving (as, lm) (s', Bk # l, []) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1745 |
by(simp add: inv_check_left_moving.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1746 |
inv_check_left_moving_in_middle.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1747 |
inv_check_left_moving_on_leftmost.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1748 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1749 |
(*inv: after_left_moving to inv_stop*) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1750 |
lemma inv_stop_Bk_move[simp]: "inv_after_left_moving (as, lm) (s, l, Bk # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1751 |
\<Longrightarrow> inv_stop (as, lm) (s', Bk # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1752 |
apply(auto simp: inv_after_left_moving.simps inv_stop.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1753 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1754 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1755 |
lemma inv_stop_Bk_empty[simp]: "inv_after_left_moving (as, lm) (s, l, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1756 |
\<Longrightarrow> inv_stop (as, lm) (s', Bk # l, []) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1757 |
by(auto simp: inv_after_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1758 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1759 |
(*inv: stop to stop*) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1760 |
lemma inv_stop_indep_fst[simp]: "inv_stop (as, lm) (x, l, r) ires \<Longrightarrow> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1761 |
inv_stop (as, lm) (y, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1762 |
apply(simp add: inv_stop.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1763 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1764 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1765 |
lemma inv_after_clear_no_Oc[simp]: "inv_after_clear (as, lm) (s, aaa, Oc # xs) ires= False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1766 |
apply(auto simp: inv_after_clear.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1767 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1768 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1769 |
lemma inv_after_left_moving_no_Oc[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1770 |
"inv_after_left_moving (as, lm) (s, aaa, Oc # xs) ires = False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1771 |
by(auto simp: inv_after_left_moving.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1772 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1773 |
lemma inv_after_clear_Suc_nonempty[simp]: |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1774 |
"inv_after_clear (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) (s, b, []) ires = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1775 |
apply(auto simp: inv_after_clear.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1776 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1777 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1778 |
lemma inv_on_left_moving_Suc_nonempty[simp]: "inv_on_left_moving (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1779 |
(s, b, Oc # list) ires \<Longrightarrow> b \<noteq> []" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1780 |
apply(auto simp: inv_on_left_moving.simps inv_on_left_moving_norm.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1781 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1782 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1783 |
lemma inv_check_left_moving_Suc_nonempty[simp]: |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1784 |
"inv_check_left_moving (as, abc_lm_s lm n (Suc (abc_lm_v lm n))) (s, b, Oc # list) ires \<Longrightarrow> b \<noteq> []" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1785 |
apply(auto simp: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps split: if_splits) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1786 |
done |
173
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
1787 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1788 |
lemma tinc_correct_pre: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1789 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1790 |
and inv_start: "inv_locate_a (as, lm) (n, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1791 |
and lm': "lm' = abc_lm_s lm n (Suc (abc_lm_v lm n))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1792 |
and f: "f = steps (Suc 0, l, r) (tinc_b, 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1793 |
and P: "P = (\<lambda> (s, l, r). s = 10)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1794 |
and Q: "Q = (\<lambda> (s, l, r). inc_inv n (as, lm) (s, l, r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1795 |
shows "\<exists> stp. P (f stp) \<and> Q (f stp)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1796 |
proof(rule_tac LE = inc_LE in halt_lemma2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1797 |
show "wf inc_LE" by(auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1798 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1799 |
show "Q (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1800 |
using inv_start |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1801 |
apply(simp add: f P Q steps.simps inc_inv.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1802 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1803 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1804 |
show "\<not> P (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1805 |
apply(simp add: f P steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1806 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1807 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1808 |
show "\<forall>n. \<not> P (f n) \<and> Q (f n) \<longrightarrow> Q (f (Suc n)) \<and> (f (Suc n), f n) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1809 |
\<in> inc_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1810 |
proof(rule_tac allI, rule_tac impI, simp add: f, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1811 |
case_tac "steps (Suc 0, l, r) (tinc_b, 0) n", simp add: P) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1812 |
fix n a b c |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1813 |
assume "a \<noteq> 10 \<and> Q (a, b, c)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1814 |
thus "Q (step (a, b, c) (tinc_b, 0)) \<and> (step (a, b, c) (tinc_b, 0), a, b, c) \<in> inc_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1815 |
apply(simp add:Q) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1816 |
apply(simp add: inc_inv.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1817 |
apply(case_tac c, case_tac [2] aa) |
173
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
1818 |
apply(auto simp: Let_def step.simps tinc_b_def split: if_splits) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1819 |
apply(simp_all add: inc_inv.simps inc_LE_def lex_triple_def lex_pair_def inc_measure_def |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1820 |
numeral) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1821 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1822 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1823 |
qed |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1824 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1825 |
lemma tinc_correct: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1826 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1827 |
and inv_start: "inv_locate_a (as, lm) (n, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1828 |
and lm': "lm' = abc_lm_s lm n (Suc (abc_lm_v lm n))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1829 |
shows "\<exists> stp l' r'. steps (Suc 0, l, r) (tinc_b, 0) stp = (10, l', r') |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1830 |
\<and> inv_stop (as, lm') (10, l', r') ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1831 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1832 |
apply(drule_tac tinc_correct_pre, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1833 |
apply(rule_tac x = stp in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1834 |
apply(simp add: inc_inv.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1835 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1836 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1837 |
declare inv_locate_a.simps[simp del] abc_lm_s.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1838 |
abc_lm_v.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1839 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
1840 |
lemma is_even_4[simp]: "(4::nat) * n mod 2 = 0" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1841 |
apply(arith) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1842 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1843 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1844 |
lemma crsp_step_inc_pre: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1845 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1846 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1847 |
and aexec: "abc_step_l (as, lm) (Some (Inc n)) = (asa, lma)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1848 |
shows "\<exists> stp k. steps (Suc 0, l, r) (findnth n @ shift tinc_b (2 * n), 0) stp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1849 |
= (2*n + 10, Bk # Bk # ires, <lma> @ Bk\<up>k) \<and> stp > 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1850 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1851 |
have "\<exists> stp l' r'. steps (Suc 0, l, r) (findnth n, 0) stp = (Suc (2 * n), l', r') |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1852 |
\<and> inv_locate_a (as, lm) (n, l', r') ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1853 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1854 |
apply(rule_tac findnth_correct, simp_all add: crsp layout) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1855 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1856 |
from this obtain stp l' r' where a: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1857 |
"steps (Suc 0, l, r) (findnth n, 0) stp = (Suc (2 * n), l', r') |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1858 |
\<and> inv_locate_a (as, lm) (n, l', r') ires" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1859 |
moreover have |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1860 |
"\<exists> stp la ra. steps (Suc 0, l', r') (tinc_b, 0) stp = (10, la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1861 |
\<and> inv_stop (as, lma) (10, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1862 |
using assms a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1863 |
proof(rule_tac lm' = lma and n = n and lm = lm and ly = ly and ap = ap in tinc_correct, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1864 |
simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1865 |
show "lma = abc_lm_s lm n (Suc (abc_lm_v lm n))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1866 |
using aexec |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1867 |
apply(simp add: abc_step_l.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1868 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1869 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1870 |
from this obtain stpa la ra where b: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1871 |
"steps (Suc 0, l', r') (tinc_b, 0) stpa = (10, la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1872 |
\<and> inv_stop (as, lma) (10, la, ra) ires" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1873 |
from a b show "\<exists>stp k. steps (Suc 0, l, r) (findnth n @ shift tinc_b (2 * n), 0) stp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1874 |
= (2 * n + 10, Bk # Bk # ires, <lma> @ Bk \<up> k) \<and> stp > 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1875 |
apply(rule_tac x = "stp + stpa" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1876 |
using tm_append_steps[of "Suc 0" l r "findnth n" stp l' r' tinc_b stpa 10 la ra "length (findnth n) div 2"] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1877 |
apply(simp add: length_findnth inv_stop.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1878 |
apply(case_tac stpa, simp_all add: steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1879 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1880 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1881 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1882 |
lemma crsp_step_inc: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1883 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1884 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1885 |
and fetch: "abc_fetch as ap = Some (Inc n)" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1886 |
shows "\<exists>stp > 0. crsp ly (abc_step_l (as, lm) (Some (Inc n))) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1887 |
(steps (s, l, r) (ci ly (start_of ly as) (Inc n), start_of ly as - Suc 0) stp) ires" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1888 |
proof(case_tac "(abc_step_l (as, lm) (Some (Inc n)))") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1889 |
fix a b |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1890 |
assume aexec: "abc_step_l (as, lm) (Some (Inc n)) = (a, b)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1891 |
then have "\<exists> stp k. steps (Suc 0, l, r) (findnth n @ shift tinc_b (2 * n), 0) stp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1892 |
= (2*n + 10, Bk # Bk # ires, <b> @ Bk\<up>k) \<and> stp > 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1893 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1894 |
apply(rule_tac crsp_step_inc_pre, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1895 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1896 |
thus "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1897 |
using assms aexec |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1898 |
apply(erule_tac exE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1899 |
apply(erule_tac exE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1900 |
apply(erule_tac conjE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1901 |
apply(rule_tac x = stp in exI, simp add: ci.simps tm_shift_eq_steps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1902 |
apply(drule_tac off = "(start_of (layout_of ap) as - Suc 0)" in tm_shift_eq_steps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1903 |
apply(auto simp: crsp.simps abc_step_l.simps fetch start_of_Suc1) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1904 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1905 |
qed |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1906 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1907 |
subsection{* Crsp of Dec n e*} |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
1908 |
declare adjust.simps[simp del] |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1909 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1910 |
type_synonym dec_inv_t = "(nat * nat list) \<Rightarrow> config \<Rightarrow> cell list \<Rightarrow> bool" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1911 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1912 |
fun dec_first_on_right_moving :: "nat \<Rightarrow> dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1913 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1914 |
"dec_first_on_right_moving n (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1915 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1916 |
ml + mr = Suc m \<and> length lm1 = n \<and> ml > 0 \<and> m > 0 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1917 |
(if lm1 = [] then l = Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1918 |
else l = Oc\<up>ml @ [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1919 |
((r = Oc\<up>mr @ [Bk] @ <lm2> @ Bk\<up>rn) \<or> (r = Oc\<up>mr \<and> lm2 = [])))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1920 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1921 |
fun dec_on_right_moving :: "dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1922 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1923 |
"dec_on_right_moving (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1924 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1925 |
ml + mr = Suc (Suc m) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1926 |
(if lm1 = [] then l = Oc\<up>ml@ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1927 |
else l = Oc\<up>ml @ [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1928 |
((r = Oc\<up>mr @ [Bk] @ <lm2> @ Bk\<up>rn) \<or> (r = Oc\<up>mr \<and> lm2 = [])))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1929 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1930 |
fun dec_after_clear :: "dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1931 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1932 |
"dec_after_clear (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1933 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1934 |
ml + mr = Suc m \<and> ml = Suc m \<and> r \<noteq> [] \<and> r \<noteq> [] \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1935 |
(if lm1 = [] then l = Oc\<up>ml@ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1936 |
else l = Oc\<up>ml @ [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1937 |
(tl r = Bk # <lm2> @ Bk\<up>rn \<or> tl r = [] \<and> lm2 = []))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1938 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1939 |
fun dec_after_write :: "dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1940 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1941 |
"dec_after_write (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1942 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1943 |
ml + mr = Suc m \<and> ml = Suc m \<and> lm2 \<noteq> [] \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1944 |
(if lm1 = [] then l = Bk # Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1945 |
else l = Bk # Oc\<up>ml @ [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1946 |
tl r = <lm2> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1947 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1948 |
fun dec_right_move :: "dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1949 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1950 |
"dec_right_move (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1951 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1952 |
\<and> ml = Suc m \<and> mr = (0::nat) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1953 |
(if lm1 = [] then l = Bk # Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1954 |
else l = Bk # Oc\<up>ml @ [Bk] @ <rev lm1> @ Bk # Bk # ires) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1955 |
\<and> (r = Bk # <lm2> @ Bk\<up>rn \<or> r = [] \<and> lm2 = []))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1956 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1957 |
fun dec_check_right_move :: "dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1958 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1959 |
"dec_check_right_move (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1960 |
(\<exists> lm1 lm2 m ml mr rn. lm = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1961 |
ml = Suc m \<and> mr = (0::nat) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1962 |
(if lm1 = [] then l = Bk # Bk # Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1963 |
else l = Bk # Bk # Oc\<up>ml @ [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1964 |
r = <lm2> @ Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1965 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1966 |
fun dec_left_move :: "dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1967 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1968 |
"dec_left_move (as, lm) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1969 |
(\<exists> lm1 m rn. (lm::nat list) = lm1 @ [m::nat] \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1970 |
rn > 0 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1971 |
(if lm1 = [] then l = Bk # Oc\<up>Suc m @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1972 |
else l = Bk # Oc\<up>Suc m @ Bk # <rev lm1> @ Bk # Bk # ires) \<and> r = Bk\<up>rn)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1973 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1974 |
declare |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1975 |
dec_on_right_moving.simps[simp del] dec_after_clear.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1976 |
dec_after_write.simps[simp del] dec_left_move.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1977 |
dec_check_right_move.simps[simp del] dec_right_move.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1978 |
dec_first_on_right_moving.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1979 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1980 |
fun inv_locate_n_b :: "inc_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1981 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1982 |
"inv_locate_n_b (as, lm) (s, l, r) ires= |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1983 |
(\<exists> lm1 lm2 tn m ml mr rn. lm @ 0\<up>tn = lm1 @ [m] @ lm2 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1984 |
length lm1 = s \<and> m + 1 = ml + mr \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1985 |
ml = 1 \<and> tn = s + 1 - length lm \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1986 |
(if lm1 = [] then l = Oc\<up>ml @ Bk # Bk # ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1987 |
else l = Oc\<up>ml @ Bk # <rev lm1> @ Bk # Bk # ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1988 |
(r = Oc\<up>mr @ [Bk] @ <lm2>@ Bk\<up>rn \<or> (lm2 = [] \<and> r = Oc\<up>mr)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1989 |
)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1990 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1991 |
fun dec_inv_1 :: "layout \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1992 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1993 |
"dec_inv_1 ly n e (as, am) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1994 |
(let ss = start_of ly as in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1995 |
let am' = abc_lm_s am n (abc_lm_v am n - Suc 0) in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1996 |
let am'' = abc_lm_s am n (abc_lm_v am n) in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1997 |
if s = start_of ly e then inv_stop (as, am'') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1998 |
else if s = ss then False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
1999 |
else if s = ss + 2 * n + 1 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2000 |
inv_locate_b (as, am) (n, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2001 |
else if s = ss + 2 * n + 13 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2002 |
inv_on_left_moving (as, am'') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2003 |
else if s = ss + 2 * n + 14 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2004 |
inv_check_left_moving (as, am'') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2005 |
else if s = ss + 2 * n + 15 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2006 |
inv_after_left_moving (as, am'') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2007 |
else False)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2008 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2009 |
declare fetch.simps[simp del] |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2010 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2011 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2012 |
lemma x_plus_helpers: |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2013 |
"x + 4 = Suc (x + 3)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2014 |
"x + 5 = Suc (x + 4)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2015 |
"x + 6 = Suc (x + 5)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2016 |
"x + 7 = Suc (x + 6)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2017 |
"x + 8 = Suc (x + 7)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2018 |
"x + 9 = Suc (x + 8)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2019 |
"x + 10 = Suc (x + 9)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2020 |
"x + 11 = Suc (x + 10)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2021 |
"x + 12 = Suc (x + 11)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2022 |
"x + 13 = Suc (x + 12)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2023 |
"14 + x = Suc (x + 13)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2024 |
"15 + x = Suc (x + 14)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2025 |
"16 + x = Suc (x + 15)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2026 |
by auto |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2027 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2028 |
lemma fetch_Dec[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2029 |
"fetch (ci ly (start_of ly as) (Dec n e)) (Suc (2 * n)) Bk = (W1, start_of ly as + 2 *n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2030 |
"fetch (ci ly (start_of ly as) (Dec n e)) (Suc (2 * n)) Oc = (R, Suc (start_of ly as) + 2 *n)" |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2031 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (2 * n))) Oc |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2032 |
= (R, start_of ly as + 2*n + 2)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2033 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (2 * n))) Bk |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2034 |
= (L, start_of ly as + 2*n + 13)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2035 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (Suc (2 * n)))) Oc |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2036 |
= (R, start_of ly as + 2*n + 2)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2037 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (Suc (Suc (Suc (2 * n)))) Bk |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2038 |
= (L, start_of ly as + 2*n + 3)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2039 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 4) Oc = (W0, start_of ly as + 2*n + 3)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2040 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 4) Bk = (R, start_of ly as + 2*n + 4)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2041 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 5) Bk = (R, start_of ly as + 2*n + 5)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2042 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 6) Bk = (L, start_of ly as + 2*n + 6)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2043 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 6) Oc = (L, start_of ly as + 2*n + 7)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2044 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 7) Bk = (L, start_of ly as + 2*n + 10)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2045 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 8) Bk = (W1, start_of ly as + 2*n + 7)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2046 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 8) Oc = (R, start_of ly as + 2*n + 8)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2047 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 9) Bk = (L, start_of ly as + 2*n + 9)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2048 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 9) Oc = (R, start_of ly as + 2*n + 8)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2049 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 10) Bk = (R, start_of ly as + 2*n + 4)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2050 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 10) Oc = (W0, start_of ly as + 2*n + 9)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2051 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 11) Oc = (L, start_of ly as + 2*n + 10)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2052 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 11) Bk = (L, start_of ly as + 2*n + 11)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2053 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 12) Oc = (L, start_of ly as + 2*n + 10)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2054 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 12) Bk = (R, start_of ly as + 2*n + 12)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2055 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (2 * n + 13) Bk = (R, start_of ly as + 2*n + 16)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2056 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (14 + 2 * n) Oc = (L, start_of ly as + 2*n + 13)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2057 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (14 + 2 * n) Bk = (L, start_of ly as + 2*n + 14)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2058 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (15 + 2 * n) Oc = (L, start_of ly as + 2*n + 13)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2059 |
"fetch (ci (ly) (start_of ly as) (Dec n e)) (15 + 2 * n) Bk = (R, start_of ly as + 2*n + 15)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2060 |
"fetch (ci (ly) (start_of (ly) as) (Dec n e)) (16 + 2 * n) Bk = (R, start_of (ly) e)" |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2061 |
unfolding x_plus_helpers fetch.simps |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2062 |
by(auto simp: ci.simps findnth.simps |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2063 |
nth_of.simps shift.simps nth_append tdec_b_def length_findnth adjust.simps) |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2064 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2065 |
lemma steps_start_of_invb_inv_locate_a1[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2066 |
"\<lbrakk>r = [] \<or> hd r = Bk; inv_locate_a (as, lm) (n, l, r) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2067 |
\<Longrightarrow> \<exists>stp la ra. |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2068 |
steps (start_of ly as + 2 * n, l, r) (ci ly (start_of ly as) (Dec n e), |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2069 |
start_of ly as - Suc 0) stp = (Suc (start_of ly as + 2 * n), la, ra) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2070 |
inv_locate_b (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2071 |
apply(rule_tac x = "Suc (Suc 0)" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2072 |
apply(auto simp: steps.simps step.simps length_ci_dec) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2073 |
apply(case_tac r, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2074 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2075 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2076 |
lemma steps_start_of_invb_inv_locate_a2[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2077 |
"\<lbrakk>inv_locate_a (as, lm) (n, l, r) ires; r \<noteq> [] \<and> hd r \<noteq> Bk\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2078 |
\<Longrightarrow> \<exists>stp la ra. |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2079 |
steps (start_of ly as + 2 * n, l, r) (ci ly (start_of ly as) (Dec n e), |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2080 |
start_of ly as - Suc 0) stp = (Suc (start_of ly as + 2 * n), la, ra) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2081 |
inv_locate_b (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2082 |
apply(rule_tac x = "(Suc 0)" in exI, case_tac "hd r", simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2083 |
apply(auto simp: steps.simps step.simps length_ci_dec) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2084 |
apply(case_tac r, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2085 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2086 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2087 |
fun abc_dec_1_stage1:: "config \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2088 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2089 |
"abc_dec_1_stage1 (s, l, r) ss n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2090 |
(if s > ss \<and> s \<le> ss + 2*n + 1 then 4 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2091 |
else if s = ss + 2 * n + 13 \<or> s = ss + 2*n + 14 then 3 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2092 |
else if s = ss + 2*n + 15 then 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2093 |
else 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2094 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2095 |
fun abc_dec_1_stage2:: "config \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2096 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2097 |
"abc_dec_1_stage2 (s, l, r) ss n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2098 |
(if s \<le> ss + 2 * n + 1 then (ss + 2 * n + 16 - s) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2099 |
else if s = ss + 2*n + 13 then length l |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2100 |
else if s = ss + 2*n + 14 then length l |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2101 |
else 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2102 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2103 |
fun abc_dec_1_stage3 :: "config \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2104 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2105 |
"abc_dec_1_stage3 (s, l, r) ss n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2106 |
(if s \<le> ss + 2*n + 1 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2107 |
if (s - ss) mod 2 = 0 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2108 |
if r \<noteq> [] \<and> hd r = Oc then 0 else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2109 |
else length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2110 |
else if s = ss + 2 * n + 13 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2111 |
if r \<noteq> [] \<and> hd r = Oc then 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2112 |
else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2113 |
else if s = ss + 2 * n + 14 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2114 |
if r \<noteq> [] \<and> hd r = Oc then 3 else 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2115 |
else 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2116 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2117 |
fun abc_dec_1_measure :: "(config \<times> nat \<times> nat) \<Rightarrow> (nat \<times> nat \<times> nat)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2118 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2119 |
"abc_dec_1_measure (c, ss, n) = (abc_dec_1_stage1 c ss n, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2120 |
abc_dec_1_stage2 c ss n, abc_dec_1_stage3 c ss n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2121 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2122 |
definition abc_dec_1_LE :: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2123 |
"((config \<times> nat \<times> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2124 |
nat) \<times> (config \<times> nat \<times> nat)) set" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2125 |
where "abc_dec_1_LE \<equiv> (inv_image lex_triple abc_dec_1_measure)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2126 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2127 |
lemma wf_dec_le: "wf abc_dec_1_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2128 |
by(auto intro:wf_inv_image simp:abc_dec_1_LE_def lex_triple_def lex_pair_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2129 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2130 |
lemma startof_Suc2: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2131 |
"abc_fetch as ap = Some (Dec n e) \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2132 |
start_of (layout_of ap) (Suc as) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2133 |
start_of (layout_of ap) as + 2 * n + 16" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2134 |
apply(auto simp: start_of.simps layout_of.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2135 |
length_of.simps abc_fetch.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2136 |
take_Suc_conv_app_nth split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2137 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2138 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2139 |
lemma start_of_less_2: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2140 |
"start_of ly e \<le> start_of ly (Suc e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2141 |
apply(case_tac "e < length ly") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2142 |
apply(auto simp: start_of.simps take_Suc take_Suc_conv_app_nth) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2143 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2144 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2145 |
lemma start_of_less_1: "start_of ly e \<le> start_of ly (e + d)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2146 |
proof(induct d) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2147 |
case 0 thus "?case" by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2148 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2149 |
case (Suc d) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2150 |
have "start_of ly e \<le> start_of ly (e + d)" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2151 |
moreover have "start_of ly (e + d) \<le> start_of ly (Suc (e + d))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2152 |
by(rule_tac start_of_less_2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2153 |
ultimately show"?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2154 |
by(simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2155 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2156 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2157 |
lemma start_of_less: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2158 |
assumes "e < as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2159 |
shows "start_of ly e \<le> start_of ly as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2160 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2161 |
obtain d where " as = e + d" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2162 |
using assms by (metis less_imp_add_positive) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2163 |
thus "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2164 |
by(simp add: start_of_less_1) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2165 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2166 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2167 |
lemma start_of_ge: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2168 |
assumes fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2169 |
and layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2170 |
and great: "e > as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2171 |
shows "start_of ly e \<ge> start_of ly as + 2*n + 16" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2172 |
proof(cases "e = Suc as") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2173 |
case True |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2174 |
have "e = Suc as" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2175 |
moreover hence "start_of ly (Suc as) = start_of ly as + 2*n + 16" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2176 |
using layout fetch |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2177 |
by(simp add: startof_Suc2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2178 |
ultimately show "?thesis" by (simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2179 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2180 |
case False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2181 |
have "e \<noteq> Suc as" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2182 |
then have "e > Suc as" using great by arith |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2183 |
then have "start_of ly (Suc as) \<le> start_of ly e" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2184 |
by(simp add: start_of_less) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2185 |
moreover have "start_of ly (Suc as) = start_of ly as + 2*n + 16" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2186 |
using layout fetch |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2187 |
by(simp add: startof_Suc2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2188 |
ultimately show "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2189 |
by arith |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2190 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2191 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2192 |
declare dec_inv_1.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2193 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2194 |
lemma start_of_ineq1[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2195 |
"\<lbrakk>abc_fetch as aprog = Some (Dec n e); ly = layout_of aprog\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2196 |
\<Longrightarrow> (start_of ly e \<noteq> Suc (start_of ly as + 2 * n) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2197 |
start_of ly e \<noteq> Suc (Suc (start_of ly as + 2 * n)) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2198 |
start_of ly e \<noteq> start_of ly as + 2 * n + 3 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2199 |
start_of ly e \<noteq> start_of ly as + 2 * n + 4 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2200 |
start_of ly e \<noteq> start_of ly as + 2 * n + 5 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2201 |
start_of ly e \<noteq> start_of ly as + 2 * n + 6 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2202 |
start_of ly e \<noteq> start_of ly as + 2 * n + 7 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2203 |
start_of ly e \<noteq> start_of ly as + 2 * n + 8 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2204 |
start_of ly e \<noteq> start_of ly as + 2 * n + 9 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2205 |
start_of ly e \<noteq> start_of ly as + 2 * n + 10 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2206 |
start_of ly e \<noteq> start_of ly as + 2 * n + 11 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2207 |
start_of ly e \<noteq> start_of ly as + 2 * n + 12 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2208 |
start_of ly e \<noteq> start_of ly as + 2 * n + 13 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2209 |
start_of ly e \<noteq> start_of ly as + 2 * n + 14 \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2210 |
start_of ly e \<noteq> start_of ly as + 2 * n + 15)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2211 |
using start_of_ge[of as aprog n e ly] start_of_less[of e as ly] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2212 |
apply(case_tac "e < as", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2213 |
apply(case_tac "e = as", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2214 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2215 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2216 |
lemma start_of_ineq2[simp]: "\<lbrakk>abc_fetch as aprog = Some (Dec n e); ly = layout_of aprog\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2217 |
\<Longrightarrow> (Suc (start_of ly as + 2 * n) \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2218 |
Suc (Suc (start_of ly as + 2 * n)) \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2219 |
start_of ly as + 2 * n + 3 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2220 |
start_of ly as + 2 * n + 4 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2221 |
start_of ly as + 2 * n + 5 \<noteq>start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2222 |
start_of ly as + 2 * n + 6 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2223 |
start_of ly as + 2 * n + 7 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2224 |
start_of ly as + 2 * n + 8 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2225 |
start_of ly as + 2 * n + 9 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2226 |
start_of ly as + 2 * n + 10 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2227 |
start_of ly as + 2 * n + 11 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2228 |
start_of ly as + 2 * n + 12 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2229 |
start_of ly as + 2 * n + 13 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2230 |
start_of ly as + 2 * n + 14 \<noteq> start_of ly e \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2231 |
start_of ly as + 2 * n + 15 \<noteq> start_of ly e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2232 |
using start_of_ge[of as aprog n e ly] start_of_less[of e as ly] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2233 |
apply(case_tac "e < as", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2234 |
apply(case_tac "e = as", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2235 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2236 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2237 |
lemma inv_locate_b_nonempty[simp]: "inv_locate_b (as, lm) (n, [], []) ires = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2238 |
apply(auto simp: inv_locate_b.simps in_middle.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2239 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2240 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2241 |
lemma inv_locate_b_no_Bk[simp]: "inv_locate_b (as, lm) (n, [], Bk # list) ires = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2242 |
apply(auto simp: inv_locate_b.simps in_middle.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2243 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2244 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2245 |
lemma dec_first_on_right_moving_Oc[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2246 |
"\<lbrakk>dec_first_on_right_moving n (as, am) (s, aaa, Oc # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2247 |
\<Longrightarrow> dec_first_on_right_moving n (as, am) (s', Oc # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2248 |
apply(simp only: dec_first_on_right_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2249 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2250 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2251 |
rule_tac x = m in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2252 |
apply(rule_tac x = "Suc ml" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2253 |
rule_tac x = "mr - 1" in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2254 |
apply(case_tac [!] mr, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2255 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2256 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2257 |
lemma dec_first_on_right_moving_Bk_nonempty[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2258 |
"dec_first_on_right_moving n (as, am) (s, l, Bk # xs) ires \<Longrightarrow> l \<noteq> []" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2259 |
apply(auto simp: dec_first_on_right_moving.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2260 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2261 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2262 |
lemma replicateE[elim]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2263 |
"\<lbrakk>\<not> length lm1 < length am; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2264 |
am @ replicate (length lm1 - length am) 0 @ [0::nat] = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2265 |
lm1 @ m # lm2; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2266 |
0 < m\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2267 |
\<Longrightarrow> RR" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2268 |
apply(subgoal_tac "lm2 = []", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2269 |
apply(drule_tac length_equal, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2270 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2271 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2272 |
lemma dec_after_clear_Bk_strip_hd[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2273 |
"\<lbrakk>dec_first_on_right_moving n (as, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2274 |
abc_lm_s am n (abc_lm_v am n)) (s, l, Bk # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2275 |
\<Longrightarrow> dec_after_clear (as, abc_lm_s am n |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2276 |
(abc_lm_v am n - Suc 0)) (s', tl l, hd l # Bk # xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2277 |
apply(simp only: dec_first_on_right_moving.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2278 |
dec_after_clear.simps abc_lm_s.simps abc_lm_v.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2279 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2280 |
apply(case_tac "n < length am") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2281 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2282 |
rule_tac x = "m - 1" in exI, auto simp: ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2283 |
apply(case_tac [!] mr, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2284 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2285 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2286 |
lemma dec_first_on_right_moving_dec_after_clear_cases[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2287 |
"\<lbrakk>dec_first_on_right_moving n (as, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2288 |
abc_lm_s am n (abc_lm_v am n)) (s, l, []) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2289 |
\<Longrightarrow> (l = [] \<longrightarrow> dec_after_clear (as, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2290 |
abc_lm_s am n (abc_lm_v am n - Suc 0)) (s', [], [Bk]) ires) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2291 |
(l \<noteq> [] \<longrightarrow> dec_after_clear (as, abc_lm_s am n |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2292 |
(abc_lm_v am n - Suc 0)) (s', tl l, [hd l]) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2293 |
apply(subgoal_tac "l \<noteq> []", |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2294 |
simp only: dec_first_on_right_moving.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2295 |
dec_after_clear.simps abc_lm_s.simps abc_lm_v.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2296 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2297 |
apply(case_tac "n < length am", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2298 |
apply(rule_tac x = lm1 in exI, rule_tac x = "m - 1" in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2299 |
apply(case_tac [1-2] m, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2300 |
apply(auto simp: dec_first_on_right_moving.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2301 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2302 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2303 |
lemma dec_after_clear_Bk_via_Oc[simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, Oc # r) ires\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2304 |
\<Longrightarrow> dec_after_clear (as, am) (s', l, Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2305 |
apply(auto simp: dec_after_clear.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2306 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2307 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2308 |
lemma dec_right_move_Bk_via_clear_Bk[simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, Bk # r) ires\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2309 |
\<Longrightarrow> dec_right_move (as, am) (s', Bk # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2310 |
apply(auto simp: dec_after_clear.simps dec_right_move.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2311 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2312 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2313 |
lemma dec_right_move_Bk_Bk_via_clear[simp]: "\<lbrakk>dec_after_clear (as, am) (s, l, []) ires\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2314 |
\<Longrightarrow> dec_right_move (as, am) (s', Bk # l, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2315 |
apply(auto simp: dec_after_clear.simps dec_right_move.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2316 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2317 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2318 |
lemma dec_right_move_no_Oc[simp]:"dec_right_move (as, am) (s, l, Oc # r) ires = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2319 |
apply(auto simp: dec_right_move.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2320 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2321 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2322 |
lemma dec_right_move_2_check_right_move[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2323 |
"\<lbrakk>dec_right_move (as, am) (s, l, Bk # r) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2324 |
\<Longrightarrow> dec_check_right_move (as, am) (s', Bk # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2325 |
apply(auto simp: dec_right_move.simps dec_check_right_move.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2326 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2327 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2328 |
lemma lm_iff_empty[simp]: "(<lm::nat list> = []) = (lm = [])" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2329 |
apply(case_tac lm, simp_all add: tape_of_nl_cons) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2330 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2331 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2332 |
lemma dec_right_move_asif_Bk_singleton[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2333 |
"dec_right_move (as, am) (s, l, []) ires= |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2334 |
dec_right_move (as, am) (s, l, [Bk]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2335 |
apply(simp add: dec_right_move.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2336 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2337 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2338 |
lemma dec_check_right_move_nonempty[simp]: "dec_check_right_move (as, am) (s, l, r) ires\<Longrightarrow> l \<noteq> []" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2339 |
apply(auto simp: dec_check_right_move.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2340 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2341 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2342 |
lemma dec_check_right_move_Oc_tail[simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, Oc # r) ires\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2343 |
\<Longrightarrow> dec_after_write (as, am) (s', tl l, hd l # Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2344 |
apply(auto simp: dec_check_right_move.simps dec_after_write.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2345 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2346 |
rule_tac x = m in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2347 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2348 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2349 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2350 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2351 |
lemma dec_left_move_Bk_tail[simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, Bk # r) ires\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2352 |
\<Longrightarrow> dec_left_move (as, am) (s', tl l, hd l # Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2353 |
apply(auto simp: dec_check_right_move.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2354 |
dec_left_move.simps inv_after_move.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2355 |
apply(rule_tac x = lm1 in exI, rule_tac x = m in exI, auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2356 |
apply(case_tac [!] lm2, simp_all add: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2357 |
apply(rule_tac [!] x = "(Suc rn)" in exI, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2358 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2359 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2360 |
lemma dec_left_move_tail[simp]: "\<lbrakk>dec_check_right_move (as, am) (s, l, []) ires\<rbrakk> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2361 |
\<Longrightarrow> dec_left_move (as, am) (s', tl l, [hd l]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2362 |
apply(auto simp: dec_check_right_move.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2363 |
dec_left_move.simps inv_after_move.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2364 |
apply(rule_tac x = lm1 in exI, rule_tac x = m in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2365 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2366 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2367 |
lemma dec_left_move_no_Oc[simp]: "dec_left_move (as, am) (s, aaa, Oc # xs) ires = False" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2368 |
apply(auto simp: dec_left_move.simps inv_after_move.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2369 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2370 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2371 |
lemma dec_left_move_nonempty[simp]: "dec_left_move (as, am) (s, l, r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2372 |
\<Longrightarrow> l \<noteq> []" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2373 |
apply(auto simp: dec_left_move.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2374 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2375 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2376 |
lemma inv_on_left_moving_in_middle_B_Oc_Bk_Bks[simp]: "inv_on_left_moving_in_middle_B (as, [m]) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2377 |
(s', Oc # Oc\<up>m @ Bk # Bk # ires, Bk # Bk\<up>rn) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2378 |
apply(simp add: inv_on_left_moving_in_middle_B.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2379 |
apply(rule_tac x = "[m]" in exI, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2380 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2381 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2382 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2383 |
lemma inv_on_left_moving_in_middle_B_Oc_Bk_Bks_rev[simp]: "lm1 \<noteq> [] \<Longrightarrow> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2384 |
inv_on_left_moving_in_middle_B (as, lm1 @ [m]) (s', |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2385 |
Oc # Oc\<up>m @ Bk # <rev lm1> @ Bk # Bk # ires, Bk # Bk\<up>rn) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2386 |
apply(simp only: inv_on_left_moving_in_middle_B.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2387 |
apply(rule_tac x = "lm1 @ [m ]" in exI, rule_tac x = "[]" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2388 |
apply(simp add: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2389 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2390 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2391 |
lemma inv_on_left_moving_Bk_tail[simp]: "dec_left_move (as, am) (s, l, Bk # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2392 |
\<Longrightarrow> inv_on_left_moving (as, am) (s', tl l, hd l # Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2393 |
apply(auto simp: dec_left_move.simps inv_on_left_moving.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2394 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2395 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2396 |
lemma inv_on_left_moving_tail[simp]: "dec_left_move (as, am) (s, l, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2397 |
\<Longrightarrow> inv_on_left_moving (as, am) (s', tl l, [hd l]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2398 |
apply(auto simp: dec_left_move.simps inv_on_left_moving.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2399 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2400 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2401 |
lemma dec_on_right_moving_Oc_mv[simp]: "dec_after_write (as, am) (s, l, Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2402 |
\<Longrightarrow> dec_on_right_moving (as, am) (s', Oc # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2403 |
apply(auto simp: dec_after_write.simps dec_on_right_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2404 |
apply(rule_tac x = "lm1 @ [m]" in exI, rule_tac x = "tl lm2" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2405 |
rule_tac x = "hd lm2" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2406 |
apply(rule_tac x = "Suc 0" in exI,rule_tac x = "Suc (hd lm2)" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2407 |
apply(case_tac lm2, auto split: if_splits simp: tape_of_nl_cons) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2408 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2409 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2410 |
lemma dec_after_write_Oc_via_Bk[simp]: "dec_after_write (as, am) (s, l, Bk # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2411 |
\<Longrightarrow> dec_after_write (as, am) (s', l, Oc # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2412 |
apply(auto simp: dec_after_write.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2413 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2414 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2415 |
lemma dec_after_write_Oc_empty[simp]: "dec_after_write (as, am) (s, aaa, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2416 |
\<Longrightarrow> dec_after_write (as, am) (s', aaa, [Oc]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2417 |
apply(auto simp: dec_after_write.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2418 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2419 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2420 |
lemma dec_on_right_moving_Oc_move[simp]: "dec_on_right_moving (as, am) (s, l, Oc # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2421 |
\<Longrightarrow> dec_on_right_moving (as, am) (s', Oc # l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2422 |
apply(simp only: dec_on_right_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2423 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2424 |
apply(erule conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2425 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2426 |
rule_tac x = "m" in exI, rule_tac x = "Suc ml" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2427 |
rule_tac x = "mr - 1" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2428 |
apply(case_tac mr, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2429 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2430 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2431 |
lemma dec_on_right_moving_nonempty[simp]: "dec_on_right_moving (as, am) (s, l, r) ires\<Longrightarrow> l \<noteq> []" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2432 |
apply(auto simp: dec_on_right_moving.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2433 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2434 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2435 |
lemma dec_after_clear_Bk_tail[simp]: "dec_on_right_moving (as, am) (s, l, Bk # r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2436 |
\<Longrightarrow> dec_after_clear (as, am) (s', tl l, hd l # Bk # r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2437 |
apply(auto simp: dec_on_right_moving.simps dec_after_clear.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2438 |
apply(case_tac [!] mr, auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2439 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2440 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2441 |
lemma dec_after_clear_tail[simp]: "dec_on_right_moving (as, am) (s, l, []) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2442 |
\<Longrightarrow> dec_after_clear (as, am) (s', tl l, [hd l]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2443 |
apply(auto simp: dec_on_right_moving.simps dec_after_clear.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2444 |
apply(simp_all split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2445 |
apply(rule_tac x = lm1 in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2446 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2447 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2448 |
lemma dec_false_1[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2449 |
"\<lbrakk>abc_lm_v am n = 0; inv_locate_b (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2450 |
\<Longrightarrow> False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2451 |
apply(auto simp: inv_locate_b.simps in_middle.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2452 |
apply(case_tac "length lm1 \<ge> length am", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2453 |
apply(subgoal_tac "lm2 = []", simp, subgoal_tac "m = 0", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2454 |
apply(case_tac mr, auto simp: ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2455 |
apply(subgoal_tac "Suc (length lm1) - length am = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2456 |
Suc (length lm1 - length am)", |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2457 |
simp add: exp_ind del: replicate.simps, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2458 |
apply(drule_tac xs = "am @ replicate (Suc (length lm1) - length am) 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2459 |
and ys = "lm1 @ m # lm2" in length_equal, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2460 |
apply(case_tac mr, auto simp: abc_lm_v.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2461 |
apply(case_tac "mr = 0", simp_all split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2462 |
apply(subgoal_tac "Suc (length lm1) - length am = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2463 |
Suc (length lm1 - length am)", |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2464 |
simp add: exp_ind del: replicate.simps, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2465 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2466 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2467 |
lemma inv_on_left_moving_Bk_tl[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2468 |
"\<lbrakk>inv_locate_b (as, am) (n, aaa, Bk # xs) ires; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2469 |
abc_lm_v am n = 0\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2470 |
\<Longrightarrow> inv_on_left_moving (as, abc_lm_s am n 0) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2471 |
(s, tl aaa, hd aaa # Bk # xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2472 |
apply(simp add: inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2473 |
apply(simp only: inv_locate_b.simps in_middle.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2474 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2475 |
apply(simp add: inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2476 |
apply(subgoal_tac "\<not> inv_on_left_moving_in_middle_B |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2477 |
(as, abc_lm_s am n 0) (s, tl aaa, hd aaa # Bk # xs) ires", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2478 |
apply(simp only: inv_on_left_moving_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2479 |
apply(erule_tac conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2480 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2481 |
rule_tac x = m in exI, rule_tac x = m in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2482 |
rule_tac x = "Suc 0" in exI, simp add: abc_lm_s.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2483 |
apply(case_tac mr, simp_all, auto simp: abc_lm_v.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2484 |
apply(simp only: exp_ind[THEN sym] replicate_Suc Nat.Suc_diff_le) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2485 |
apply(auto simp: inv_on_left_moving_in_middle_B.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2486 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2487 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2488 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2489 |
lemma inv_on_left_moving_tl[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2490 |
"\<lbrakk>abc_lm_v am n = 0; inv_locate_b (as, am) (n, aaa, []) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2491 |
\<Longrightarrow> inv_on_left_moving (as, abc_lm_s am n 0) (s, tl aaa, [hd aaa]) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2492 |
apply(simp add: inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2493 |
apply(simp only: inv_locate_b.simps in_middle.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2494 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2495 |
apply(simp add: inv_on_left_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2496 |
apply(subgoal_tac "\<not> inv_on_left_moving_in_middle_B |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2497 |
(as, abc_lm_s am n 0) (s, tl aaa, [hd aaa]) ires", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2498 |
apply(simp only: inv_on_left_moving_norm.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2499 |
apply(erule_tac conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2500 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2501 |
rule_tac x = m in exI, rule_tac x = m in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2502 |
rule_tac x = "Suc 0" in exI, simp add: abc_lm_s.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2503 |
apply(case_tac mr, simp_all, auto simp: abc_lm_v.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2504 |
apply(simp_all only: exp_ind Nat.Suc_diff_le del: replicate_Suc, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2505 |
apply(auto simp: inv_on_left_moving_in_middle_B.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2506 |
apply(case_tac [!] m, simp_all) |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
2507 |
done |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2508 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2509 |
declare dec_inv_1.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2510 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2511 |
declare inv_locate_n_b.simps [simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2512 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2513 |
lemma dec_first_on_right_moving_Oc_via_inv_locate_n_b[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2514 |
"\<lbrakk>inv_locate_n_b (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2515 |
\<Longrightarrow> dec_first_on_right_moving n (as, abc_lm_s am n (abc_lm_v am n)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2516 |
(s, Oc # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2517 |
apply(auto simp: inv_locate_n_b.simps dec_first_on_right_moving.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2518 |
abc_lm_s.simps abc_lm_v.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2519 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2520 |
rule_tac x = m in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2521 |
apply(rule_tac x = "Suc (Suc 0)" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2522 |
rule_tac x = "m - 1" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2523 |
apply(case_tac m, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2524 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2525 |
rule_tac x = m in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2526 |
simp add: Suc_diff_le exp_ind del: replicate.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2527 |
apply(rule_tac x = "Suc (Suc 0)" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2528 |
rule_tac x = "m - 1" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2529 |
apply(case_tac m, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2530 |
apply(rule_tac x = lm1 in exI, rule_tac x = "[]" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2531 |
rule_tac x = m in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2532 |
apply(rule_tac x = "Suc (Suc 0)" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2533 |
rule_tac x = "m - 1" in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2534 |
apply(case_tac m, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2535 |
apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2536 |
rule_tac x = m in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2537 |
simp add: Suc_diff_le exp_ind del: replicate.simps, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2538 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2539 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2540 |
lemma inv_on_left_moving_nonempty[simp]: "inv_on_left_moving (as, am) (s, [], r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2541 |
= False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2542 |
apply(simp add: inv_on_left_moving.simps inv_on_left_moving_norm.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2543 |
inv_on_left_moving_in_middle_B.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2544 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2545 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2546 |
lemma inv_check_left_moving_startof_nonempty[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2547 |
"inv_check_left_moving (as, abc_lm_s am n 0) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2548 |
(start_of (layout_of aprog) as + 2 * n + 14, [], Oc # xs) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2549 |
= False" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2550 |
apply(simp add: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2551 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2552 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2553 |
lemma start_of_lessE[elim]: "\<lbrakk>abc_fetch as ap = Some (Dec n e); |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2554 |
start_of (layout_of ap) as < start_of (layout_of ap) e; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2555 |
start_of (layout_of ap) e \<le> Suc (start_of (layout_of ap) as + 2 * n)\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2556 |
\<Longrightarrow> RR" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2557 |
using start_of_less[of e as "layout_of ap"] start_of_ge[of as ap n e "layout_of ap"] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2558 |
apply(case_tac "as < e", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2559 |
apply(case_tac "as = e", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2560 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2561 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2562 |
lemma crsp_step_dec_b_e_pre': |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2563 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2564 |
and inv_start: "inv_locate_b (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2565 |
and fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2566 |
and dec_0: "abc_lm_v lm n = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2567 |
and f: "f = (\<lambda> stp. (steps (Suc (start_of ly as) + 2 * n, la, ra) (ci ly (start_of ly as) (Dec n e), |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2568 |
start_of ly as - Suc 0) stp, start_of ly as, n))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2569 |
and P: "P = (\<lambda> ((s, l, r), ss, x). s = start_of ly e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2570 |
and Q: "Q = (\<lambda> ((s, l, r), ss, x). dec_inv_1 ly x e (as, lm) (s, l, r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2571 |
shows "\<exists> stp. P (f stp) \<and> Q (f stp)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2572 |
proof(rule_tac LE = abc_dec_1_LE in halt_lemma2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2573 |
show "wf abc_dec_1_LE" by(intro wf_dec_le) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2574 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2575 |
show "Q (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2576 |
using layout fetch |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2577 |
apply(simp add: f steps.simps Q dec_inv_1.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2578 |
apply(subgoal_tac "e > as \<or> e = as \<or> e < as") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2579 |
apply(auto simp: Let_def start_of_ge start_of_less inv_start) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2580 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2581 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2582 |
show "\<not> P (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2583 |
using layout fetch |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2584 |
apply(simp add: f steps.simps P) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2585 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2586 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2587 |
show "\<forall>n. \<not> P (f n) \<and> Q (f n) \<longrightarrow> Q (f (Suc n)) \<and> (f (Suc n), f n) \<in> abc_dec_1_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2588 |
using fetch |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2589 |
proof(rule_tac allI, rule_tac impI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2590 |
fix na |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2591 |
assume "\<not> P (f na) \<and> Q (f na)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2592 |
thus "Q (f (Suc na)) \<and> (f (Suc na), f na) \<in> abc_dec_1_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2593 |
apply(simp add: f) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2594 |
apply(case_tac "steps (Suc (start_of ly as + 2 * n), la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2595 |
(ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0) na", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2596 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2597 |
fix a b c |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2598 |
assume "\<not> P ((a, b, c), start_of ly as, n) \<and> Q ((a, b, c), start_of ly as, n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2599 |
thus "Q (step (a, b, c) (ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0), start_of ly as, n) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2600 |
((step (a, b, c) (ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0), start_of ly as, n), |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2601 |
(a, b, c), start_of ly as, n) \<in> abc_dec_1_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2602 |
apply(simp add: Q) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2603 |
apply(case_tac c, case_tac [2] aa) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2604 |
apply(simp_all add: dec_inv_1.simps Let_def split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2605 |
using fetch layout dec_0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2606 |
apply(auto simp: step.simps P dec_inv_1.simps Let_def abc_dec_1_LE_def lex_triple_def lex_pair_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2607 |
using dec_0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2608 |
apply(drule_tac dec_false_1, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2609 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2610 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2611 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2612 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2613 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2614 |
lemma crsp_step_dec_b_e_pre: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2615 |
assumes "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2616 |
and inv_start: "inv_locate_b (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2617 |
and dec_0: "abc_lm_v lm n = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2618 |
and fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2619 |
shows "\<exists>stp lb rb. |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2620 |
steps (Suc (start_of ly as) + 2 * n, la, ra) (ci ly (start_of ly as) (Dec n e), |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2621 |
start_of ly as - Suc 0) stp = (start_of ly e, lb, rb) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2622 |
dec_inv_1 ly n e (as, lm) (start_of ly e, lb, rb) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2623 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2624 |
apply(drule_tac crsp_step_dec_b_e_pre', auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2625 |
apply(rule_tac x = stp in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2626 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2627 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2628 |
lemma crsp_abc_step_via_stop[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2629 |
"\<lbrakk>abc_lm_v lm n = 0; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2630 |
inv_stop (as, abc_lm_s lm n (abc_lm_v lm n)) (start_of ly e, lb, rb) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2631 |
\<Longrightarrow> crsp ly (abc_step_l (as, lm) (Some (Dec n e))) (start_of ly e, lb, rb) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2632 |
apply(auto simp: crsp.simps abc_step_l.simps inv_stop.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2633 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2634 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2635 |
lemma crsp_step_dec_b_e: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2636 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2637 |
and inv_start: "inv_locate_a (as, lm) (n, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2638 |
and dec_0: "abc_lm_v lm n = 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2639 |
and fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2640 |
shows "\<exists>stp > 0. crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2641 |
(steps (start_of ly as + 2 * n, l, r) (ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0) stp) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2642 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2643 |
let ?P = "ci ly (start_of ly as) (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2644 |
let ?off = "start_of ly as - Suc 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2645 |
have "\<exists> stp la ra. steps (start_of ly as + 2 * n, l, r) (?P, ?off) stp = (Suc (start_of ly as) + 2*n, la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2646 |
\<and> inv_locate_b (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2647 |
using inv_start |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2648 |
apply(case_tac "r = [] \<or> hd r = Bk", simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2649 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2650 |
from this obtain stpa la ra where a: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2651 |
"steps (start_of ly as + 2 * n, l, r) (?P, ?off) stpa = (Suc (start_of ly as) + 2*n, la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2652 |
\<and> inv_locate_b (as, lm) (n, la, ra) ires" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2653 |
have "\<exists> stp lb rb. steps (Suc (start_of ly as) + 2 * n, la, ra) (?P, ?off) stp = (start_of ly e, lb, rb) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2654 |
\<and> dec_inv_1 ly n e (as, lm) (start_of ly e, lb, rb) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2655 |
using assms a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2656 |
apply(rule_tac crsp_step_dec_b_e_pre, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2657 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2658 |
from this obtain stpb lb rb where b: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2659 |
"steps (Suc (start_of ly as) + 2 * n, la, ra) (?P, ?off) stpb = (start_of ly e, lb, rb) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2660 |
\<and> dec_inv_1 ly n e (as, lm) (start_of ly e, lb, rb) ires" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2661 |
from a b show "\<exists>stp > 0. crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2662 |
(steps (start_of ly as + 2 * n, l, r) (?P, ?off) stp) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2663 |
apply(rule_tac x = "stpa + stpb" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2664 |
apply(simp add: steps_add) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2665 |
using dec_0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2666 |
apply(simp add: dec_inv_1.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2667 |
apply(case_tac stpa, simp_all add: steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2668 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2669 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2670 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2671 |
fun dec_inv_2 :: "layout \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> dec_inv_t" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2672 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2673 |
"dec_inv_2 ly n e (as, am) (s, l, r) ires = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2674 |
(let ss = start_of ly as in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2675 |
let am' = abc_lm_s am n (abc_lm_v am n - Suc 0) in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2676 |
let am'' = abc_lm_s am n (abc_lm_v am n) in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2677 |
if s = 0 then False |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2678 |
else if s = ss + 2 * n then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2679 |
inv_locate_a (as, am) (n, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2680 |
else if s = ss + 2 * n + 1 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2681 |
inv_locate_n_b (as, am) (n, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2682 |
else if s = ss + 2 * n + 2 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2683 |
dec_first_on_right_moving n (as, am'') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2684 |
else if s = ss + 2 * n + 3 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2685 |
dec_after_clear (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2686 |
else if s = ss + 2 * n + 4 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2687 |
dec_right_move (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2688 |
else if s = ss + 2 * n + 5 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2689 |
dec_check_right_move (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2690 |
else if s = ss + 2 * n + 6 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2691 |
dec_left_move (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2692 |
else if s = ss + 2 * n + 7 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2693 |
dec_after_write (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2694 |
else if s = ss + 2 * n + 8 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2695 |
dec_on_right_moving (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2696 |
else if s = ss + 2 * n + 9 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2697 |
dec_after_clear (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2698 |
else if s = ss + 2 * n + 10 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2699 |
inv_on_left_moving (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2700 |
else if s = ss + 2 * n + 11 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2701 |
inv_check_left_moving (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2702 |
else if s = ss + 2 * n + 12 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2703 |
inv_after_left_moving (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2704 |
else if s = ss + 2 * n + 16 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2705 |
inv_stop (as, am') (s, l, r) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2706 |
else False)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2707 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2708 |
declare dec_inv_2.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2709 |
fun abc_dec_2_stage1 :: "config \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2710 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2711 |
"abc_dec_2_stage1 (s, l, r) ss n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2712 |
(if s \<le> ss + 2*n + 1 then 7 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2713 |
else if s = ss + 2*n + 2 then 6 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2714 |
else if s = ss + 2*n + 3 then 5 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2715 |
else if s \<ge> ss + 2*n + 4 \<and> s \<le> ss + 2*n + 9 then 4 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2716 |
else if s = ss + 2*n + 6 then 3 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2717 |
else if s = ss + 2*n + 10 \<or> s = ss + 2*n + 11 then 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2718 |
else if s = ss + 2*n + 12 then 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2719 |
else 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2720 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2721 |
fun abc_dec_2_stage2 :: "config \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2722 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2723 |
"abc_dec_2_stage2 (s, l, r) ss n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2724 |
(if s \<le> ss + 2 * n + 1 then (ss + 2 * n + 16 - s) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2725 |
else if s = ss + 2*n + 10 then length l |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2726 |
else if s = ss + 2*n + 11 then length l |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2727 |
else if s = ss + 2*n + 4 then length r - 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2728 |
else if s = ss + 2*n + 5 then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2729 |
else if s = ss + 2*n + 7 then length r - 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2730 |
else if s = ss + 2*n + 8 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2731 |
length r + length (takeWhile (\<lambda> a. a = Oc) l) - 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2732 |
else if s = ss + 2*n + 9 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2733 |
length r + length (takeWhile (\<lambda> a. a = Oc) l) - 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2734 |
else 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2735 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2736 |
fun abc_dec_2_stage3 :: "config \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2737 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2738 |
"abc_dec_2_stage3 (s, l, r) ss n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2739 |
(if s \<le> ss + 2*n + 1 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2740 |
if (s - ss) mod 2 = 0 then if r \<noteq> [] \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2741 |
hd r = Oc then 0 else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2742 |
else length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2743 |
else if s = ss + 2 * n + 10 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2744 |
if r \<noteq> [] \<and> hd r = Oc then 2 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2745 |
else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2746 |
else if s = ss + 2 * n + 11 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2747 |
if r \<noteq> [] \<and> hd r = Oc then 3 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2748 |
else 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2749 |
else (ss + 2 * n + 16 - s))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2750 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2751 |
fun abc_dec_2_stage4 :: "config \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2752 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2753 |
"abc_dec_2_stage4 (s, l, r) ss n = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2754 |
(if s = ss + 2*n + 2 then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2755 |
else if s = ss + 2*n + 8 then length r |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2756 |
else if s = ss + 2*n + 3 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2757 |
if r \<noteq> [] \<and> hd r = Oc then 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2758 |
else 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2759 |
else if s = ss + 2*n + 7 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2760 |
if r \<noteq> [] \<and> hd r = Oc then 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2761 |
else 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2762 |
else if s = ss + 2*n + 9 then |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2763 |
if r \<noteq> [] \<and> hd r = Oc then 1 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2764 |
else 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2765 |
else 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2766 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2767 |
fun abc_dec_2_measure :: "(config \<times> nat \<times> nat) \<Rightarrow> (nat \<times> nat \<times> nat \<times> nat)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2768 |
where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2769 |
"abc_dec_2_measure (c, ss, n) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2770 |
(abc_dec_2_stage1 c ss n, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2771 |
abc_dec_2_stage2 c ss n, abc_dec_2_stage3 c ss n, abc_dec_2_stage4 c ss n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2772 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2773 |
definition lex_square:: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2774 |
"((nat \<times> nat \<times> nat \<times> nat) \<times> (nat \<times> nat \<times> nat \<times> nat)) set" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2775 |
where "lex_square \<equiv> less_than <*lex*> lex_triple" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2776 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2777 |
definition abc_dec_2_LE :: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2778 |
"((config \<times> nat \<times> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2779 |
nat) \<times> (config \<times> nat \<times> nat)) set" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2780 |
where "abc_dec_2_LE \<equiv> (inv_image lex_square abc_dec_2_measure)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2781 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2782 |
lemma wf_dec2_le: "wf abc_dec_2_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2783 |
by(auto intro:wf_inv_image simp:abc_dec_2_LE_def lex_square_def lex_triple_def lex_pair_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2784 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2785 |
lemma fix_add: "fetch ap ((x::nat) + 2*n) b = fetch ap (2*n + x) b" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2786 |
using Suc_1 add.commute by metis |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2787 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2788 |
lemma inv_locate_n_b_Bk_elim[elim]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2789 |
"\<lbrakk>0 < abc_lm_v am n; inv_locate_n_b (as, am) (n, aaa, Bk # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2790 |
\<Longrightarrow> RR" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2791 |
apply(auto simp: inv_locate_n_b.simps abc_lm_v.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2792 |
apply(case_tac [!] m, auto) |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2793 |
done |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2794 |
|
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2795 |
lemma inv_locate_n_b_nonemptyE[elim]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2796 |
"\<lbrakk>0 < abc_lm_v am n; inv_locate_n_b (as, am) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2797 |
(n, aaa, []) ires\<rbrakk> \<Longrightarrow> RR" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2798 |
apply(auto simp: inv_locate_n_b.simps abc_lm_v.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2799 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2800 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2801 |
lemma no_Ocs_dec_after_write[simp]: "dec_after_write (as, am) (s, aa, r) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2802 |
\<Longrightarrow> takeWhile (\<lambda>a. a = Oc) aa = []" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2803 |
apply(simp only : dec_after_write.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2804 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2805 |
apply(erule_tac conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2806 |
apply(case_tac aa, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2807 |
apply(case_tac a, simp only: takeWhile.simps , simp_all split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2808 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2809 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2810 |
lemma fewer_Ocs_dec_on_right_moving[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2811 |
"\<lbrakk>dec_on_right_moving (as, lm) (s, aa, []) ires; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2812 |
length (takeWhile (\<lambda>a. a = Oc) (tl aa)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2813 |
\<noteq> length (takeWhile (\<lambda>a. a = Oc) aa) - Suc 0\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2814 |
\<Longrightarrow> length (takeWhile (\<lambda>a. a = Oc) (tl aa)) < |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2815 |
length (takeWhile (\<lambda>a. a = Oc) aa) - Suc 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2816 |
apply(simp only: dec_on_right_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2817 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2818 |
apply(erule_tac conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2819 |
apply(case_tac mr, auto split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2820 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2821 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2822 |
lemma more_Ocs_dec_after_clear[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2823 |
"dec_after_clear (as, abc_lm_s am n (abc_lm_v am n - Suc 0)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2824 |
(start_of (layout_of aprog) as + 2 * n + 9, aa, Bk # xs) ires |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2825 |
\<Longrightarrow> length xs - Suc 0 < length xs + |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2826 |
length (takeWhile (\<lambda>a. a = Oc) aa)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2827 |
apply(simp only: dec_after_clear.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2828 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2829 |
apply(erule conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2830 |
apply(simp split: if_splits ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2831 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2832 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2833 |
lemma more_Ocs_dec_after_clear2[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2834 |
"\<lbrakk>dec_after_clear (as, abc_lm_s am n (abc_lm_v am n - Suc 0)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2835 |
(start_of (layout_of aprog) as + 2 * n + 9, aa, []) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2836 |
\<Longrightarrow> Suc 0 < length (takeWhile (\<lambda>a. a = Oc) aa)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2837 |
apply(simp add: dec_after_clear.simps split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2838 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2839 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2840 |
lemma inv_check_left_moving_nonemptyE[elim]: |
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2841 |
"inv_check_left_moving (as, lm) (s, [], Oc # xs) ires |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2842 |
\<Longrightarrow> RR" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2843 |
apply(simp add: inv_check_left_moving.simps inv_check_left_moving_in_middle.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2844 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2845 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2846 |
lemma inv_locate_n_b_Oc_via_at_begin_norm[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2847 |
"\<lbrakk>0 < abc_lm_v am n; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2848 |
at_begin_norm (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2849 |
\<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2850 |
apply(simp only: at_begin_norm.simps inv_locate_n_b.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2851 |
apply(erule_tac exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2852 |
apply(rule_tac x = lm1 in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2853 |
apply(case_tac "length lm2", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2854 |
apply(case_tac "lm2", simp, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2855 |
apply(case_tac "lm2", auto simp: tape_of_nl_cons split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2856 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2857 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2858 |
lemma inv_locate_n_b_Oc_via_at_begin_fst_awtn[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2859 |
"\<lbrakk>0 < abc_lm_v am n; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2860 |
at_begin_fst_awtn (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2861 |
\<Longrightarrow> inv_locate_n_b (as, am) (n, Oc # aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2862 |
apply(simp only: at_begin_fst_awtn.simps inv_locate_n_b.simps ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2863 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2864 |
apply(erule conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2865 |
apply(rule_tac x = lm1 in exI, rule_tac x = "[]" in exI, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2866 |
rule_tac x = "Suc tn" in exI, rule_tac x = 0 in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2867 |
apply(simp add: exp_ind del: replicate.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2868 |
apply(rule conjI)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2869 |
apply(auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2870 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2871 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2872 |
lemma inv_locate_n_b_Oc_via_inv_locate_n_a[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2873 |
"\<lbrakk>0 < abc_lm_v am n; inv_locate_a (as, am) (n, aaa, Oc # xs) ires\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2874 |
\<Longrightarrow> inv_locate_n_b (as, am) (n, Oc#aaa, xs) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2875 |
apply(auto simp: inv_locate_a.simps at_begin_fst_bwtn.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2876 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2877 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2878 |
lemma more_Oc_dec_on_right_moving[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2879 |
"\<lbrakk>dec_on_right_moving (as, am) (s, aa, Bk # xs) ires; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2880 |
Suc (length (takeWhile (\<lambda>a. a = Oc) (tl aa))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2881 |
\<noteq> length (takeWhile (\<lambda>a. a = Oc) aa)\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2882 |
\<Longrightarrow> Suc (length (takeWhile (\<lambda>a. a = Oc) (tl aa))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2883 |
< length (takeWhile (\<lambda>a. a = Oc) aa)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2884 |
apply(simp only: dec_on_right_moving.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2885 |
apply(erule exE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2886 |
apply(erule conjE)+ |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2887 |
apply(case_tac ml, auto split: if_splits ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2888 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2889 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2890 |
lemma crsp_step_dec_b_suc_pre: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2891 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2892 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2893 |
and inv_start: "inv_locate_a (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2894 |
and fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2895 |
and dec_suc: "0 < abc_lm_v lm n" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2896 |
and f: "f = (\<lambda> stp. (steps (start_of ly as + 2 * n, la, ra) (ci ly (start_of ly as) (Dec n e), |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2897 |
start_of ly as - Suc 0) stp, start_of ly as, n))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2898 |
and P: "P = (\<lambda> ((s, l, r), ss, x). s = start_of ly as + 2*n + 16)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2899 |
and Q: "Q = (\<lambda> ((s, l, r), ss, x). dec_inv_2 ly x e (as, lm) (s, l, r) ires)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2900 |
shows "\<exists> stp. P (f stp) \<and> Q(f stp)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2901 |
proof(rule_tac LE = abc_dec_2_LE in halt_lemma2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2902 |
show "wf abc_dec_2_LE" by(intro wf_dec2_le) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2903 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2904 |
show "Q (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2905 |
using layout fetch inv_start |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2906 |
apply(simp add: f steps.simps Q) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2907 |
apply(simp only: dec_inv_2.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2908 |
apply(auto simp: Let_def start_of_ge start_of_less inv_start dec_inv_2.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2909 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2910 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2911 |
show "\<not> P (f 0)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2912 |
using layout fetch |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2913 |
apply(simp add: f steps.simps P) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2914 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2915 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2916 |
show "\<forall>n. \<not> P (f n) \<and> Q (f n) \<longrightarrow> Q (f (Suc n)) \<and> (f (Suc n), f n) \<in> abc_dec_2_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2917 |
using fetch |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2918 |
proof(rule_tac allI, rule_tac impI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2919 |
fix na |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2920 |
assume "\<not> P (f na) \<and> Q (f na)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2921 |
thus "Q (f (Suc na)) \<and> (f (Suc na), f na) \<in> abc_dec_2_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2922 |
apply(simp add: f) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2923 |
apply(case_tac "steps ((start_of ly as + 2 * n), la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2924 |
(ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0) na", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2925 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2926 |
fix a b c |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2927 |
assume "\<not> P ((a, b, c), start_of ly as, n) \<and> Q ((a, b, c), start_of ly as, n)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2928 |
thus "Q (step (a, b, c) (ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0), start_of ly as, n) \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2929 |
((step (a, b, c) (ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0), start_of ly as, n), |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2930 |
(a, b, c), start_of ly as, n) \<in> abc_dec_2_LE" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2931 |
apply(simp add: Q) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2932 |
apply(erule_tac conjE) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2933 |
apply(case_tac c, case_tac [2] aa) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2934 |
apply(simp_all add: dec_inv_2.simps Let_def) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2935 |
apply(simp_all split: if_splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2936 |
using fetch layout dec_suc |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2937 |
apply(auto simp: step.simps P dec_inv_2.simps Let_def abc_dec_2_LE_def lex_triple_def lex_pair_def lex_square_def |
115
653426ed4b38
started with abacus section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
112
diff
changeset
|
2938 |
fix_add numeral_3_eq_3) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2939 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2940 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2941 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2942 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2943 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2944 |
lemma crsp_abc_step_l_start_of[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2945 |
"\<lbrakk>inv_stop (as, abc_lm_s lm n (abc_lm_v lm n - Suc 0)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2946 |
(start_of (layout_of ap) as + 2 * n + 16, a, b) ires; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2947 |
abc_lm_v lm n > 0; |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2948 |
abc_fetch as ap = Some (Dec n e)\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2949 |
\<Longrightarrow> crsp (layout_of ap) (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2950 |
(start_of (layout_of ap) as + 2 * n + 16, a, b) ires" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2951 |
by(auto simp: inv_stop.simps crsp.simps abc_step_l.simps startof_Suc2) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2952 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2953 |
lemma crsp_step_dec_b_suc: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2954 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2955 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2956 |
and inv_start: "inv_locate_a (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2957 |
and fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2958 |
and dec_suc: "0 < abc_lm_v lm n" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2959 |
shows "\<exists>stp > 0. crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2960 |
(steps (start_of ly as + 2 * n, la, ra) (ci (layout_of ap) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2961 |
(start_of ly as) (Dec n e), start_of ly as - Suc 0) stp) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2962 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2963 |
apply(drule_tac crsp_step_dec_b_suc_pre, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2964 |
apply(rule_tac x = stp in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2965 |
apply(simp add: dec_inv_2.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2966 |
apply(case_tac stp, simp_all add: steps.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2967 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2968 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2969 |
lemma crsp_step_dec_b: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2970 |
assumes layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2971 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2972 |
and inv_start: "inv_locate_a (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2973 |
and fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2974 |
shows "\<exists>stp > 0. crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2975 |
(steps (start_of ly as + 2 * n, la, ra) (ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0) stp) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2976 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2977 |
apply(case_tac "abc_lm_v lm n = 0") |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2978 |
apply(rule_tac crsp_step_dec_b_e, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2979 |
apply(rule_tac crsp_step_dec_b_suc, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2980 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2981 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2982 |
lemma crsp_step_dec: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2983 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2984 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2985 |
and fetch: "abc_fetch as ap = Some (Dec n e)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2986 |
shows "\<exists>stp > 0. crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2987 |
(steps (s, l, r) (ci ly (start_of ly as) (Dec n e), start_of ly as - Suc 0) stp) ires" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2988 |
proof(simp add: ci.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2989 |
let ?off = "start_of ly as - Suc 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2990 |
let ?A = "findnth n" |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
2991 |
let ?B = "adjust (shift (shift tdec_b (2 * n)) ?off) (start_of ly e)" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2992 |
have "\<exists> stp la ra. steps (s, l, r) (shift ?A ?off @ ?B, ?off) stp = (start_of ly as + 2*n, la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2993 |
\<and> inv_locate_a (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2994 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2995 |
have "\<exists>stp l' r'. steps (Suc 0, l, r) (?A, 0) stp = (Suc (2 * n), l', r') \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2996 |
inv_locate_a (as, lm) (n, l', r') ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2997 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2998 |
apply(rule_tac findnth_correct, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
2999 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3000 |
then obtain stp l' r' where a: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3001 |
"steps (Suc 0, l, r) (?A, 0) stp = (Suc (2 * n), l', r') \<and> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3002 |
inv_locate_a (as, lm) (n, l', r') ires" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3003 |
then have "steps (Suc 0 + ?off, l, r) (shift ?A ?off, ?off) stp = (Suc (2 * n) + ?off, l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3004 |
apply(rule_tac tm_shift_eq_steps, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3005 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3006 |
moreover have "s = start_of ly as" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3007 |
using crsp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3008 |
apply(auto simp: crsp.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3009 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3010 |
ultimately show "\<exists> stp la ra. steps (s, l, r) (shift ?A ?off @ ?B, ?off) stp = (start_of ly as + 2*n, la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3011 |
\<and> inv_locate_a (as, lm) (n, la, ra) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3012 |
using a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3013 |
apply(drule_tac B = ?B in tm_append_first_steps_eq, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3014 |
apply(rule_tac x = stp in exI, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3015 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3016 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3017 |
from this obtain stpa la ra where a: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3018 |
"steps (s, l, r) (shift ?A ?off @ ?B, ?off) stpa = (start_of ly as + 2*n, la, ra) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3019 |
\<and> inv_locate_a (as, lm) (n, la, ra) ires" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3020 |
have "\<exists>stp. crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3021 |
(steps (start_of ly as + 2*n, la, ra) (shift ?A ?off @ ?B, ?off) stp) ires \<and> stp > 0" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3022 |
using assms a |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3023 |
apply(drule_tac crsp_step_dec_b, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3024 |
apply(rule_tac x = stp in exI, simp add: ci.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3025 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3026 |
then obtain stpb where b: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3027 |
"crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3028 |
(steps (start_of ly as + 2*n, la, ra) (shift ?A ?off @ ?B, ?off) stpb) ires \<and> stpb > 0" .. |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3029 |
from a b show "\<exists> stp>0. crsp ly (abc_step_l (as, lm) (Some (Dec n e))) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3030 |
(steps (s, l, r) (shift ?A ?off @ ?B, ?off) stp) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3031 |
apply(rule_tac x = "stpa + stpb" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3032 |
apply(simp add: steps_add) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3033 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3034 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3035 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3036 |
subsection{*Crsp of Goto*} |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3037 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3038 |
lemma crsp_step_goto: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3039 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3040 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3041 |
shows "\<exists>stp>0. crsp ly (abc_step_l (as, lm) (Some (Goto n))) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3042 |
(steps (s, l, r) (ci ly (start_of ly as) (Goto n), |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3043 |
start_of ly as - Suc 0) stp) ires" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3044 |
using crsp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3045 |
apply(rule_tac x = "Suc 0" in exI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3046 |
apply(case_tac r, case_tac [2] a) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3047 |
apply(simp_all add: ci.simps steps.simps step.simps crsp.simps fetch.simps |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3048 |
crsp.simps abc_step_l.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3049 |
done |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3050 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3051 |
lemma crsp_step_in: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3052 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3053 |
and compile: "tp = tm_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3054 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3055 |
and fetch: "abc_fetch as ap = Some ins" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3056 |
shows "\<exists> stp>0. crsp ly (abc_step_l (as, lm) (Some ins)) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3057 |
(steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3058 |
using assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3059 |
apply(case_tac ins, simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3060 |
apply(rule crsp_step_inc, simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3061 |
apply(rule crsp_step_dec, simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3062 |
apply(rule_tac crsp_step_goto, simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3063 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3064 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3065 |
lemma crsp_step: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3066 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3067 |
and compile: "tp = tm_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3068 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3069 |
and fetch: "abc_fetch as ap = Some ins" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3070 |
shows "\<exists> stp>0. crsp ly (abc_step_l (as, lm) (Some ins)) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3071 |
(steps (s, l, r) (tp, 0) stp) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3072 |
proof - |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3073 |
have "\<exists> stp>0. crsp ly (abc_step_l (as, lm) (Some ins)) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3074 |
(steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3075 |
using assms |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3076 |
apply(rule_tac crsp_step_in, simp_all) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3077 |
done |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3078 |
from this obtain stp where d: "stp > 0 \<and> crsp ly (abc_step_l (as, lm) (Some ins)) |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3079 |
(steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp) ires" .. |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3080 |
obtain s' l' r' where e: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3081 |
"(steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp) = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3082 |
apply(case_tac "(steps (s, l, r) (ci ly (start_of ly as) ins, start_of ly as - 1) stp)") |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3083 |
by blast |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3084 |
then have "steps (s, l, r) (tp, 0) stp = (s', l', r')" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3085 |
using assms d |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3086 |
apply(rule_tac steps_eq_in) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3087 |
apply(simp_all) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3088 |
apply(case_tac "(abc_step_l (as, lm) (Some ins))", simp add: crsp.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3089 |
done |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3090 |
thus " \<exists>stp>0. crsp ly (abc_step_l (as, lm) (Some ins)) (steps (s, l, r) (tp, 0) stp) ires" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3091 |
using d e |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3092 |
apply(rule_tac x = stp in exI, simp) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3093 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3094 |
qed |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3095 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3096 |
lemma crsp_steps: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3097 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3098 |
and compile: "tp = tm_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3099 |
and crsp: "crsp ly (as, lm) (s, l, r) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3100 |
shows "\<exists> stp. crsp ly (abc_steps_l (as, lm) ap n) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3101 |
(steps (s, l, r) (tp, 0) stp) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3102 |
using crsp |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3103 |
apply(induct n) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3104 |
apply(rule_tac x = 0 in exI) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3105 |
apply(simp add: steps.simps abc_steps_l.simps, simp) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3106 |
apply(case_tac "(abc_steps_l (as, lm) ap n)", auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3107 |
apply(frule_tac abc_step_red, simp) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3108 |
apply(case_tac "abc_fetch a ap", simp add: abc_step_l.simps, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3109 |
apply(case_tac "steps (s, l, r) (tp, 0) stp", simp) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3110 |
using assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3111 |
apply(drule_tac s = ab and l = ba and r = c in crsp_step, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3112 |
apply(rule_tac x = "stp + stpa" in exI, simp add: steps_add) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3113 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3114 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3115 |
lemma tp_correct': |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3116 |
assumes layout: "ly = layout_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3117 |
and compile: "tp = tm_of ap" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3118 |
and crsp: "crsp ly (0, lm) (Suc 0, l, r) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3119 |
and abc_halt: "abc_steps_l (0, lm) ap stp = (length ap, am)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3120 |
shows "\<exists> stp k. steps (Suc 0, l, r) (tp, 0) stp = (start_of ly (length ap), Bk # Bk # ires, <am> @ Bk\<up>k)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3121 |
using assms |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3122 |
apply(drule_tac n = stp in crsp_steps, auto) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3123 |
apply(rule_tac x = stpa in exI) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3124 |
apply(case_tac "steps (Suc 0, l, r) (tm_of ap, 0) stpa", simp add: crsp.simps) |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3125 |
done |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3126 |
|
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3127 |
text{*The tp @ [(Nop, 0), (Nop, 0)] is nomoral turing machines, so we can use Hoare_plus when composing with Mop machine*} |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3128 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3129 |
lemma layout_id_cons: "layout_of (ap @ [p]) = layout_of ap @ [length_of p]" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3130 |
apply(simp add: layout_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3131 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3132 |
|
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
3133 |
lemma map_start_of_layout[simp]: |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3134 |
"map (start_of (layout_of xs @ [length_of x])) [0..<length xs] = (map (start_of (layout_of xs)) [0..<length xs])" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3135 |
apply(auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3136 |
apply(simp add: layout_of.simps start_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3137 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3138 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3139 |
lemma tpairs_id_cons: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3140 |
"tpairs_of (xs @ [x]) = tpairs_of xs @ [(start_of (layout_of (xs @ [x])) (length xs), x)]" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3141 |
apply(auto simp: tpairs_of.simps layout_id_cons ) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3142 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3143 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3144 |
lemma map_length_ci: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3145 |
"(map (length \<circ> (\<lambda>(xa, y). ci (layout_of xs @ [length_of x]) xa y)) (tpairs_of xs)) = |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3146 |
(map (length \<circ> (\<lambda>(x, y). ci (layout_of xs) x y)) (tpairs_of xs)) " |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3147 |
apply(auto) |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
3148 |
apply(case_tac b, auto simp: ci.simps adjust.simps) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3149 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3150 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3151 |
lemma length_tp'[simp]: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3152 |
"\<lbrakk>ly = layout_of ap; tp = tm_of ap\<rbrakk> \<Longrightarrow> |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
3153 |
length tp = 2 * sum_list (take (length ap) (layout_of ap))" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3154 |
proof(induct ap arbitrary: ly tp rule: rev_induct) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3155 |
case Nil |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3156 |
thus "?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3157 |
by(simp add: tms_of.simps tm_of.simps tpairs_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3158 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3159 |
fix x xs ly tp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3160 |
assume ind: "\<And>ly tp. \<lbrakk>ly = layout_of xs; tp = tm_of xs\<rbrakk> \<Longrightarrow> |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
3161 |
length tp = 2 * sum_list (take (length xs) (layout_of xs))" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3162 |
and layout: "ly = layout_of (xs @ [x])" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3163 |
and tp: "tp = tm_of (xs @ [x])" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3164 |
obtain ly' where a: "ly' = layout_of xs" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3165 |
by metis |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3166 |
obtain tp' where b: "tp' = tm_of xs" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3167 |
by metis |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
3168 |
have c: "length tp' = 2 * sum_list (take (length xs) (layout_of xs))" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3169 |
using a b |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3170 |
by(erule_tac ind, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3171 |
thus "length tp = 2 * |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
3172 |
sum_list (take (length (xs @ [x])) (layout_of (xs @ [x])))" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3173 |
using tp b |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3174 |
apply(auto simp: layout_id_cons tm_of.simps tms_of.simps length_concat tpairs_id_cons map_length_ci) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3175 |
apply(case_tac x) |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
181
diff
changeset
|
3176 |
apply(auto simp: ci.simps tinc_b_def tdec_b_def length_findnth adjust.simps length_of.simps |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3177 |
split: abc_inst.splits) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3178 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3179 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3180 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3181 |
lemma length_tp: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3182 |
"\<lbrakk>ly = layout_of ap; tp = tm_of ap\<rbrakk> \<Longrightarrow> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3183 |
start_of ly (length ap) = Suc (length tp div 2)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3184 |
apply(frule_tac length_tp', simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3185 |
apply(simp add: start_of.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3186 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3187 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3188 |
lemma compile_correct_halt: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3189 |
assumes layout: "ly = layout_of ap" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3190 |
and compile: "tp = tm_of ap" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3191 |
and crsp: "crsp ly (0, lm) (Suc 0, l, r) ires" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3192 |
and abc_halt: "abc_steps_l (0, lm) ap stp = (length ap, am)" |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3193 |
and rs_loc: "n < length am" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3194 |
and rs: "abc_lm_v am n = rs" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3195 |
and off: "off = length tp div 2" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3196 |
shows "\<exists> stp i j. steps (Suc 0, l, r) (tp @ shift (mopup n) off, 0) stp = (0, Bk\<up>i @ Bk # Bk # ires, Oc\<up>Suc rs @ Bk\<up>j)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3197 |
proof - |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3198 |
have "\<exists> stp k. steps (Suc 0, l, r) (tp, 0) stp = (Suc off, Bk # Bk # ires, <am> @ Bk\<up>k)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3199 |
using assms tp_correct'[of ly ap tp lm l r ires stp am] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3200 |
by(simp add: length_tp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3201 |
then obtain stp k where "steps (Suc 0, l, r) (tp, 0) stp = (Suc off, Bk # Bk # ires, <am> @ Bk\<up>k)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3202 |
by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3203 |
then have a: "steps (Suc 0, l, r) (tp@shift (mopup n) off , 0) stp = (Suc off, Bk # Bk # ires, <am> @ Bk\<up>k)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3204 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3205 |
by(auto intro: tm_append_first_steps_eq) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3206 |
have "\<exists> stp i j. (steps (Suc 0, Bk # Bk # ires, <am> @ Bk \<up> k) (mopup_a n @ shift mopup_b (2 * n), 0) stp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3207 |
= (0, Bk\<up>i @ Bk # Bk # ires, Oc # Oc\<up> rs @ Bk\<up>j)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3208 |
using assms |
173
b51cb9aef3ae
split Mopup TM into a separate file
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
170
diff
changeset
|
3209 |
by(rule_tac mopup_correct, auto simp: abc_lm_v.simps) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3210 |
then obtain stpb i j where |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3211 |
"steps (Suc 0, Bk # Bk # ires, <am> @ Bk \<up> k) (mopup_a n @ shift mopup_b (2 * n), 0) stpb |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3212 |
= (0, Bk\<up>i @ Bk # Bk # ires, Oc # Oc\<up> rs @ Bk\<up>j)" by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3213 |
then have b: "steps (Suc 0 + off, Bk # Bk # ires, <am> @ Bk \<up> k) (tp @ shift (mopup n) off, 0) stpb |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3214 |
= (0, Bk\<up>i @ Bk # Bk # ires, Oc # Oc\<up> rs @ Bk\<up>j)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3215 |
using assms wf_mopup |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3216 |
apply(drule_tac tm_append_second_halt_eq, auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3217 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3218 |
from a b show "?thesis" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3219 |
by(rule_tac x = "stp + stpb" in exI, simp add: steps_add) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3220 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3221 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3222 |
declare mopup.simps[simp del] |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3223 |
lemma abc_step_red2: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3224 |
"abc_steps_l (s, lm) p (Suc n) = (let (as', am') = abc_steps_l (s, lm) p n in |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3225 |
abc_step_l (as', am') (abc_fetch as' p))" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3226 |
apply(case_tac "abc_steps_l (s, lm) p n", simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3227 |
apply(drule_tac abc_step_red, simp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3228 |
done |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3229 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3230 |
lemma crsp_steps2: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3231 |
assumes |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3232 |
layout: "ly = layout_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3233 |
and compile: "tp = tm_of ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3234 |
and crsp: "crsp ly (0, lm) (Suc 0, l, r) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3235 |
and nothalt: "as < length ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3236 |
and aexec: "abc_steps_l (0, lm) ap stp = (as, am)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3237 |
shows "\<exists>stpa\<ge>stp. crsp ly (as, am) (steps (Suc 0, l, r) (tp, 0) stpa) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3238 |
using nothalt aexec |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3239 |
proof(induct stp arbitrary: as am) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3240 |
case 0 |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3241 |
thus "?case" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3242 |
using crsp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3243 |
by(rule_tac x = 0 in exI, auto simp: abc_steps_l.simps steps.simps crsp) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3244 |
next |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3245 |
case (Suc stp as am) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3246 |
have ind: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3247 |
"\<And> as am. \<lbrakk>as < length ap; abc_steps_l (0, lm) ap stp = (as, am)\<rbrakk> |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3248 |
\<Longrightarrow> \<exists>stpa\<ge>stp. crsp ly (as, am) (steps (Suc 0, l, r) (tp, 0) stpa) ires" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3249 |
have a: "as < length ap" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3250 |
have b: "abc_steps_l (0, lm) ap (Suc stp) = (as, am)" by fact |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3251 |
obtain as' am' where c: "abc_steps_l (0, lm) ap stp = (as', am')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3252 |
by(case_tac "abc_steps_l (0, lm) ap stp", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3253 |
then have d: "as' < length ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3254 |
using a b |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3255 |
by(simp add: abc_step_red2, case_tac "as' < length ap", simp, |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3256 |
simp add: abc_fetch.simps abc_steps_l.simps abc_step_l.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3257 |
have "\<exists>stpa\<ge>stp. crsp ly (as', am') (steps (Suc 0, l, r) (tp, 0) stpa) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3258 |
using d c ind by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3259 |
from this obtain stpa where e: |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3260 |
"stpa \<ge> stp \<and> crsp ly (as', am') (steps (Suc 0, l, r) (tp, 0) stpa) ires" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3261 |
by blast |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3262 |
obtain s' l' r' where f: "steps (Suc 0, l, r) (tp, 0) stpa = (s', l', r')" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3263 |
by(case_tac "steps (Suc 0, l, r) (tp, 0) stpa", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3264 |
obtain ins where g: "abc_fetch as' ap = Some ins" using d |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3265 |
by(case_tac "abc_fetch as' ap",auto simp: abc_fetch.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3266 |
then have "\<exists>stp> (0::nat). crsp ly (abc_step_l (as', am') (Some ins)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3267 |
(steps (s', l', r') (tp, 0) stp) ires " |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3268 |
using layout compile e f |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3269 |
by(rule_tac crsp_step, simp_all) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3270 |
then obtain stpb where "stpb > 0 \<and> crsp ly (abc_step_l (as', am') (Some ins)) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3271 |
(steps (s', l', r') (tp, 0) stpb) ires" .. |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3272 |
from this show "?case" using b e g f c |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3273 |
by(rule_tac x = "stpa + stpb" in exI, simp add: steps_add abc_step_red2) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3274 |
qed |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3275 |
|
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3276 |
lemma compile_correct_unhalt: |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3277 |
assumes layout: "ly = layout_of ap" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3278 |
and compile: "tp = tm_of ap" |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3279 |
and crsp: "crsp ly (0, lm) (1, l, r) ires" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3280 |
and off: "off = length tp div 2" |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3281 |
and abc_unhalt: "\<forall> stp. (\<lambda> (as, am). as < length ap) (abc_steps_l (0, lm) ap stp)" |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3282 |
shows "\<forall> stp.\<not> is_final (steps (1, l, r) (tp @ shift (mopup n) off, 0) stp)" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3283 |
using assms |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3284 |
proof(rule_tac allI, rule_tac notI) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3285 |
fix stp |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3286 |
assume h: "is_final (steps (1, l, r) (tp @ shift (mopup n) off, 0) stp)" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3287 |
obtain as am where a: "abc_steps_l (0, lm) ap stp = (as, am)" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3288 |
by(case_tac "abc_steps_l (0, lm) ap stp", auto) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3289 |
then have b: "as < length ap" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3290 |
using abc_unhalt |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3291 |
by(erule_tac x = stp in allE, simp) |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3292 |
have "\<exists> stpa\<ge>stp. crsp ly (as, am) (steps (1, l, r) (tp, 0) stpa) ires " |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3293 |
using assms b a |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3294 |
apply(simp add: numeral) |
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3295 |
apply(rule_tac crsp_steps2) |
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3296 |
apply(simp_all) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3297 |
done |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3298 |
then obtain stpa where |
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3299 |
"stpa\<ge>stp \<and> crsp ly (as, am) (steps (1, l, r) (tp, 0) stpa) ires" .. |
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3300 |
then obtain s' l' r' where b: "(steps (1, l, r) (tp, 0) stpa) = (s', l', r') \<and> |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3301 |
stpa\<ge>stp \<and> crsp ly (as, am) (s', l', r') ires" |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3302 |
by(case_tac "steps (1, l, r) (tp, 0) stpa", auto) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3303 |
hence c: |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3304 |
"(steps (1, l, r) (tp @ shift (mopup n) off, 0) stpa) = (s', l', r')" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3305 |
by(rule_tac tm_append_first_steps_eq, simp_all add: crsp.simps) |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3306 |
from b have d: "s' > 0 \<and> stpa \<ge> stp" |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3307 |
by(simp add: crsp.simps) |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
3308 |
then obtain diff where e: "stpa = stp + diff" by (metis le_iff_add) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3309 |
obtain s'' l'' r'' where f: |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3310 |
"steps (1, l, r) (tp @ shift (mopup n) off, 0) stp = (s'', l'', r'') \<and> is_final (s'', l'', r'')" |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3311 |
using h |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3312 |
by(case_tac "steps (1, l, r) (tp @ shift (mopup n) off, 0) stp", auto) |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3313 |
|
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3314 |
then have "is_final (steps (s'', l'', r'') (tp @ shift (mopup n) off, 0) diff)" |
61
7edbd5657702
updated files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
60
diff
changeset
|
3315 |
by(auto intro: after_is_final) |
170
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3316 |
then have "is_final (steps (1, l, r) (tp @ shift (mopup n) off, 0) stpa)" |
eccd79a974ae
updated some files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
166
diff
changeset
|
3317 |
using e f by simp |
60
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3318 |
from this and c d show "False" by simp |
c8ff97d9f8da
new version of abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
3319 |
qed |
47
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3320 |
|
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3321 |
end |
251e192339b7
added abacus
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3322 |