author | huffman |
Tue, 13 Dec 2011 12:05:47 +0100 | |
changeset 45845 | 4158f35a5c6f |
parent 45604 | 29cf40fe8daf |
child 45847 | b4254b2e2b4a |
permissions | -rw-r--r-- |
24333 | 1 |
(* |
2 |
Author: Jeremy Dawson, NICTA |
|
3 |
||
44939
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
4 |
Theorems to do with integers, expressed using Pls, Min, BIT, |
24333 | 5 |
theorems linking them to lists of booleans, and repeated splitting |
6 |
and concatenation. |
|
7 |
*) |
|
8 |
||
9 |
header "Bool lists and integers" |
|
10 |
||
37658 | 11 |
theory Bool_List_Representation |
12 |
imports Bit_Int |
|
26557 | 13 |
begin |
24333 | 14 |
|
37657 | 15 |
subsection {* Operations on lists of booleans *} |
16 |
||
17 |
primrec bl_to_bin_aux :: "bool list \<Rightarrow> int \<Rightarrow> int" where |
|
18 |
Nil: "bl_to_bin_aux [] w = w" |
|
19 |
| Cons: "bl_to_bin_aux (b # bs) w = |
|
20 |
bl_to_bin_aux bs (w BIT (if b then 1 else 0))" |
|
21 |
||
22 |
definition bl_to_bin :: "bool list \<Rightarrow> int" where |
|
23 |
bl_to_bin_def : "bl_to_bin bs = bl_to_bin_aux bs Int.Pls" |
|
24 |
||
37667 | 25 |
lemma [code]: |
26 |
"bl_to_bin bs = bl_to_bin_aux bs 0" |
|
27 |
by (simp add: bl_to_bin_def Pls_def) |
|
28 |
||
37657 | 29 |
primrec bin_to_bl_aux :: "nat \<Rightarrow> int \<Rightarrow> bool list \<Rightarrow> bool list" where |
30 |
Z: "bin_to_bl_aux 0 w bl = bl" |
|
31 |
| Suc: "bin_to_bl_aux (Suc n) w bl = |
|
32 |
bin_to_bl_aux n (bin_rest w) ((bin_last w = 1) # bl)" |
|
33 |
||
34 |
definition bin_to_bl :: "nat \<Rightarrow> int \<Rightarrow> bool list" where |
|
35 |
bin_to_bl_def : "bin_to_bl n w = bin_to_bl_aux n w []" |
|
36 |
||
37 |
primrec bl_of_nth :: "nat \<Rightarrow> (nat \<Rightarrow> bool) \<Rightarrow> bool list" where |
|
38 |
Suc: "bl_of_nth (Suc n) f = f n # bl_of_nth n f" |
|
39 |
| Z: "bl_of_nth 0 f = []" |
|
40 |
||
41 |
primrec takefill :: "'a \<Rightarrow> nat \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
|
42 |
Z: "takefill fill 0 xs = []" |
|
43 |
| Suc: "takefill fill (Suc n) xs = ( |
|
44 |
case xs of [] => fill # takefill fill n xs |
|
45 |
| y # ys => y # takefill fill n ys)" |
|
46 |
||
47 |
definition map2 :: "('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> 'a list \<Rightarrow> 'b list \<Rightarrow> 'c list" where |
|
48 |
"map2 f as bs = map (split f) (zip as bs)" |
|
49 |
||
50 |
lemma map2_Nil [simp]: "map2 f [] ys = []" |
|
51 |
unfolding map2_def by auto |
|
52 |
||
53 |
lemma map2_Nil2 [simp]: "map2 f xs [] = []" |
|
54 |
unfolding map2_def by auto |
|
55 |
||
56 |
lemma map2_Cons [simp]: |
|
57 |
"map2 f (x # xs) (y # ys) = f x y # map2 f xs ys" |
|
58 |
unfolding map2_def by auto |
|
59 |
||
60 |
||
24465 | 61 |
subsection "Arithmetic in terms of bool lists" |
62 |
||
44939
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
63 |
text {* |
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
64 |
Arithmetic operations in terms of the reversed bool list, |
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
65 |
assuming input list(s) the same length, and don't extend them. |
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
66 |
*} |
24465 | 67 |
|
26557 | 68 |
primrec rbl_succ :: "bool list => bool list" where |
24465 | 69 |
Nil: "rbl_succ Nil = Nil" |
26557 | 70 |
| Cons: "rbl_succ (x # xs) = (if x then False # rbl_succ xs else True # xs)" |
24465 | 71 |
|
26557 | 72 |
primrec rbl_pred :: "bool list => bool list" where |
73 |
Nil: "rbl_pred Nil = Nil" |
|
74 |
| Cons: "rbl_pred (x # xs) = (if x then False # xs else True # rbl_pred xs)" |
|
24465 | 75 |
|
26557 | 76 |
primrec rbl_add :: "bool list => bool list => bool list" where |
44939
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
77 |
-- "result is length of first arg, second arg may be longer" |
26557 | 78 |
Nil: "rbl_add Nil x = Nil" |
79 |
| Cons: "rbl_add (y # ys) x = (let ws = rbl_add ys (tl x) in |
|
24465 | 80 |
(y ~= hd x) # (if hd x & y then rbl_succ ws else ws))" |
81 |
||
26557 | 82 |
primrec rbl_mult :: "bool list => bool list => bool list" where |
44939
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
83 |
-- "result is length of first arg, second arg may be longer" |
26557 | 84 |
Nil: "rbl_mult Nil x = Nil" |
85 |
| Cons: "rbl_mult (y # ys) x = (let ws = False # rbl_mult ys x in |
|
24465 | 86 |
if y then rbl_add ws x else ws)" |
24333 | 87 |
|
88 |
lemma butlast_power: |
|
30971 | 89 |
"(butlast ^^ n) bl = take (length bl - n) bl" |
24333 | 90 |
by (induct n) (auto simp: butlast_take) |
91 |
||
26086
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
92 |
lemma bin_to_bl_aux_Pls_minus_simp [simp]: |
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
93 |
"0 < n ==> bin_to_bl_aux n Int.Pls bl = |
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
94 |
bin_to_bl_aux (n - 1) Int.Pls (False # bl)" |
24333 | 95 |
by (cases n) auto |
96 |
||
26086
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
97 |
lemma bin_to_bl_aux_Min_minus_simp [simp]: |
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
98 |
"0 < n ==> bin_to_bl_aux n Int.Min bl = |
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
99 |
bin_to_bl_aux (n - 1) Int.Min (True # bl)" |
24333 | 100 |
by (cases n) auto |
101 |
||
26086
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
102 |
lemma bin_to_bl_aux_Bit_minus_simp [simp]: |
24333 | 103 |
"0 < n ==> bin_to_bl_aux n (w BIT b) bl = |
37654 | 104 |
bin_to_bl_aux (n - 1) w ((b = 1) # bl)" |
24333 | 105 |
by (cases n) auto |
106 |
||
26086
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
107 |
lemma bin_to_bl_aux_Bit0_minus_simp [simp]: |
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
108 |
"0 < n ==> bin_to_bl_aux n (Int.Bit0 w) bl = |
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
109 |
bin_to_bl_aux (n - 1) w (False # bl)" |
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
110 |
by (cases n) auto |
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
111 |
|
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
112 |
lemma bin_to_bl_aux_Bit1_minus_simp [simp]: |
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
113 |
"0 < n ==> bin_to_bl_aux n (Int.Bit1 w) bl = |
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
114 |
bin_to_bl_aux (n - 1) w (True # bl)" |
3c243098b64a
New simpler representation of numerals, using Bit0 and Bit1 instead of BIT, B0, and B1
huffman
parents:
26008
diff
changeset
|
115 |
by (cases n) auto |
24333 | 116 |
|
44939
5930d35c976d
removed unused legacy lemma names, some comment cleanup.
kleing
parents:
41842
diff
changeset
|
117 |
text {* Link between bin and bool list. *} |
24465 | 118 |
|
26557 | 119 |
lemma bl_to_bin_aux_append: |
120 |
"bl_to_bin_aux (bs @ cs) w = bl_to_bin_aux cs (bl_to_bin_aux bs w)" |
|
121 |
by (induct bs arbitrary: w) auto |
|
24465 | 122 |
|
26557 | 123 |
lemma bin_to_bl_aux_append: |
124 |
"bin_to_bl_aux n w bs @ cs = bin_to_bl_aux n w (bs @ cs)" |
|
125 |
by (induct n arbitrary: w bs) auto |
|
24333 | 126 |
|
24465 | 127 |
lemma bl_to_bin_append: |
26557 | 128 |
"bl_to_bin (bs @ cs) = bl_to_bin_aux cs (bl_to_bin bs)" |
24465 | 129 |
unfolding bl_to_bin_def by (rule bl_to_bin_aux_append) |
130 |
||
24333 | 131 |
lemma bin_to_bl_aux_alt: |
132 |
"bin_to_bl_aux n w bs = bin_to_bl n w @ bs" |
|
133 |
unfolding bin_to_bl_def by (simp add : bin_to_bl_aux_append) |
|
134 |
||
24465 | 135 |
lemma bin_to_bl_0: "bin_to_bl 0 bs = []" |
24333 | 136 |
unfolding bin_to_bl_def by auto |
137 |
||
26557 | 138 |
lemma size_bin_to_bl_aux: |
139 |
"size (bin_to_bl_aux n w bs) = n + length bs" |
|
140 |
by (induct n arbitrary: w bs) auto |
|
24333 | 141 |
|
24465 | 142 |
lemma size_bin_to_bl: "size (bin_to_bl n w) = n" |
24333 | 143 |
unfolding bin_to_bl_def by (simp add : size_bin_to_bl_aux) |
144 |
||
26557 | 145 |
lemma bin_bl_bin': |
146 |
"bl_to_bin (bin_to_bl_aux n w bs) = |
|
147 |
bl_to_bin_aux bs (bintrunc n w)" |
|
148 |
by (induct n arbitrary: w bs) (auto simp add : bl_to_bin_def) |
|
24465 | 149 |
|
150 |
lemma bin_bl_bin: "bl_to_bin (bin_to_bl n w) = bintrunc n w" |
|
151 |
unfolding bin_to_bl_def bin_bl_bin' by auto |
|
152 |
||
26557 | 153 |
lemma bl_bin_bl': |
154 |
"bin_to_bl (n + length bs) (bl_to_bin_aux bs w) = |
|
24465 | 155 |
bin_to_bl_aux n w bs" |
26557 | 156 |
apply (induct bs arbitrary: w n) |
24465 | 157 |
apply auto |
158 |
apply (simp_all only : add_Suc [symmetric]) |
|
159 |
apply (auto simp add : bin_to_bl_def) |
|
160 |
done |
|
161 |
||
162 |
lemma bl_bin_bl: "bin_to_bl (length bs) (bl_to_bin bs) = bs" |
|
163 |
unfolding bl_to_bin_def |
|
164 |
apply (rule box_equals) |
|
165 |
apply (rule bl_bin_bl') |
|
166 |
prefer 2 |
|
167 |
apply (rule bin_to_bl_aux.Z) |
|
168 |
apply simp |
|
169 |
done |
|
170 |
||
171 |
declare |
|
172 |
bin_to_bl_0 [simp] |
|
173 |
size_bin_to_bl [simp] |
|
174 |
bin_bl_bin [simp] |
|
175 |
bl_bin_bl [simp] |
|
176 |
||
177 |
lemma bl_to_bin_inj: |
|
178 |
"bl_to_bin bs = bl_to_bin cs ==> length bs = length cs ==> bs = cs" |
|
179 |
apply (rule_tac box_equals) |
|
180 |
defer |
|
181 |
apply (rule bl_bin_bl) |
|
182 |
apply (rule bl_bin_bl) |
|
183 |
apply simp |
|
184 |
done |
|
185 |
||
186 |
lemma bl_to_bin_False: "bl_to_bin (False # bl) = bl_to_bin bl" |
|
187 |
unfolding bl_to_bin_def by auto |
|
188 |
||
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
189 |
lemma bl_to_bin_Nil: "bl_to_bin [] = Int.Pls" |
24465 | 190 |
unfolding bl_to_bin_def by auto |
191 |
||
26557 | 192 |
lemma bin_to_bl_Pls_aux: |
193 |
"bin_to_bl_aux n Int.Pls bl = replicate n False @ bl" |
|
194 |
by (induct n arbitrary: bl) (auto simp: replicate_app_Cons_same) |
|
24333 | 195 |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
196 |
lemma bin_to_bl_Pls: "bin_to_bl n Int.Pls = replicate n False" |
24333 | 197 |
unfolding bin_to_bl_def by (simp add : bin_to_bl_Pls_aux) |
198 |
||
199 |
lemma bin_to_bl_Min_aux [rule_format] : |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
200 |
"ALL bl. bin_to_bl_aux n Int.Min bl = replicate n True @ bl" |
24333 | 201 |
by (induct n) (auto simp: replicate_app_Cons_same) |
202 |
||
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
203 |
lemma bin_to_bl_Min: "bin_to_bl n Int.Min = replicate n True" |
24333 | 204 |
unfolding bin_to_bl_def by (simp add : bin_to_bl_Min_aux) |
205 |
||
24465 | 206 |
lemma bl_to_bin_rep_F: |
207 |
"bl_to_bin (replicate n False @ bl) = bl_to_bin bl" |
|
208 |
apply (simp add: bin_to_bl_Pls_aux [symmetric] bin_bl_bin') |
|
209 |
apply (simp add: bl_to_bin_def) |
|
210 |
done |
|
211 |
||
212 |
lemma bin_to_bl_trunc: |
|
213 |
"n <= m ==> bin_to_bl n (bintrunc m w) = bin_to_bl n w" |
|
214 |
by (auto intro: bl_to_bin_inj) |
|
215 |
||
216 |
declare |
|
217 |
bin_to_bl_trunc [simp] |
|
218 |
bl_to_bin_False [simp] |
|
219 |
bl_to_bin_Nil [simp] |
|
220 |
||
24333 | 221 |
lemma bin_to_bl_aux_bintr [rule_format] : |
222 |
"ALL m bin bl. bin_to_bl_aux n (bintrunc m bin) bl = |
|
223 |
replicate (n - m) False @ bin_to_bl_aux (min n m) bin bl" |
|
27105
5f139027c365
slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
haftmann
parents:
26584
diff
changeset
|
224 |
apply (induct n) |
24333 | 225 |
apply clarsimp |
226 |
apply clarsimp |
|
227 |
apply (case_tac "m") |
|
228 |
apply (clarsimp simp: bin_to_bl_Pls_aux) |
|
229 |
apply (erule thin_rl) |
|
230 |
apply (induct_tac n) |
|
231 |
apply auto |
|
232 |
done |
|
233 |
||
234 |
lemmas bin_to_bl_bintr = |
|
235 |
bin_to_bl_aux_bintr [where bl = "[]", folded bin_to_bl_def] |
|
236 |
||
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
237 |
lemma bl_to_bin_rep_False: "bl_to_bin (replicate n False) = Int.Pls" |
24465 | 238 |
by (induct n) auto |
239 |
||
26557 | 240 |
lemma len_bin_to_bl_aux: |
241 |
"length (bin_to_bl_aux n w bs) = n + length bs" |
|
242 |
by (induct n arbitrary: w bs) auto |
|
24333 | 243 |
|
244 |
lemma len_bin_to_bl [simp]: "length (bin_to_bl n w) = n" |
|
245 |
unfolding bin_to_bl_def len_bin_to_bl_aux by auto |
|
246 |
||
26557 | 247 |
lemma sign_bl_bin': |
248 |
"bin_sign (bl_to_bin_aux bs w) = bin_sign w" |
|
249 |
by (induct bs arbitrary: w) auto |
|
24333 | 250 |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
251 |
lemma sign_bl_bin: "bin_sign (bl_to_bin bs) = Int.Pls" |
24333 | 252 |
unfolding bl_to_bin_def by (simp add : sign_bl_bin') |
253 |
||
26557 | 254 |
lemma bl_sbin_sign_aux: |
255 |
"hd (bin_to_bl_aux (Suc n) w bs) = |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
256 |
(bin_sign (sbintrunc n w) = Int.Min)" |
26557 | 257 |
apply (induct n arbitrary: w bs) |
24333 | 258 |
apply clarsimp |
26557 | 259 |
apply (cases w rule: bin_exhaust) |
24333 | 260 |
apply (simp split add : bit.split) |
261 |
apply clarsimp |
|
262 |
done |
|
263 |
||
264 |
lemma bl_sbin_sign: |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
265 |
"hd (bin_to_bl (Suc n) w) = (bin_sign (sbintrunc n w) = Int.Min)" |
24333 | 266 |
unfolding bin_to_bl_def by (rule bl_sbin_sign_aux) |
267 |
||
26557 | 268 |
lemma bin_nth_of_bl_aux [rule_format]: |
269 |
"\<forall>w. bin_nth (bl_to_bin_aux bl w) n = |
|
24333 | 270 |
(n < size bl & rev bl ! n | n >= length bl & bin_nth w (n - size bl))" |
271 |
apply (induct_tac bl) |
|
272 |
apply clarsimp |
|
273 |
apply clarsimp |
|
274 |
apply (cut_tac x=n and y="size list" in linorder_less_linear) |
|
275 |
apply (erule disjE, simp add: nth_append)+ |
|
26557 | 276 |
apply auto |
24333 | 277 |
done |
278 |
||
45475 | 279 |
lemma bin_nth_of_bl: "bin_nth (bl_to_bin bl) n = (n < length bl & rev bl ! n)" |
24333 | 280 |
unfolding bl_to_bin_def by (simp add : bin_nth_of_bl_aux) |
281 |
||
282 |
lemma bin_nth_bl [rule_format] : "ALL m w. n < m --> |
|
283 |
bin_nth w n = nth (rev (bin_to_bl m w)) n" |
|
284 |
apply (induct n) |
|
285 |
apply clarsimp |
|
286 |
apply (case_tac m, clarsimp) |
|
287 |
apply (clarsimp simp: bin_to_bl_def) |
|
288 |
apply (simp add: bin_to_bl_aux_alt) |
|
289 |
apply clarsimp |
|
290 |
apply (case_tac m, clarsimp) |
|
291 |
apply (clarsimp simp: bin_to_bl_def) |
|
292 |
apply (simp add: bin_to_bl_aux_alt) |
|
293 |
done |
|
294 |
||
24465 | 295 |
lemma nth_rev [rule_format] : |
296 |
"n < length xs --> rev xs ! n = xs ! (length xs - 1 - n)" |
|
297 |
apply (induct_tac "xs") |
|
298 |
apply simp |
|
299 |
apply (clarsimp simp add : nth_append nth.simps split add : nat.split) |
|
300 |
apply (rule_tac f = "%n. list ! n" in arg_cong) |
|
301 |
apply arith |
|
302 |
done |
|
303 |
||
45604 | 304 |
lemmas nth_rev_alt = nth_rev [where xs = "rev ys", simplified] for ys |
24465 | 305 |
|
24333 | 306 |
lemma nth_bin_to_bl_aux [rule_format] : |
307 |
"ALL w n bl. n < m + length bl --> (bin_to_bl_aux m w bl) ! n = |
|
308 |
(if n < m then bin_nth w (m - 1 - n) else bl ! (n - m))" |
|
27105
5f139027c365
slightly tuning of some proofs involving case distinction and induction on natural numbers and similar
haftmann
parents:
26584
diff
changeset
|
309 |
apply (induct m) |
24333 | 310 |
apply clarsimp |
311 |
apply clarsimp |
|
312 |
apply (case_tac w rule: bin_exhaust) |
|
313 |
apply simp |
|
314 |
done |
|
315 |
||
316 |
lemma nth_bin_to_bl: "n < m ==> (bin_to_bl m w) ! n = bin_nth w (m - Suc n)" |
|
317 |
unfolding bin_to_bl_def by (simp add : nth_bin_to_bl_aux) |
|
318 |
||
26557 | 319 |
lemma bl_to_bin_lt2p_aux [rule_format]: |
320 |
"\<forall>w. bl_to_bin_aux bs w < (w + 1) * (2 ^ length bs)" |
|
321 |
apply (induct bs) |
|
24333 | 322 |
apply clarsimp |
323 |
apply clarsimp |
|
324 |
apply safe |
|
26557 | 325 |
apply (erule allE, erule xtr8 [rotated], |
29667 | 326 |
simp add: numeral_simps algebra_simps cong add : number_of_False_cong)+ |
24333 | 327 |
done |
328 |
||
329 |
lemma bl_to_bin_lt2p: "bl_to_bin bs < (2 ^ length bs)" |
|
330 |
apply (unfold bl_to_bin_def) |
|
331 |
apply (rule xtr1) |
|
332 |
prefer 2 |
|
333 |
apply (rule bl_to_bin_lt2p_aux) |
|
334 |
apply simp |
|
335 |
done |
|
336 |
||
337 |
lemma bl_to_bin_ge2p_aux [rule_format] : |
|
26557 | 338 |
"\<forall>w. bl_to_bin_aux bs w >= w * (2 ^ length bs)" |
24333 | 339 |
apply (induct bs) |
340 |
apply clarsimp |
|
341 |
apply clarsimp |
|
342 |
apply safe |
|
28059 | 343 |
apply (erule allE, erule preorder_class.order_trans [rotated], |
29667 | 344 |
simp add: numeral_simps algebra_simps cong add : number_of_False_cong)+ |
24333 | 345 |
done |
346 |
||
347 |
lemma bl_to_bin_ge0: "bl_to_bin bs >= 0" |
|
348 |
apply (unfold bl_to_bin_def) |
|
349 |
apply (rule xtr4) |
|
350 |
apply (rule bl_to_bin_ge2p_aux) |
|
45845
4158f35a5c6f
remove some unwanted numeral-representation-specific simp rules
huffman
parents:
45604
diff
changeset
|
351 |
apply (simp add: Pls_def) |
24333 | 352 |
done |
353 |
||
354 |
lemma butlast_rest_bin: |
|
355 |
"butlast (bin_to_bl n w) = bin_to_bl (n - 1) (bin_rest w)" |
|
356 |
apply (unfold bin_to_bl_def) |
|
357 |
apply (cases w rule: bin_exhaust) |
|
358 |
apply (cases n, clarsimp) |
|
359 |
apply clarsimp |
|
360 |
apply (auto simp add: bin_to_bl_aux_alt) |
|
361 |
done |
|
362 |
||
363 |
lemmas butlast_bin_rest = butlast_rest_bin |
|
45604 | 364 |
[where w="bl_to_bin bl" and n="length bl", simplified] for bl |
24333 | 365 |
|
26557 | 366 |
lemma butlast_rest_bl2bin_aux: |
367 |
"bl ~= [] \<Longrightarrow> |
|
368 |
bl_to_bin_aux (butlast bl) w = bin_rest (bl_to_bin_aux bl w)" |
|
369 |
by (induct bl arbitrary: w) auto |
|
24333 | 370 |
|
371 |
lemma butlast_rest_bl2bin: |
|
372 |
"bl_to_bin (butlast bl) = bin_rest (bl_to_bin bl)" |
|
373 |
apply (unfold bl_to_bin_def) |
|
374 |
apply (cases bl) |
|
375 |
apply (auto simp add: butlast_rest_bl2bin_aux) |
|
376 |
done |
|
377 |
||
26557 | 378 |
lemma trunc_bl2bin_aux [rule_format]: |
379 |
"ALL w. bintrunc m (bl_to_bin_aux bl w) = |
|
380 |
bl_to_bin_aux (drop (length bl - m) bl) (bintrunc (m - length bl) w)" |
|
24333 | 381 |
apply (induct_tac bl) |
382 |
apply clarsimp |
|
383 |
apply clarsimp |
|
384 |
apply safe |
|
385 |
apply (case_tac "m - size list") |
|
386 |
apply (simp add : diff_is_0_eq [THEN iffD1, THEN Suc_diff_le]) |
|
387 |
apply simp |
|
26557 | 388 |
apply (rule_tac f = "%nat. bl_to_bin_aux list (Int.Bit1 (bintrunc nat w))" |
24333 | 389 |
in arg_cong) |
390 |
apply simp |
|
391 |
apply (case_tac "m - size list") |
|
392 |
apply (simp add: diff_is_0_eq [THEN iffD1, THEN Suc_diff_le]) |
|
393 |
apply simp |
|
26557 | 394 |
apply (rule_tac f = "%nat. bl_to_bin_aux list (Int.Bit0 (bintrunc nat w))" |
24333 | 395 |
in arg_cong) |
396 |
apply simp |
|
397 |
done |
|
398 |
||
399 |
lemma trunc_bl2bin: |
|
400 |
"bintrunc m (bl_to_bin bl) = bl_to_bin (drop (length bl - m) bl)" |
|
401 |
unfolding bl_to_bin_def by (simp add : trunc_bl2bin_aux) |
|
402 |
||
403 |
lemmas trunc_bl2bin_len [simp] = |
|
45604 | 404 |
trunc_bl2bin [of "length bl" bl, simplified] for bl |
24333 | 405 |
|
406 |
lemma bl2bin_drop: |
|
407 |
"bl_to_bin (drop k bl) = bintrunc (length bl - k) (bl_to_bin bl)" |
|
408 |
apply (rule trans) |
|
409 |
prefer 2 |
|
410 |
apply (rule trunc_bl2bin [symmetric]) |
|
411 |
apply (cases "k <= length bl") |
|
412 |
apply auto |
|
413 |
done |
|
414 |
||
415 |
lemma nth_rest_power_bin [rule_format] : |
|
30971 | 416 |
"ALL n. bin_nth ((bin_rest ^^ k) w) n = bin_nth w (n + k)" |
24333 | 417 |
apply (induct k, clarsimp) |
418 |
apply clarsimp |
|
419 |
apply (simp only: bin_nth.Suc [symmetric] add_Suc) |
|
420 |
done |
|
421 |
||
422 |
lemma take_rest_power_bin: |
|
30971 | 423 |
"m <= n ==> take m (bin_to_bl n w) = bin_to_bl m ((bin_rest ^^ (n - m)) w)" |
24333 | 424 |
apply (rule nth_equalityI) |
425 |
apply simp |
|
426 |
apply (clarsimp simp add: nth_bin_to_bl nth_rest_power_bin) |
|
427 |
done |
|
428 |
||
24465 | 429 |
lemma hd_butlast: "size xs > 1 ==> hd (butlast xs) = hd xs" |
430 |
by (cases xs) auto |
|
24333 | 431 |
|
26557 | 432 |
lemma last_bin_last': |
37654 | 433 |
"size xs > 0 \<Longrightarrow> last xs = (bin_last (bl_to_bin_aux xs w) = 1)" |
26557 | 434 |
by (induct xs arbitrary: w) auto |
24333 | 435 |
|
436 |
lemma last_bin_last: |
|
37654 | 437 |
"size xs > 0 ==> last xs = (bin_last (bl_to_bin xs) = 1)" |
24333 | 438 |
unfolding bl_to_bin_def by (erule last_bin_last') |
439 |
||
440 |
lemma bin_last_last: |
|
37654 | 441 |
"bin_last w = (if last (bin_to_bl (Suc n) w) then 1 else 0)" |
24333 | 442 |
apply (unfold bin_to_bl_def) |
443 |
apply simp |
|
444 |
apply (auto simp add: bin_to_bl_aux_alt) |
|
445 |
done |
|
446 |
||
24465 | 447 |
(** links between bit-wise operations and operations on bool lists **) |
448 |
||
24333 | 449 |
lemma bl_xor_aux_bin [rule_format] : "ALL v w bs cs. |
26557 | 450 |
map2 (%x y. x ~= y) (bin_to_bl_aux n v bs) (bin_to_bl_aux n w cs) = |
451 |
bin_to_bl_aux n (v XOR w) (map2 (%x y. x ~= y) bs cs)" |
|
24333 | 452 |
apply (induct_tac n) |
453 |
apply safe |
|
454 |
apply simp |
|
455 |
apply (case_tac v rule: bin_exhaust) |
|
456 |
apply (case_tac w rule: bin_exhaust) |
|
457 |
apply clarsimp |
|
458 |
apply (case_tac b) |
|
459 |
apply (case_tac ba, safe, simp_all)+ |
|
460 |
done |
|
461 |
||
462 |
lemma bl_or_aux_bin [rule_format] : "ALL v w bs cs. |
|
26557 | 463 |
map2 (op | ) (bin_to_bl_aux n v bs) (bin_to_bl_aux n w cs) = |
464 |
bin_to_bl_aux n (v OR w) (map2 (op | ) bs cs)" |
|
24333 | 465 |
apply (induct_tac n) |
466 |
apply safe |
|
467 |
apply simp |
|
468 |
apply (case_tac v rule: bin_exhaust) |
|
469 |
apply (case_tac w rule: bin_exhaust) |
|
470 |
apply clarsimp |
|
471 |
apply (case_tac b) |
|
472 |
apply (case_tac ba, safe, simp_all)+ |
|
473 |
done |
|
474 |
||
475 |
lemma bl_and_aux_bin [rule_format] : "ALL v w bs cs. |
|
26557 | 476 |
map2 (op & ) (bin_to_bl_aux n v bs) (bin_to_bl_aux n w cs) = |
477 |
bin_to_bl_aux n (v AND w) (map2 (op & ) bs cs)" |
|
24333 | 478 |
apply (induct_tac n) |
479 |
apply safe |
|
480 |
apply simp |
|
481 |
apply (case_tac v rule: bin_exhaust) |
|
482 |
apply (case_tac w rule: bin_exhaust) |
|
483 |
apply clarsimp |
|
484 |
done |
|
485 |
||
486 |
lemma bl_not_aux_bin [rule_format] : |
|
487 |
"ALL w cs. map Not (bin_to_bl_aux n w cs) = |
|
24353 | 488 |
bin_to_bl_aux n (NOT w) (map Not cs)" |
24333 | 489 |
apply (induct n) |
490 |
apply clarsimp |
|
491 |
apply clarsimp |
|
492 |
done |
|
493 |
||
494 |
lemmas bl_not_bin = bl_not_aux_bin |
|
495 |
[where cs = "[]", unfolded bin_to_bl_def [symmetric] map.simps] |
|
496 |
||
497 |
lemmas bl_and_bin = bl_and_aux_bin [where bs="[]" and cs="[]", |
|
26557 | 498 |
unfolded map2_Nil, folded bin_to_bl_def] |
24333 | 499 |
|
500 |
lemmas bl_or_bin = bl_or_aux_bin [where bs="[]" and cs="[]", |
|
26557 | 501 |
unfolded map2_Nil, folded bin_to_bl_def] |
24333 | 502 |
|
503 |
lemmas bl_xor_bin = bl_xor_aux_bin [where bs="[]" and cs="[]", |
|
26557 | 504 |
unfolded map2_Nil, folded bin_to_bl_def] |
24333 | 505 |
|
506 |
lemma drop_bin2bl_aux [rule_format] : |
|
507 |
"ALL m bin bs. drop m (bin_to_bl_aux n bin bs) = |
|
508 |
bin_to_bl_aux (n - m) bin (drop (m - n) bs)" |
|
509 |
apply (induct n, clarsimp) |
|
510 |
apply clarsimp |
|
511 |
apply (case_tac bin rule: bin_exhaust) |
|
512 |
apply (case_tac "m <= n", simp) |
|
513 |
apply (case_tac "m - n", simp) |
|
514 |
apply simp |
|
515 |
apply (rule_tac f = "%nat. drop nat bs" in arg_cong) |
|
516 |
apply simp |
|
517 |
done |
|
518 |
||
519 |
lemma drop_bin2bl: "drop m (bin_to_bl n bin) = bin_to_bl (n - m) bin" |
|
520 |
unfolding bin_to_bl_def by (simp add : drop_bin2bl_aux) |
|
521 |
||
522 |
lemma take_bin2bl_lem1 [rule_format] : |
|
523 |
"ALL w bs. take m (bin_to_bl_aux m w bs) = bin_to_bl m w" |
|
524 |
apply (induct m, clarsimp) |
|
525 |
apply clarsimp |
|
526 |
apply (simp add: bin_to_bl_aux_alt) |
|
527 |
apply (simp add: bin_to_bl_def) |
|
528 |
apply (simp add: bin_to_bl_aux_alt) |
|
529 |
done |
|
530 |
||
531 |
lemma take_bin2bl_lem [rule_format] : |
|
532 |
"ALL w bs. take m (bin_to_bl_aux (m + n) w bs) = |
|
533 |
take m (bin_to_bl (m + n) w)" |
|
534 |
apply (induct n) |
|
535 |
apply clarify |
|
536 |
apply (simp_all (no_asm) add: bin_to_bl_def take_bin2bl_lem1) |
|
537 |
apply simp |
|
538 |
done |
|
539 |
||
540 |
lemma bin_split_take [rule_format] : |
|
541 |
"ALL b c. bin_split n c = (a, b) --> |
|
542 |
bin_to_bl m a = take m (bin_to_bl (m + n) c)" |
|
543 |
apply (induct n) |
|
544 |
apply clarsimp |
|
545 |
apply (clarsimp simp: Let_def split: ls_splits) |
|
546 |
apply (simp add: bin_to_bl_def) |
|
547 |
apply (simp add: take_bin2bl_lem) |
|
548 |
done |
|
549 |
||
550 |
lemma bin_split_take1: |
|
551 |
"k = m + n ==> bin_split n c = (a, b) ==> |
|
552 |
bin_to_bl m a = take m (bin_to_bl k c)" |
|
553 |
by (auto elim: bin_split_take) |
|
554 |
||
555 |
lemma nth_takefill [rule_format] : "ALL m l. m < n --> |
|
556 |
takefill fill n l ! m = (if m < length l then l ! m else fill)" |
|
557 |
apply (induct n, clarsimp) |
|
558 |
apply clarsimp |
|
559 |
apply (case_tac m) |
|
560 |
apply (simp split: list.split) |
|
561 |
apply clarsimp |
|
562 |
apply (erule allE)+ |
|
563 |
apply (erule (1) impE) |
|
564 |
apply (simp split: list.split) |
|
565 |
done |
|
566 |
||
567 |
lemma takefill_alt [rule_format] : |
|
568 |
"ALL l. takefill fill n l = take n l @ replicate (n - length l) fill" |
|
569 |
by (induct n) (auto split: list.split) |
|
570 |
||
571 |
lemma takefill_replicate [simp]: |
|
572 |
"takefill fill n (replicate m fill) = replicate n fill" |
|
573 |
by (simp add : takefill_alt replicate_add [symmetric]) |
|
574 |
||
575 |
lemma takefill_le' [rule_format] : |
|
576 |
"ALL l n. n = m + k --> takefill x m (takefill x n l) = takefill x m l" |
|
577 |
by (induct m) (auto split: list.split) |
|
578 |
||
579 |
lemma length_takefill [simp]: "length (takefill fill n l) = n" |
|
580 |
by (simp add : takefill_alt) |
|
581 |
||
582 |
lemma take_takefill': |
|
583 |
"!!w n. n = k + m ==> take k (takefill fill n w) = takefill fill k w" |
|
584 |
by (induct k) (auto split add : list.split) |
|
585 |
||
586 |
lemma drop_takefill: |
|
587 |
"!!w. drop k (takefill fill (m + k) w) = takefill fill m (drop k w)" |
|
588 |
by (induct k) (auto split add : list.split) |
|
589 |
||
590 |
lemma takefill_le [simp]: |
|
591 |
"m \<le> n \<Longrightarrow> takefill x m (takefill x n l) = takefill x m l" |
|
592 |
by (auto simp: le_iff_add takefill_le') |
|
593 |
||
594 |
lemma take_takefill [simp]: |
|
595 |
"m \<le> n \<Longrightarrow> take m (takefill fill n w) = takefill fill m w" |
|
596 |
by (auto simp: le_iff_add take_takefill') |
|
597 |
||
598 |
lemma takefill_append: |
|
599 |
"takefill fill (m + length xs) (xs @ w) = xs @ (takefill fill m w)" |
|
600 |
by (induct xs) auto |
|
601 |
||
602 |
lemma takefill_same': |
|
603 |
"l = length xs ==> takefill fill l xs = xs" |
|
604 |
by clarify (induct xs, auto) |
|
605 |
||
606 |
lemmas takefill_same [simp] = takefill_same' [OF refl] |
|
607 |
||
608 |
lemma takefill_bintrunc: |
|
609 |
"takefill False n bl = rev (bin_to_bl n (bl_to_bin (rev bl)))" |
|
610 |
apply (rule nth_equalityI) |
|
611 |
apply simp |
|
612 |
apply (clarsimp simp: nth_takefill nth_rev nth_bin_to_bl bin_nth_of_bl) |
|
613 |
done |
|
614 |
||
615 |
lemma bl_bin_bl_rtf: |
|
616 |
"bin_to_bl n (bl_to_bin bl) = rev (takefill False n (rev bl))" |
|
617 |
by (simp add : takefill_bintrunc) |
|
618 |
||
619 |
lemmas bl_bin_bl_rep_drop = |
|
620 |
bl_bin_bl_rtf [simplified takefill_alt, |
|
621 |
simplified, simplified rev_take, simplified] |
|
622 |
||
623 |
lemma tf_rev: |
|
624 |
"n + k = m + length bl ==> takefill x m (rev (takefill y n bl)) = |
|
625 |
rev (takefill y m (rev (takefill x k (rev bl))))" |
|
626 |
apply (rule nth_equalityI) |
|
627 |
apply (auto simp add: nth_takefill nth_rev) |
|
628 |
apply (rule_tac f = "%n. bl ! n" in arg_cong) |
|
629 |
apply arith |
|
630 |
done |
|
631 |
||
632 |
lemma takefill_minus: |
|
633 |
"0 < n ==> takefill fill (Suc (n - 1)) w = takefill fill n w" |
|
634 |
by auto |
|
635 |
||
636 |
lemmas takefill_Suc_cases = |
|
45604 | 637 |
list.cases [THEN takefill.Suc [THEN trans]] |
24333 | 638 |
|
639 |
lemmas takefill_Suc_Nil = takefill_Suc_cases (1) |
|
640 |
lemmas takefill_Suc_Cons = takefill_Suc_cases (2) |
|
641 |
||
642 |
lemmas takefill_minus_simps = takefill_Suc_cases [THEN [2] |
|
45604 | 643 |
takefill_minus [symmetric, THEN trans]] |
24333 | 644 |
|
645 |
lemmas takefill_pred_simps [simp] = |
|
45604 | 646 |
takefill_minus_simps [where n="number_of bin", simplified nobm1] for bin |
24333 | 647 |
|
648 |
(* links with function bl_to_bin *) |
|
649 |
||
650 |
lemma bl_to_bin_aux_cat: |
|
26557 | 651 |
"!!nv v. bl_to_bin_aux bs (bin_cat w nv v) = |
652 |
bin_cat w (nv + length bs) (bl_to_bin_aux bs v)" |
|
24333 | 653 |
apply (induct bs) |
654 |
apply simp |
|
655 |
apply (simp add: bin_cat_Suc_Bit [symmetric] del: bin_cat.simps) |
|
656 |
done |
|
657 |
||
658 |
lemma bin_to_bl_aux_cat: |
|
659 |
"!!w bs. bin_to_bl_aux (nv + nw) (bin_cat v nw w) bs = |
|
660 |
bin_to_bl_aux nv v (bin_to_bl_aux nw w bs)" |
|
661 |
by (induct nw) auto |
|
662 |
||
663 |
lemmas bl_to_bin_aux_alt = |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
664 |
bl_to_bin_aux_cat [where nv = "0" and v = "Int.Pls", |
24333 | 665 |
simplified bl_to_bin_def [symmetric], simplified] |
666 |
||
667 |
lemmas bin_to_bl_cat = |
|
668 |
bin_to_bl_aux_cat [where bs = "[]", folded bin_to_bl_def] |
|
669 |
||
670 |
lemmas bl_to_bin_aux_app_cat = |
|
671 |
trans [OF bl_to_bin_aux_append bl_to_bin_aux_alt] |
|
672 |
||
673 |
lemmas bin_to_bl_aux_cat_app = |
|
674 |
trans [OF bin_to_bl_aux_cat bin_to_bl_aux_alt] |
|
675 |
||
676 |
lemmas bl_to_bin_app_cat = bl_to_bin_aux_app_cat |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
677 |
[where w = "Int.Pls", folded bl_to_bin_def] |
24333 | 678 |
|
679 |
lemmas bin_to_bl_cat_app = bin_to_bl_aux_cat_app |
|
680 |
[where bs = "[]", folded bin_to_bl_def] |
|
681 |
||
682 |
(* bl_to_bin_app_cat_alt and bl_to_bin_app_cat are easily interderivable *) |
|
683 |
lemma bl_to_bin_app_cat_alt: |
|
684 |
"bin_cat (bl_to_bin cs) n w = bl_to_bin (cs @ bin_to_bl n w)" |
|
685 |
by (simp add : bl_to_bin_app_cat) |
|
686 |
||
687 |
lemma mask_lem: "(bl_to_bin (True # replicate n False)) = |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
688 |
Int.succ (bl_to_bin (replicate n True))" |
24333 | 689 |
apply (unfold bl_to_bin_def) |
690 |
apply (induct n) |
|
691 |
apply simp |
|
31790 | 692 |
apply (simp only: Suc_eq_plus1 replicate_add |
24333 | 693 |
append_Cons [symmetric] bl_to_bin_aux_append) |
694 |
apply simp |
|
695 |
done |
|
696 |
||
24465 | 697 |
(* function bl_of_nth *) |
24333 | 698 |
lemma length_bl_of_nth [simp]: "length (bl_of_nth n f) = n" |
699 |
by (induct n) auto |
|
700 |
||
701 |
lemma nth_bl_of_nth [simp]: |
|
702 |
"m < n \<Longrightarrow> rev (bl_of_nth n f) ! m = f m" |
|
703 |
apply (induct n) |
|
704 |
apply simp |
|
705 |
apply (clarsimp simp add : nth_append) |
|
706 |
apply (rule_tac f = "f" in arg_cong) |
|
707 |
apply simp |
|
708 |
done |
|
709 |
||
710 |
lemma bl_of_nth_inj: |
|
711 |
"(!!k. k < n ==> f k = g k) ==> bl_of_nth n f = bl_of_nth n g" |
|
712 |
by (induct n) auto |
|
713 |
||
714 |
lemma bl_of_nth_nth_le [rule_format] : "ALL xs. |
|
45475 | 715 |
length xs >= n --> bl_of_nth n (nth (rev xs)) = drop (length xs - n) xs" |
24333 | 716 |
apply (induct n, clarsimp) |
717 |
apply clarsimp |
|
718 |
apply (rule trans [OF _ hd_Cons_tl]) |
|
719 |
apply (frule Suc_le_lessD) |
|
720 |
apply (simp add: nth_rev trans [OF drop_Suc drop_tl, symmetric]) |
|
721 |
apply (subst hd_drop_conv_nth) |
|
722 |
apply force |
|
723 |
apply simp_all |
|
724 |
apply (rule_tac f = "%n. drop n xs" in arg_cong) |
|
725 |
apply simp |
|
726 |
done |
|
727 |
||
728 |
lemmas bl_of_nth_nth [simp] = order_refl [THEN bl_of_nth_nth_le, simplified] |
|
729 |
||
730 |
lemma size_rbl_pred: "length (rbl_pred bl) = length bl" |
|
731 |
by (induct bl) auto |
|
732 |
||
733 |
lemma size_rbl_succ: "length (rbl_succ bl) = length bl" |
|
734 |
by (induct bl) auto |
|
735 |
||
736 |
lemma size_rbl_add: |
|
737 |
"!!cl. length (rbl_add bl cl) = length bl" |
|
738 |
by (induct bl) (auto simp: Let_def size_rbl_succ) |
|
739 |
||
740 |
lemma size_rbl_mult: |
|
741 |
"!!cl. length (rbl_mult bl cl) = length bl" |
|
742 |
by (induct bl) (auto simp add : Let_def size_rbl_add) |
|
743 |
||
744 |
lemmas rbl_sizes [simp] = |
|
745 |
size_rbl_pred size_rbl_succ size_rbl_add size_rbl_mult |
|
746 |
||
747 |
lemmas rbl_Nils = |
|
748 |
rbl_pred.Nil rbl_succ.Nil rbl_add.Nil rbl_mult.Nil |
|
749 |
||
750 |
lemma rbl_pred: |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
751 |
"!!bin. rbl_pred (rev (bin_to_bl n bin)) = rev (bin_to_bl n (Int.pred bin))" |
24333 | 752 |
apply (induct n, simp) |
753 |
apply (unfold bin_to_bl_def) |
|
754 |
apply clarsimp |
|
755 |
apply (case_tac bin rule: bin_exhaust) |
|
756 |
apply (case_tac b) |
|
757 |
apply (clarsimp simp: bin_to_bl_aux_alt)+ |
|
758 |
done |
|
759 |
||
760 |
lemma rbl_succ: |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
761 |
"!!bin. rbl_succ (rev (bin_to_bl n bin)) = rev (bin_to_bl n (Int.succ bin))" |
24333 | 762 |
apply (induct n, simp) |
763 |
apply (unfold bin_to_bl_def) |
|
764 |
apply clarsimp |
|
765 |
apply (case_tac bin rule: bin_exhaust) |
|
766 |
apply (case_tac b) |
|
767 |
apply (clarsimp simp: bin_to_bl_aux_alt)+ |
|
768 |
done |
|
769 |
||
770 |
lemma rbl_add: |
|
771 |
"!!bina binb. rbl_add (rev (bin_to_bl n bina)) (rev (bin_to_bl n binb)) = |
|
772 |
rev (bin_to_bl n (bina + binb))" |
|
773 |
apply (induct n, simp) |
|
774 |
apply (unfold bin_to_bl_def) |
|
775 |
apply clarsimp |
|
776 |
apply (case_tac bina rule: bin_exhaust) |
|
777 |
apply (case_tac binb rule: bin_exhaust) |
|
778 |
apply (case_tac b) |
|
779 |
apply (case_tac [!] "ba") |
|
780 |
apply (auto simp: rbl_succ succ_def bin_to_bl_aux_alt Let_def add_ac) |
|
781 |
done |
|
782 |
||
783 |
lemma rbl_add_app2: |
|
784 |
"!!blb. length blb >= length bla ==> |
|
785 |
rbl_add bla (blb @ blc) = rbl_add bla blb" |
|
786 |
apply (induct bla, simp) |
|
787 |
apply clarsimp |
|
788 |
apply (case_tac blb, clarsimp) |
|
789 |
apply (clarsimp simp: Let_def) |
|
790 |
done |
|
791 |
||
792 |
lemma rbl_add_take2: |
|
793 |
"!!blb. length blb >= length bla ==> |
|
794 |
rbl_add bla (take (length bla) blb) = rbl_add bla blb" |
|
795 |
apply (induct bla, simp) |
|
796 |
apply clarsimp |
|
797 |
apply (case_tac blb, clarsimp) |
|
798 |
apply (clarsimp simp: Let_def) |
|
799 |
done |
|
800 |
||
801 |
lemma rbl_add_long: |
|
802 |
"m >= n ==> rbl_add (rev (bin_to_bl n bina)) (rev (bin_to_bl m binb)) = |
|
803 |
rev (bin_to_bl n (bina + binb))" |
|
804 |
apply (rule box_equals [OF _ rbl_add_take2 rbl_add]) |
|
805 |
apply (rule_tac f = "rbl_add (rev (bin_to_bl n bina))" in arg_cong) |
|
806 |
apply (rule rev_swap [THEN iffD1]) |
|
807 |
apply (simp add: rev_take drop_bin2bl) |
|
808 |
apply simp |
|
809 |
done |
|
810 |
||
811 |
lemma rbl_mult_app2: |
|
812 |
"!!blb. length blb >= length bla ==> |
|
813 |
rbl_mult bla (blb @ blc) = rbl_mult bla blb" |
|
814 |
apply (induct bla, simp) |
|
815 |
apply clarsimp |
|
816 |
apply (case_tac blb, clarsimp) |
|
817 |
apply (clarsimp simp: Let_def rbl_add_app2) |
|
818 |
done |
|
819 |
||
820 |
lemma rbl_mult_take2: |
|
821 |
"length blb >= length bla ==> |
|
822 |
rbl_mult bla (take (length bla) blb) = rbl_mult bla blb" |
|
823 |
apply (rule trans) |
|
824 |
apply (rule rbl_mult_app2 [symmetric]) |
|
825 |
apply simp |
|
826 |
apply (rule_tac f = "rbl_mult bla" in arg_cong) |
|
827 |
apply (rule append_take_drop_id) |
|
828 |
done |
|
829 |
||
830 |
lemma rbl_mult_gt1: |
|
831 |
"m >= length bl ==> rbl_mult bl (rev (bin_to_bl m binb)) = |
|
832 |
rbl_mult bl (rev (bin_to_bl (length bl) binb))" |
|
833 |
apply (rule trans) |
|
834 |
apply (rule rbl_mult_take2 [symmetric]) |
|
835 |
apply simp_all |
|
836 |
apply (rule_tac f = "rbl_mult bl" in arg_cong) |
|
837 |
apply (rule rev_swap [THEN iffD1]) |
|
838 |
apply (simp add: rev_take drop_bin2bl) |
|
839 |
done |
|
840 |
||
841 |
lemma rbl_mult_gt: |
|
842 |
"m > n ==> rbl_mult (rev (bin_to_bl n bina)) (rev (bin_to_bl m binb)) = |
|
843 |
rbl_mult (rev (bin_to_bl n bina)) (rev (bin_to_bl n binb))" |
|
844 |
by (auto intro: trans [OF rbl_mult_gt1]) |
|
845 |
||
846 |
lemmas rbl_mult_Suc = lessI [THEN rbl_mult_gt] |
|
847 |
||
848 |
lemma rbbl_Cons: |
|
37654 | 849 |
"b # rev (bin_to_bl n x) = rev (bin_to_bl (Suc n) (x BIT If b 1 0))" |
24333 | 850 |
apply (unfold bin_to_bl_def) |
851 |
apply simp |
|
852 |
apply (simp add: bin_to_bl_aux_alt) |
|
853 |
done |
|
854 |
||
855 |
lemma rbl_mult: "!!bina binb. |
|
856 |
rbl_mult (rev (bin_to_bl n bina)) (rev (bin_to_bl n binb)) = |
|
857 |
rev (bin_to_bl n (bina * binb))" |
|
858 |
apply (induct n) |
|
859 |
apply simp |
|
860 |
apply (unfold bin_to_bl_def) |
|
861 |
apply clarsimp |
|
862 |
apply (case_tac bina rule: bin_exhaust) |
|
863 |
apply (case_tac binb rule: bin_exhaust) |
|
864 |
apply (case_tac b) |
|
865 |
apply (case_tac [!] "ba") |
|
866 |
apply (auto simp: bin_to_bl_aux_alt Let_def) |
|
867 |
apply (auto simp: rbbl_Cons rbl_mult_Suc rbl_add) |
|
868 |
done |
|
869 |
||
870 |
lemma rbl_add_split: |
|
871 |
"P (rbl_add (y # ys) (x # xs)) = |
|
872 |
(ALL ws. length ws = length ys --> ws = rbl_add ys xs --> |
|
26008 | 873 |
(y --> ((x --> P (False # rbl_succ ws)) & (~ x --> P (True # ws)))) & |
24333 | 874 |
(~ y --> P (x # ws)))" |
875 |
apply (auto simp add: Let_def) |
|
876 |
apply (case_tac [!] "y") |
|
877 |
apply auto |
|
878 |
done |
|
879 |
||
880 |
lemma rbl_mult_split: |
|
881 |
"P (rbl_mult (y # ys) xs) = |
|
882 |
(ALL ws. length ws = Suc (length ys) --> ws = False # rbl_mult ys xs --> |
|
883 |
(y --> P (rbl_add ws xs)) & (~ y --> P ws))" |
|
884 |
by (clarsimp simp add : Let_def) |
|
885 |
||
886 |
lemma and_len: "xs = ys ==> xs = ys & length xs = length ys" |
|
887 |
by auto |
|
888 |
||
889 |
lemma size_if: "size (if p then xs else ys) = (if p then size xs else size ys)" |
|
890 |
by auto |
|
891 |
||
892 |
lemma tl_if: "tl (if p then xs else ys) = (if p then tl xs else tl ys)" |
|
893 |
by auto |
|
894 |
||
895 |
lemma hd_if: "hd (if p then xs else ys) = (if p then hd xs else hd ys)" |
|
896 |
by auto |
|
897 |
||
24465 | 898 |
lemma if_Not_x: "(if p then ~ x else x) = (p = (~ x))" |
899 |
by auto |
|
900 |
||
901 |
lemma if_x_Not: "(if p then x else ~ x) = (p = x)" |
|
902 |
by auto |
|
903 |
||
24333 | 904 |
lemma if_same_and: "(If p x y & If p u v) = (if p then x & u else y & v)" |
905 |
by auto |
|
906 |
||
907 |
lemma if_same_eq: "(If p x y = (If p u v)) = (if p then x = (u) else y = (v))" |
|
908 |
by auto |
|
909 |
||
910 |
lemma if_same_eq_not: |
|
911 |
"(If p x y = (~ If p u v)) = (if p then x = (~u) else y = (~v))" |
|
912 |
by auto |
|
913 |
||
914 |
(* note - if_Cons can cause blowup in the size, if p is complex, |
|
915 |
so make a simproc *) |
|
916 |
lemma if_Cons: "(if p then x # xs else y # ys) = If p x y # If p xs ys" |
|
917 |
by auto |
|
918 |
||
919 |
lemma if_single: |
|
920 |
"(if xc then [xab] else [an]) = [if xc then xab else an]" |
|
921 |
by auto |
|
922 |
||
24465 | 923 |
lemma if_bool_simps: |
924 |
"If p True y = (p | y) & If p False y = (~p & y) & |
|
925 |
If p y True = (p --> y) & If p y False = (p & y)" |
|
926 |
by auto |
|
927 |
||
928 |
lemmas if_simps = if_x_Not if_Not_x if_cancel if_True if_False if_bool_simps |
|
929 |
||
45604 | 930 |
lemmas seqr = eq_reflection [where x = "size w"] for w |
24333 | 931 |
|
932 |
lemmas tl_Nil = tl.simps (1) |
|
933 |
lemmas tl_Cons = tl.simps (2) |
|
934 |
||
935 |
||
24350 | 936 |
subsection "Repeated splitting or concatenation" |
24333 | 937 |
|
938 |
lemma sclem: |
|
939 |
"size (concat (map (bin_to_bl n) xs)) = length xs * n" |
|
940 |
by (induct xs) auto |
|
941 |
||
942 |
lemma bin_cat_foldl_lem [rule_format] : |
|
943 |
"ALL x. foldl (%u. bin_cat u n) x xs = |
|
944 |
bin_cat x (size xs * n) (foldl (%u. bin_cat u n) y xs)" |
|
945 |
apply (induct xs) |
|
946 |
apply simp |
|
947 |
apply clarify |
|
948 |
apply (simp (no_asm)) |
|
949 |
apply (frule asm_rl) |
|
950 |
apply (drule spec) |
|
951 |
apply (erule trans) |
|
32439 | 952 |
apply (drule_tac x = "bin_cat y n a" in spec) |
32642
026e7c6a6d08
be more cautious wrt. simp rules: inf_absorb1, inf_absorb2, sup_absorb1, sup_absorb2 are no simp rules by default any longer
haftmann
parents:
32439
diff
changeset
|
953 |
apply (simp add : bin_cat_assoc_sym min_max.inf_absorb2) |
24333 | 954 |
done |
955 |
||
956 |
lemma bin_rcat_bl: |
|
957 |
"(bin_rcat n wl) = bl_to_bin (concat (map (bin_to_bl n) wl))" |
|
958 |
apply (unfold bin_rcat_def) |
|
959 |
apply (rule sym) |
|
960 |
apply (induct wl) |
|
961 |
apply (auto simp add : bl_to_bin_append) |
|
962 |
apply (simp add : bl_to_bin_aux_alt sclem) |
|
963 |
apply (simp add : bin_cat_foldl_lem [symmetric]) |
|
964 |
done |
|
965 |
||
966 |
lemmas bin_rsplit_aux_simps = bin_rsplit_aux.simps bin_rsplitl_aux.simps |
|
967 |
lemmas rsplit_aux_simps = bin_rsplit_aux_simps |
|
968 |
||
45604 | 969 |
lemmas th_if_simp1 = split_if [where P = "op = l", THEN iffD1, THEN conjunct1, THEN mp] for l |
970 |
lemmas th_if_simp2 = split_if [where P = "op = l", THEN iffD1, THEN conjunct2, THEN mp] for l |
|
24333 | 971 |
|
972 |
lemmas rsplit_aux_simp1s = rsplit_aux_simps [THEN th_if_simp1] |
|
973 |
||
974 |
lemmas rsplit_aux_simp2ls = rsplit_aux_simps [THEN th_if_simp2] |
|
975 |
(* these safe to [simp add] as require calculating m - n *) |
|
976 |
lemmas bin_rsplit_aux_simp2s [simp] = rsplit_aux_simp2ls [unfolded Let_def] |
|
977 |
lemmas rbscl = bin_rsplit_aux_simp2s (2) |
|
978 |
||
979 |
lemmas rsplit_aux_0_simps [simp] = |
|
980 |
rsplit_aux_simp1s [OF disjI1] rsplit_aux_simp1s [OF disjI2] |
|
981 |
||
982 |
lemma bin_rsplit_aux_append: |
|
26557 | 983 |
"bin_rsplit_aux n m c (bs @ cs) = bin_rsplit_aux n m c bs @ cs" |
984 |
apply (induct n m c bs rule: bin_rsplit_aux.induct) |
|
24333 | 985 |
apply (subst bin_rsplit_aux.simps) |
986 |
apply (subst bin_rsplit_aux.simps) |
|
987 |
apply (clarsimp split: ls_splits) |
|
26557 | 988 |
apply auto |
24333 | 989 |
done |
990 |
||
991 |
lemma bin_rsplitl_aux_append: |
|
26557 | 992 |
"bin_rsplitl_aux n m c (bs @ cs) = bin_rsplitl_aux n m c bs @ cs" |
993 |
apply (induct n m c bs rule: bin_rsplitl_aux.induct) |
|
24333 | 994 |
apply (subst bin_rsplitl_aux.simps) |
995 |
apply (subst bin_rsplitl_aux.simps) |
|
996 |
apply (clarsimp split: ls_splits) |
|
26557 | 997 |
apply auto |
24333 | 998 |
done |
999 |
||
1000 |
lemmas rsplit_aux_apps [where bs = "[]"] = |
|
1001 |
bin_rsplit_aux_append bin_rsplitl_aux_append |
|
1002 |
||
1003 |
lemmas rsplit_def_auxs = bin_rsplit_def bin_rsplitl_def |
|
1004 |
||
1005 |
lemmas rsplit_aux_alts = rsplit_aux_apps |
|
1006 |
[unfolded append_Nil rsplit_def_auxs [symmetric]] |
|
1007 |
||
1008 |
lemma bin_split_minus: "0 < n ==> bin_split (Suc (n - 1)) w = bin_split n w" |
|
1009 |
by auto |
|
1010 |
||
1011 |
lemmas bin_split_minus_simp = |
|
45604 | 1012 |
bin_split.Suc [THEN [2] bin_split_minus [symmetric, THEN trans]] |
24333 | 1013 |
|
1014 |
lemma bin_split_pred_simp [simp]: |
|
1015 |
"(0::nat) < number_of bin \<Longrightarrow> |
|
1016 |
bin_split (number_of bin) w = |
|
25919
8b1c0d434824
joined theories IntDef, Numeral, IntArith to theory Int
haftmann
parents:
25350
diff
changeset
|
1017 |
(let (w1, w2) = bin_split (number_of (Int.pred bin)) (bin_rest w) |
24333 | 1018 |
in (w1, w2 BIT bin_last w))" |
1019 |
by (simp only: nobm1 bin_split_minus_simp) |
|
1020 |
||
24465 | 1021 |
declare bin_split_pred_simp [simp] |
1022 |
||
24333 | 1023 |
lemma bin_rsplit_aux_simp_alt: |
26557 | 1024 |
"bin_rsplit_aux n m c bs = |
24333 | 1025 |
(if m = 0 \<or> n = 0 |
1026 |
then bs |
|
1027 |
else let (a, b) = bin_split n c in bin_rsplit n (m - n, a) @ b # bs)" |
|
26557 | 1028 |
unfolding bin_rsplit_aux.simps [of n m c bs] |
1029 |
apply simp |
|
1030 |
apply (subst rsplit_aux_alts) |
|
1031 |
apply (simp add: bin_rsplit_def) |
|
24333 | 1032 |
done |
1033 |
||
1034 |
lemmas bin_rsplit_simp_alt = |
|
45604 | 1035 |
trans [OF bin_rsplit_def bin_rsplit_aux_simp_alt] |
24333 | 1036 |
|
1037 |
lemmas bthrs = bin_rsplit_simp_alt [THEN [2] trans] |
|
1038 |
||
1039 |
lemma bin_rsplit_size_sign' [rule_format] : |
|
1040 |
"n > 0 ==> (ALL nw w. rev sw = bin_rsplit n (nw, w) --> |
|
1041 |
(ALL v: set sw. bintrunc n v = v))" |
|
1042 |
apply (induct sw) |
|
1043 |
apply clarsimp |
|
1044 |
apply clarsimp |
|
1045 |
apply (drule bthrs) |
|
1046 |
apply (simp (no_asm_use) add: Let_def split: ls_splits) |
|
1047 |
apply clarify |
|
1048 |
apply (erule impE, rule exI, erule exI) |
|
1049 |
apply (drule split_bintrunc) |
|
1050 |
apply simp |
|
1051 |
done |
|
1052 |
||
1053 |
lemmas bin_rsplit_size_sign = bin_rsplit_size_sign' [OF asm_rl |
|
45604 | 1054 |
rev_rev_ident [THEN trans] set_rev [THEN equalityD2 [THEN subsetD]]] |
24333 | 1055 |
|
1056 |
lemma bin_nth_rsplit [rule_format] : |
|
1057 |
"n > 0 ==> m < n ==> (ALL w k nw. rev sw = bin_rsplit n (nw, w) --> |
|
1058 |
k < size sw --> bin_nth (sw ! k) m = bin_nth w (k * n + m))" |
|
1059 |
apply (induct sw) |
|
1060 |
apply clarsimp |
|
1061 |
apply clarsimp |
|
1062 |
apply (drule bthrs) |
|
1063 |
apply (simp (no_asm_use) add: Let_def split: ls_splits) |
|
1064 |
apply clarify |
|
1065 |
apply (erule allE, erule impE, erule exI) |
|
1066 |
apply (case_tac k) |
|
1067 |
apply clarsimp |
|
1068 |
prefer 2 |
|
1069 |
apply clarsimp |
|
1070 |
apply (erule allE) |
|
1071 |
apply (erule (1) impE) |
|
1072 |
apply (drule bin_nth_split, erule conjE, erule allE, |
|
1073 |
erule trans, simp add : add_ac)+ |
|
1074 |
done |
|
1075 |
||
1076 |
lemma bin_rsplit_all: |
|
1077 |
"0 < nw ==> nw <= n ==> bin_rsplit n (nw, w) = [bintrunc n w]" |
|
1078 |
unfolding bin_rsplit_def |
|
1079 |
by (clarsimp dest!: split_bintrunc simp: rsplit_aux_simp2ls split: ls_splits) |
|
1080 |
||
1081 |
lemma bin_rsplit_l [rule_format] : |
|
1082 |
"ALL bin. bin_rsplitl n (m, bin) = bin_rsplit n (m, bintrunc m bin)" |
|
1083 |
apply (rule_tac a = "m" in wf_less_than [THEN wf_induct]) |
|
1084 |
apply (simp (no_asm) add : bin_rsplitl_def bin_rsplit_def) |
|
1085 |
apply (rule allI) |
|
1086 |
apply (subst bin_rsplitl_aux.simps) |
|
1087 |
apply (subst bin_rsplit_aux.simps) |
|
26557 | 1088 |
apply (clarsimp simp: Let_def split: ls_splits) |
24333 | 1089 |
apply (drule bin_split_trunc) |
1090 |
apply (drule sym [THEN trans], assumption) |
|
26557 | 1091 |
apply (subst rsplit_aux_alts(1)) |
1092 |
apply (subst rsplit_aux_alts(2)) |
|
1093 |
apply clarsimp |
|
1094 |
unfolding bin_rsplit_def bin_rsplitl_def |
|
1095 |
apply simp |
|
24333 | 1096 |
done |
26557 | 1097 |
|
24333 | 1098 |
lemma bin_rsplit_rcat [rule_format] : |
1099 |
"n > 0 --> bin_rsplit n (n * size ws, bin_rcat n ws) = map (bintrunc n) ws" |
|
1100 |
apply (unfold bin_rsplit_def bin_rcat_def) |
|
1101 |
apply (rule_tac xs = "ws" in rev_induct) |
|
1102 |
apply clarsimp |
|
1103 |
apply clarsimp |
|
26557 | 1104 |
apply (subst rsplit_aux_alts) |
1105 |
unfolding bin_split_cat |
|
1106 |
apply simp |
|
24333 | 1107 |
done |
1108 |
||
1109 |
lemma bin_rsplit_aux_len_le [rule_format] : |
|
26557 | 1110 |
"\<forall>ws m. n \<noteq> 0 \<longrightarrow> ws = bin_rsplit_aux n nw w bs \<longrightarrow> |
1111 |
length ws \<le> m \<longleftrightarrow> nw + length bs * n \<le> m * n" |
|
1112 |
apply (induct n nw w bs rule: bin_rsplit_aux.induct) |
|
24333 | 1113 |
apply (subst bin_rsplit_aux.simps) |
26557 | 1114 |
apply (simp add: lrlem Let_def split: ls_splits) |
24333 | 1115 |
done |
1116 |
||
1117 |
lemma bin_rsplit_len_le: |
|
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset
|
1118 |
"n \<noteq> 0 --> ws = bin_rsplit n (nw, w) --> (length ws <= m) = (nw <= m * n)" |
24333 | 1119 |
unfolding bin_rsplit_def by (clarsimp simp add : bin_rsplit_aux_len_le) |
1120 |
||
1121 |
lemma bin_rsplit_aux_len [rule_format] : |
|
26557 | 1122 |
"n\<noteq>0 --> length (bin_rsplit_aux n nw w cs) = |
24333 | 1123 |
(nw + n - 1) div n + length cs" |
26557 | 1124 |
apply (induct n nw w cs rule: bin_rsplit_aux.induct) |
24333 | 1125 |
apply (subst bin_rsplit_aux.simps) |
1126 |
apply (clarsimp simp: Let_def split: ls_splits) |
|
1127 |
apply (erule thin_rl) |
|
27651
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27105
diff
changeset
|
1128 |
apply (case_tac m) |
16a26996c30e
moved op dvd to theory Ring_and_Field; generalized a couple of lemmas
haftmann
parents:
27105
diff
changeset
|
1129 |
apply simp |
24333 | 1130 |
apply (case_tac "m <= n") |
27677 | 1131 |
apply auto |
24333 | 1132 |
done |
1133 |
||
1134 |
lemma bin_rsplit_len: |
|
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset
|
1135 |
"n\<noteq>0 ==> length (bin_rsplit n (nw, w)) = (nw + n - 1) div n" |
24333 | 1136 |
unfolding bin_rsplit_def by (clarsimp simp add : bin_rsplit_aux_len) |
1137 |
||
26557 | 1138 |
lemma bin_rsplit_aux_len_indep: |
1139 |
"n \<noteq> 0 \<Longrightarrow> length bs = length cs \<Longrightarrow> |
|
1140 |
length (bin_rsplit_aux n nw v bs) = |
|
1141 |
length (bin_rsplit_aux n nw w cs)" |
|
1142 |
proof (induct n nw w cs arbitrary: v bs rule: bin_rsplit_aux.induct) |
|
1143 |
case (1 n m w cs v bs) show ?case |
|
1144 |
proof (cases "m = 0") |
|
28298 | 1145 |
case True then show ?thesis using `length bs = length cs` by simp |
26557 | 1146 |
next |
1147 |
case False |
|
1148 |
from "1.hyps" `m \<noteq> 0` `n \<noteq> 0` have hyp: "\<And>v bs. length bs = Suc (length cs) \<Longrightarrow> |
|
1149 |
length (bin_rsplit_aux n (m - n) v bs) = |
|
1150 |
length (bin_rsplit_aux n (m - n) (fst (bin_split n w)) (snd (bin_split n w) # cs))" |
|
1151 |
by auto |
|
1152 |
show ?thesis using `length bs = length cs` `n \<noteq> 0` |
|
1153 |
by (auto simp add: bin_rsplit_aux_simp_alt Let_def bin_rsplit_len |
|
1154 |
split: ls_splits) |
|
1155 |
qed |
|
1156 |
qed |
|
24333 | 1157 |
|
1158 |
lemma bin_rsplit_len_indep: |
|
25134
3d4953e88449
Eliminated most of the neq0_conv occurrences. As a result, many
nipkow
parents:
25112
diff
changeset
|
1159 |
"n\<noteq>0 ==> length (bin_rsplit n (nw, v)) = length (bin_rsplit n (nw, w))" |
24333 | 1160 |
apply (unfold bin_rsplit_def) |
26557 | 1161 |
apply (simp (no_asm)) |
24333 | 1162 |
apply (erule bin_rsplit_aux_len_indep) |
1163 |
apply (rule refl) |
|
1164 |
done |
|
1165 |
||
1166 |
end |