15647
|
1 |
(* AUTOMATICALLY GENERATED, DO NOT EDIT! *)
|
|
2 |
|
17566
|
3 |
theory HOL4Prob imports HOL4Real begin
|
14516
|
4 |
|
|
5 |
;setup_theory prob_extra
|
|
6 |
|
17644
|
7 |
lemma BOOL_BOOL_CASES_THM: "ALL f::bool => bool.
|
|
8 |
f = (%b::bool. False) |
|
|
9 |
f = (%b::bool. True) | f = (%b::bool. b) | f = Not"
|
14516
|
10 |
by (import prob_extra BOOL_BOOL_CASES_THM)
|
|
11 |
|
17652
|
12 |
lemma EVEN_ODD_BASIC: "EVEN 0 & ~ EVEN 1 & EVEN 2 & ~ ODD 0 & ODD 1 & ~ ODD 2"
|
14516
|
13 |
by (import prob_extra EVEN_ODD_BASIC)
|
|
14 |
|
17644
|
15 |
lemma EVEN_ODD_EXISTS_EQ: "ALL n::nat.
|
17652
|
16 |
EVEN n = (EX m::nat. n = 2 * m) & ODD n = (EX m::nat. n = Suc (2 * m))"
|
14516
|
17 |
by (import prob_extra EVEN_ODD_EXISTS_EQ)
|
|
18 |
|
17644
|
19 |
lemma DIV_THEN_MULT: "ALL (p::nat) q::nat. Suc q * (p div Suc q) <= p"
|
14516
|
20 |
by (import prob_extra DIV_THEN_MULT)
|
|
21 |
|
17694
|
22 |
lemma DIV_TWO_UNIQUE: "ALL (n::nat) (q::nat) r::nat.
|
|
23 |
n = 2 * q + r & (r = 0 | r = 1) --> q = n div 2 & r = n mod 2"
|
14516
|
24 |
by (import prob_extra DIV_TWO_UNIQUE)
|
|
25 |
|
17652
|
26 |
lemma DIVISION_TWO: "ALL n::nat. n = 2 * (n div 2) + n mod 2 & (n mod 2 = 0 | n mod 2 = 1)"
|
14516
|
27 |
by (import prob_extra DIVISION_TWO)
|
|
28 |
|
17652
|
29 |
lemma DIV_TWO: "ALL n::nat. n = 2 * (n div 2) + n mod 2"
|
14516
|
30 |
by (import prob_extra DIV_TWO)
|
|
31 |
|
17652
|
32 |
lemma MOD_TWO: "ALL n::nat. n mod 2 = (if EVEN n then 0 else 1)"
|
14516
|
33 |
by (import prob_extra MOD_TWO)
|
|
34 |
|
17652
|
35 |
lemma DIV_TWO_BASIC: "(op &::bool => bool => bool)
|
|
36 |
((op =::nat => nat => bool)
|
|
37 |
((op div::nat => nat => nat) (0::nat)
|
20485
|
38 |
((number_of \<Colon> int => nat)
|
|
39 |
((op BIT \<Colon> int => bit => int)
|
|
40 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
41 |
(bit.B0::bit))))
|
|
42 |
(0::nat))
|
|
43 |
((op &::bool => bool => bool)
|
|
44 |
((op =::nat => nat => bool)
|
|
45 |
((op div::nat => nat => nat) (1::nat)
|
20485
|
46 |
((number_of \<Colon> int => nat)
|
|
47 |
((op BIT \<Colon> int => bit => int)
|
|
48 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
49 |
(bit.B0::bit))))
|
|
50 |
(0::nat))
|
|
51 |
((op =::nat => nat => bool)
|
|
52 |
((op div::nat => nat => nat)
|
20485
|
53 |
((number_of \<Colon> int => nat)
|
|
54 |
((op BIT \<Colon> int => bit => int)
|
|
55 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
56 |
(bit.B0::bit)))
|
20485
|
57 |
((number_of \<Colon> int => nat)
|
|
58 |
((op BIT \<Colon> int => bit => int)
|
|
59 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
60 |
(bit.B0::bit))))
|
|
61 |
(1::nat)))"
|
14516
|
62 |
by (import prob_extra DIV_TWO_BASIC)
|
|
63 |
|
17694
|
64 |
lemma DIV_TWO_MONO: "ALL (m::nat) n::nat. m div 2 < n div 2 --> m < n"
|
14516
|
65 |
by (import prob_extra DIV_TWO_MONO)
|
|
66 |
|
17694
|
67 |
lemma DIV_TWO_MONO_EVEN: "ALL (m::nat) n::nat. EVEN n --> (m div 2 < n div 2) = (m < n)"
|
14516
|
68 |
by (import prob_extra DIV_TWO_MONO_EVEN)
|
|
69 |
|
17652
|
70 |
lemma DIV_TWO_CANCEL: "ALL n::nat. 2 * n div 2 = n & Suc (2 * n) div 2 = n"
|
14516
|
71 |
by (import prob_extra DIV_TWO_CANCEL)
|
|
72 |
|
17652
|
73 |
lemma EXP_DIV_TWO: "(All::(nat => bool) => bool)
|
|
74 |
(%n::nat.
|
|
75 |
(op =::nat => nat => bool)
|
|
76 |
((op div::nat => nat => nat)
|
|
77 |
((op ^::nat => nat => nat)
|
20485
|
78 |
((number_of \<Colon> int => nat)
|
|
79 |
((op BIT \<Colon> int => bit => int)
|
|
80 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
81 |
(bit.B0::bit)))
|
|
82 |
((Suc::nat => nat) n))
|
20485
|
83 |
((number_of \<Colon> int => nat)
|
|
84 |
((op BIT \<Colon> int => bit => int)
|
|
85 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
86 |
(bit.B0::bit))))
|
|
87 |
((op ^::nat => nat => nat)
|
20485
|
88 |
((number_of \<Colon> int => nat)
|
|
89 |
((op BIT \<Colon> int => bit => int)
|
|
90 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
91 |
(bit.B0::bit)))
|
|
92 |
n))"
|
14516
|
93 |
by (import prob_extra EXP_DIV_TWO)
|
|
94 |
|
17652
|
95 |
lemma EVEN_EXP_TWO: "ALL n::nat. EVEN (2 ^ n) = (n ~= 0)"
|
14516
|
96 |
by (import prob_extra EVEN_EXP_TWO)
|
|
97 |
|
17652
|
98 |
lemma DIV_TWO_EXP: "ALL (n::nat) k::nat. (k div 2 < 2 ^ n) = (k < 2 ^ Suc n)"
|
14516
|
99 |
by (import prob_extra DIV_TWO_EXP)
|
|
100 |
|
|
101 |
consts
|
|
102 |
inf :: "(real => bool) => real"
|
|
103 |
|
|
104 |
defs
|
17644
|
105 |
inf_primdef: "inf == %P::real => bool. - sup (IMAGE uminus P)"
|
|
106 |
|
|
107 |
lemma inf_def: "ALL P::real => bool. inf P = - sup (IMAGE uminus P)"
|
14516
|
108 |
by (import prob_extra inf_def)
|
|
109 |
|
17644
|
110 |
lemma INF_DEF_ALT: "ALL P::real => bool. inf P = - sup (%r::real. P (- r))"
|
14516
|
111 |
by (import prob_extra INF_DEF_ALT)
|
|
112 |
|
17694
|
113 |
lemma REAL_SUP_EXISTS_UNIQUE: "ALL P::real => bool.
|
|
114 |
Ex P & (EX z::real. ALL x::real. P x --> x <= z) -->
|
|
115 |
(EX! s::real. ALL y::real. (EX x::real. P x & y < x) = (y < s))"
|
14516
|
116 |
by (import prob_extra REAL_SUP_EXISTS_UNIQUE)
|
|
117 |
|
17694
|
118 |
lemma REAL_SUP_MAX: "ALL (P::real => bool) z::real.
|
|
119 |
P z & (ALL x::real. P x --> x <= z) --> sup P = z"
|
14516
|
120 |
by (import prob_extra REAL_SUP_MAX)
|
|
121 |
|
17694
|
122 |
lemma REAL_INF_MIN: "ALL (P::real => bool) z::real.
|
|
123 |
P z & (ALL x::real. P x --> z <= x) --> inf P = z"
|
14516
|
124 |
by (import prob_extra REAL_INF_MIN)
|
|
125 |
|
17652
|
126 |
lemma HALF_POS: "(op <::real => real => bool) (0::real)
|
|
127 |
((op /::real => real => real) (1::real)
|
20485
|
128 |
((number_of \<Colon> int => real)
|
|
129 |
((op BIT \<Colon> int => bit => int)
|
|
130 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
131 |
(bit.B0::bit))))"
|
14516
|
132 |
by (import prob_extra HALF_POS)
|
|
133 |
|
17652
|
134 |
lemma HALF_CANCEL: "(op =::real => real => bool)
|
|
135 |
((op *::real => real => real)
|
20485
|
136 |
((number_of \<Colon> int => real)
|
|
137 |
((op BIT \<Colon> int => bit => int)
|
|
138 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
139 |
(bit.B0::bit)))
|
|
140 |
((op /::real => real => real) (1::real)
|
20485
|
141 |
((number_of \<Colon> int => real)
|
|
142 |
((op BIT \<Colon> int => bit => int)
|
|
143 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
144 |
(bit.B0::bit)))))
|
|
145 |
(1::real)"
|
14516
|
146 |
by (import prob_extra HALF_CANCEL)
|
|
147 |
|
17652
|
148 |
lemma POW_HALF_POS: "(All::(nat => bool) => bool)
|
|
149 |
(%n::nat.
|
|
150 |
(op <::real => real => bool) (0::real)
|
|
151 |
((op ^::real => nat => real)
|
|
152 |
((op /::real => real => real) (1::real)
|
20485
|
153 |
((number_of \<Colon> int => real)
|
|
154 |
((op BIT \<Colon> int => bit => int)
|
|
155 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
156 |
(bit.B0::bit))))
|
|
157 |
n))"
|
14516
|
158 |
by (import prob_extra POW_HALF_POS)
|
|
159 |
|
|
160 |
lemma POW_HALF_MONO: "(All::(nat => bool) => bool)
|
|
161 |
(%m::nat.
|
|
162 |
(All::(nat => bool) => bool)
|
|
163 |
(%n::nat.
|
|
164 |
(op -->::bool => bool => bool) ((op <=::nat => nat => bool) m n)
|
|
165 |
((op <=::real => real => bool)
|
|
166 |
((op ^::real => nat => real)
|
|
167 |
((op /::real => real => real) (1::real)
|
20485
|
168 |
((number_of \<Colon> int => real)
|
|
169 |
((op BIT \<Colon> int => bit => int)
|
|
170 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
|
15647
|
171 |
(bit.B1::bit))
|
|
172 |
(bit.B0::bit))))
|
14516
|
173 |
n)
|
|
174 |
((op ^::real => nat => real)
|
|
175 |
((op /::real => real => real) (1::real)
|
20485
|
176 |
((number_of \<Colon> int => real)
|
|
177 |
((op BIT \<Colon> int => bit => int)
|
|
178 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
|
15647
|
179 |
(bit.B1::bit))
|
|
180 |
(bit.B0::bit))))
|
14516
|
181 |
m))))"
|
|
182 |
by (import prob_extra POW_HALF_MONO)
|
|
183 |
|
17652
|
184 |
lemma POW_HALF_TWICE: "(All::(nat => bool) => bool)
|
|
185 |
(%n::nat.
|
|
186 |
(op =::real => real => bool)
|
|
187 |
((op ^::real => nat => real)
|
|
188 |
((op /::real => real => real) (1::real)
|
20485
|
189 |
((number_of \<Colon> int => real)
|
|
190 |
((op BIT \<Colon> int => bit => int)
|
|
191 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
192 |
(bit.B0::bit))))
|
|
193 |
n)
|
|
194 |
((op *::real => real => real)
|
20485
|
195 |
((number_of \<Colon> int => real)
|
|
196 |
((op BIT \<Colon> int => bit => int)
|
|
197 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
198 |
(bit.B0::bit)))
|
|
199 |
((op ^::real => nat => real)
|
|
200 |
((op /::real => real => real) (1::real)
|
20485
|
201 |
((number_of \<Colon> int => real)
|
|
202 |
((op BIT \<Colon> int => bit => int)
|
|
203 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
|
17652
|
204 |
(bit.B1::bit))
|
|
205 |
(bit.B0::bit))))
|
|
206 |
((Suc::nat => nat) n))))"
|
14516
|
207 |
by (import prob_extra POW_HALF_TWICE)
|
|
208 |
|
17652
|
209 |
lemma X_HALF_HALF: "ALL x::real. 1 / 2 * x + 1 / 2 * x = x"
|
14516
|
210 |
by (import prob_extra X_HALF_HALF)
|
|
211 |
|
17694
|
212 |
lemma REAL_SUP_LE_X: "ALL (P::real => bool) x::real.
|
|
213 |
Ex P & (ALL r::real. P r --> r <= x) --> sup P <= x"
|
14516
|
214 |
by (import prob_extra REAL_SUP_LE_X)
|
|
215 |
|
17694
|
216 |
lemma REAL_X_LE_SUP: "ALL (P::real => bool) x::real.
|
|
217 |
Ex P &
|
|
218 |
(EX z::real. ALL r::real. P r --> r <= z) &
|
|
219 |
(EX r::real. P r & x <= r) -->
|
|
220 |
x <= sup P"
|
14516
|
221 |
by (import prob_extra REAL_X_LE_SUP)
|
|
222 |
|
|
223 |
lemma ABS_BETWEEN_LE: "ALL (x::real) (y::real) d::real.
|
17652
|
224 |
(0 <= d & x - d <= y & y <= x + d) = (abs (y - x) <= d)"
|
14516
|
225 |
by (import prob_extra ABS_BETWEEN_LE)
|
|
226 |
|
17652
|
227 |
lemma ONE_MINUS_HALF: "(op =::real => real => bool)
|
|
228 |
((op -::real => real => real) (1::real)
|
|
229 |
((op /::real => real => real) (1::real)
|
20485
|
230 |
((number_of \<Colon> int => real)
|
|
231 |
((op BIT \<Colon> int => bit => int)
|
|
232 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
233 |
(bit.B0::bit)))))
|
|
234 |
((op /::real => real => real) (1::real)
|
20485
|
235 |
((number_of \<Colon> int => real)
|
|
236 |
((op BIT \<Colon> int => bit => int)
|
|
237 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
238 |
(bit.B0::bit))))"
|
14516
|
239 |
by (import prob_extra ONE_MINUS_HALF)
|
|
240 |
|
17652
|
241 |
lemma HALF_LT_1: "(op <::real => real => bool)
|
|
242 |
((op /::real => real => real) (1::real)
|
20485
|
243 |
((number_of \<Colon> int => real)
|
|
244 |
((op BIT \<Colon> int => bit => int)
|
|
245 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
246 |
(bit.B0::bit))))
|
|
247 |
(1::real)"
|
14516
|
248 |
by (import prob_extra HALF_LT_1)
|
|
249 |
|
17652
|
250 |
lemma POW_HALF_EXP: "(All::(nat => bool) => bool)
|
|
251 |
(%n::nat.
|
|
252 |
(op =::real => real => bool)
|
|
253 |
((op ^::real => nat => real)
|
|
254 |
((op /::real => real => real) (1::real)
|
20485
|
255 |
((number_of \<Colon> int => real)
|
|
256 |
((op BIT \<Colon> int => bit => int)
|
|
257 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
258 |
(bit.B0::bit))))
|
|
259 |
n)
|
|
260 |
((inverse::real => real)
|
|
261 |
((real::nat => real)
|
|
262 |
((op ^::nat => nat => nat)
|
20485
|
263 |
((number_of \<Colon> int => nat)
|
|
264 |
((op BIT \<Colon> int => bit => int)
|
|
265 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
|
17652
|
266 |
(bit.B1::bit))
|
|
267 |
(bit.B0::bit)))
|
|
268 |
n))))"
|
14516
|
269 |
by (import prob_extra POW_HALF_EXP)
|
|
270 |
|
17652
|
271 |
lemma INV_SUC_POS: "ALL n::nat. 0 < 1 / real (Suc n)"
|
14516
|
272 |
by (import prob_extra INV_SUC_POS)
|
|
273 |
|
17652
|
274 |
lemma INV_SUC_MAX: "ALL x::nat. 1 / real (Suc x) <= 1"
|
14516
|
275 |
by (import prob_extra INV_SUC_MAX)
|
|
276 |
|
17652
|
277 |
lemma INV_SUC: "ALL n::nat. 0 < 1 / real (Suc n) & 1 / real (Suc n) <= 1"
|
14516
|
278 |
by (import prob_extra INV_SUC)
|
|
279 |
|
17694
|
280 |
lemma ABS_UNIT_INTERVAL: "ALL (x::real) y::real.
|
|
281 |
0 <= x & x <= 1 & 0 <= y & y <= 1 --> abs (x - y) <= 1"
|
14516
|
282 |
by (import prob_extra ABS_UNIT_INTERVAL)
|
|
283 |
|
17644
|
284 |
lemma MEM_NIL: "ALL l::'a::type list. (ALL x::'a::type. ~ x mem l) = (l = [])"
|
14516
|
285 |
by (import prob_extra MEM_NIL)
|
|
286 |
|
17644
|
287 |
lemma MAP_MEM: "ALL (f::'a::type => 'b::type) (l::'a::type list) x::'b::type.
|
|
288 |
x mem map f l = (EX y::'a::type. y mem l & x = f y)"
|
14516
|
289 |
by (import prob_extra MAP_MEM)
|
|
290 |
|
17644
|
291 |
lemma MEM_NIL_MAP_CONS: "ALL (x::'a::type) l::'a::type list list. ~ [] mem map (op # x) l"
|
14516
|
292 |
by (import prob_extra MEM_NIL_MAP_CONS)
|
|
293 |
|
17644
|
294 |
lemma FILTER_TRUE: "ALL l::'a::type list. [x::'a::type:l. True] = l"
|
14516
|
295 |
by (import prob_extra FILTER_TRUE)
|
|
296 |
|
17644
|
297 |
lemma FILTER_FALSE: "ALL l::'a::type list. [x::'a::type:l. False] = []"
|
14516
|
298 |
by (import prob_extra FILTER_FALSE)
|
|
299 |
|
17694
|
300 |
lemma FILTER_MEM: "ALL (P::'a::type => bool) (x::'a::type) l::'a::type list.
|
|
301 |
x mem filter P l --> P x"
|
14516
|
302 |
by (import prob_extra FILTER_MEM)
|
|
303 |
|
17694
|
304 |
lemma MEM_FILTER: "ALL (P::'a::type => bool) (l::'a::type list) x::'a::type.
|
|
305 |
x mem filter P l --> x mem l"
|
14516
|
306 |
by (import prob_extra MEM_FILTER)
|
|
307 |
|
17644
|
308 |
lemma FILTER_OUT_ELT: "ALL (x::'a::type) l::'a::type list. x mem l | [y::'a::type:l. y ~= x] = l"
|
14516
|
309 |
by (import prob_extra FILTER_OUT_ELT)
|
|
310 |
|
17644
|
311 |
lemma IS_PREFIX_NIL: "ALL x::'a::type list. IS_PREFIX x [] & IS_PREFIX [] x = (x = [])"
|
14516
|
312 |
by (import prob_extra IS_PREFIX_NIL)
|
|
313 |
|
17644
|
314 |
lemma IS_PREFIX_REFL: "ALL x::'a::type list. IS_PREFIX x x"
|
14516
|
315 |
by (import prob_extra IS_PREFIX_REFL)
|
|
316 |
|
17694
|
317 |
lemma IS_PREFIX_ANTISYM: "ALL (x::'a::type list) y::'a::type list.
|
|
318 |
IS_PREFIX y x & IS_PREFIX x y --> x = y"
|
14516
|
319 |
by (import prob_extra IS_PREFIX_ANTISYM)
|
|
320 |
|
17694
|
321 |
lemma IS_PREFIX_TRANS: "ALL (x::'a::type list) (y::'a::type list) z::'a::type list.
|
|
322 |
IS_PREFIX x y & IS_PREFIX y z --> IS_PREFIX x z"
|
14516
|
323 |
by (import prob_extra IS_PREFIX_TRANS)
|
|
324 |
|
17644
|
325 |
lemma IS_PREFIX_BUTLAST: "ALL (x::'a::type) y::'a::type list. IS_PREFIX (x # y) (butlast (x # y))"
|
14516
|
326 |
by (import prob_extra IS_PREFIX_BUTLAST)
|
|
327 |
|
17694
|
328 |
lemma IS_PREFIX_LENGTH: "ALL (x::'a::type list) y::'a::type list.
|
|
329 |
IS_PREFIX y x --> length x <= length y"
|
14516
|
330 |
by (import prob_extra IS_PREFIX_LENGTH)
|
|
331 |
|
17694
|
332 |
lemma IS_PREFIX_LENGTH_ANTI: "ALL (x::'a::type list) y::'a::type list.
|
|
333 |
IS_PREFIX y x & length x = length y --> x = y"
|
14516
|
334 |
by (import prob_extra IS_PREFIX_LENGTH_ANTI)
|
|
335 |
|
17644
|
336 |
lemma IS_PREFIX_SNOC: "ALL (x::'a::type) (y::'a::type list) z::'a::type list.
|
|
337 |
IS_PREFIX (SNOC x y) z = (IS_PREFIX y z | z = SNOC x y)"
|
14516
|
338 |
by (import prob_extra IS_PREFIX_SNOC)
|
|
339 |
|
17644
|
340 |
lemma FOLDR_MAP: "ALL (f::'b::type => 'c::type => 'c::type) (e::'c::type)
|
|
341 |
(g::'a::type => 'b::type) l::'a::type list.
|
|
342 |
foldr f (map g l) e = foldr (%x::'a::type. f (g x)) l e"
|
14516
|
343 |
by (import prob_extra FOLDR_MAP)
|
|
344 |
|
17644
|
345 |
lemma LAST_MEM: "ALL (h::'a::type) t::'a::type list. last (h # t) mem h # t"
|
14516
|
346 |
by (import prob_extra LAST_MEM)
|
|
347 |
|
|
348 |
lemma LAST_MAP_CONS: "ALL (b::bool) (h::bool list) t::bool list list.
|
|
349 |
EX x::bool list. last (map (op # b) (h # t)) = b # x"
|
|
350 |
by (import prob_extra LAST_MAP_CONS)
|
|
351 |
|
17694
|
352 |
lemma EXISTS_LONGEST: "ALL (x::'a::type list) y::'a::type list list.
|
|
353 |
EX z::'a::type list.
|
|
354 |
z mem x # y &
|
|
355 |
(ALL w::'a::type list. w mem x # y --> length w <= length z)"
|
14516
|
356 |
by (import prob_extra EXISTS_LONGEST)
|
|
357 |
|
17644
|
358 |
lemma UNION_DEF_ALT: "ALL (s::'a::type => bool) t::'a::type => bool.
|
|
359 |
pred_set.UNION s t = (%x::'a::type. s x | t x)"
|
14516
|
360 |
by (import prob_extra UNION_DEF_ALT)
|
|
361 |
|
17644
|
362 |
lemma INTER_UNION_RDISTRIB: "ALL (p::'a::type => bool) (q::'a::type => bool) r::'a::type => bool.
|
14516
|
363 |
pred_set.INTER (pred_set.UNION p q) r =
|
|
364 |
pred_set.UNION (pred_set.INTER p r) (pred_set.INTER q r)"
|
|
365 |
by (import prob_extra INTER_UNION_RDISTRIB)
|
|
366 |
|
17644
|
367 |
lemma SUBSET_EQ: "ALL (x::'a::type => bool) xa::'a::type => bool.
|
|
368 |
(x = xa) = (SUBSET x xa & SUBSET xa x)"
|
14516
|
369 |
by (import prob_extra SUBSET_EQ)
|
|
370 |
|
17644
|
371 |
lemma INTER_IS_EMPTY: "ALL (s::'a::type => bool) t::'a::type => bool.
|
|
372 |
(pred_set.INTER s t = EMPTY) = (ALL x::'a::type. ~ s x | ~ t x)"
|
14516
|
373 |
by (import prob_extra INTER_IS_EMPTY)
|
|
374 |
|
17694
|
375 |
lemma UNION_DISJOINT_SPLIT: "ALL (s::'a::type => bool) (t::'a::type => bool) u::'a::type => bool.
|
|
376 |
pred_set.UNION s t = pred_set.UNION s u &
|
|
377 |
pred_set.INTER s t = EMPTY & pred_set.INTER s u = EMPTY -->
|
|
378 |
t = u"
|
14516
|
379 |
by (import prob_extra UNION_DISJOINT_SPLIT)
|
|
380 |
|
17644
|
381 |
lemma GSPEC_DEF_ALT: "ALL f::'a::type => 'b::type * bool.
|
|
382 |
GSPEC f = (%v::'b::type. EX x::'a::type. (v, True) = f x)"
|
14516
|
383 |
by (import prob_extra GSPEC_DEF_ALT)
|
|
384 |
|
|
385 |
;end_setup
|
|
386 |
|
|
387 |
;setup_theory prob_canon
|
|
388 |
|
|
389 |
consts
|
|
390 |
alg_twin :: "bool list => bool list => bool"
|
|
391 |
|
|
392 |
defs
|
17644
|
393 |
alg_twin_primdef: "alg_twin ==
|
|
394 |
%(x::bool list) y::bool list.
|
|
395 |
EX l::bool list. x = SNOC True l & y = SNOC False l"
|
|
396 |
|
|
397 |
lemma alg_twin_def: "ALL (x::bool list) y::bool list.
|
|
398 |
alg_twin x y = (EX l::bool list. x = SNOC True l & y = SNOC False l)"
|
14516
|
399 |
by (import prob_canon alg_twin_def)
|
|
400 |
|
|
401 |
constdefs
|
|
402 |
alg_order_tupled :: "bool list * bool list => bool"
|
|
403 |
"(op ==::(bool list * bool list => bool)
|
|
404 |
=> (bool list * bool list => bool) => prop)
|
|
405 |
(alg_order_tupled::bool list * bool list => bool)
|
|
406 |
((WFREC::(bool list * bool list => bool list * bool list => bool)
|
|
407 |
=> ((bool list * bool list => bool)
|
|
408 |
=> bool list * bool list => bool)
|
|
409 |
=> bool list * bool list => bool)
|
|
410 |
((Eps::((bool list * bool list => bool list * bool list => bool) => bool)
|
|
411 |
=> bool list * bool list => bool list * bool list => bool)
|
|
412 |
(%R::bool list * bool list => bool list * bool list => bool.
|
|
413 |
(op &::bool => bool => bool)
|
|
414 |
((WF::(bool list * bool list => bool list * bool list => bool)
|
|
415 |
=> bool)
|
|
416 |
R)
|
|
417 |
((All::(bool => bool) => bool)
|
|
418 |
(%h'::bool.
|
|
419 |
(All::(bool => bool) => bool)
|
|
420 |
(%h::bool.
|
|
421 |
(All::(bool list => bool) => bool)
|
|
422 |
(%t'::bool list.
|
|
423 |
(All::(bool list => bool) => bool)
|
|
424 |
(%t::bool list.
|
|
425 |
R ((Pair::bool list
|
|
426 |
=> bool list => bool list * bool list)
|
|
427 |
t t')
|
|
428 |
((Pair::bool list
|
|
429 |
=> bool list => bool list * bool list)
|
|
430 |
((op #::bool => bool list => bool list) h
|
|
431 |
t)
|
|
432 |
((op #::bool => bool list => bool list) h'
|
|
433 |
t')))))))))
|
|
434 |
(%alg_order_tupled::bool list * bool list => bool.
|
|
435 |
(split::(bool list => bool list => bool)
|
|
436 |
=> bool list * bool list => bool)
|
|
437 |
(%(v::bool list) v1::bool list.
|
|
438 |
(list_case::bool
|
|
439 |
=> (bool => bool list => bool) => bool list => bool)
|
|
440 |
((list_case::bool
|
|
441 |
=> (bool => bool list => bool)
|
|
442 |
=> bool list => bool)
|
|
443 |
(True::bool) (%(v8::bool) v9::bool list. True::bool) v1)
|
|
444 |
(%(v4::bool) v5::bool list.
|
|
445 |
(list_case::bool
|
|
446 |
=> (bool => bool list => bool)
|
|
447 |
=> bool list => bool)
|
|
448 |
(False::bool)
|
|
449 |
(%(v10::bool) v11::bool list.
|
|
450 |
(op |::bool => bool => bool)
|
|
451 |
((op &::bool => bool => bool)
|
|
452 |
((op =::bool => bool => bool) v4 (True::bool))
|
|
453 |
((op =::bool => bool => bool) v10 (False::bool)))
|
|
454 |
((op &::bool => bool => bool)
|
|
455 |
((op =::bool => bool => bool) v4 v10)
|
|
456 |
(alg_order_tupled
|
|
457 |
((Pair::bool list
|
|
458 |
=> bool list => bool list * bool list)
|
|
459 |
v5 v11))))
|
|
460 |
v1)
|
|
461 |
v)))"
|
|
462 |
|
|
463 |
lemma alg_order_tupled_primitive_def: "(op =::(bool list * bool list => bool)
|
|
464 |
=> (bool list * bool list => bool) => bool)
|
|
465 |
(alg_order_tupled::bool list * bool list => bool)
|
|
466 |
((WFREC::(bool list * bool list => bool list * bool list => bool)
|
|
467 |
=> ((bool list * bool list => bool)
|
|
468 |
=> bool list * bool list => bool)
|
|
469 |
=> bool list * bool list => bool)
|
|
470 |
((Eps::((bool list * bool list => bool list * bool list => bool) => bool)
|
|
471 |
=> bool list * bool list => bool list * bool list => bool)
|
|
472 |
(%R::bool list * bool list => bool list * bool list => bool.
|
|
473 |
(op &::bool => bool => bool)
|
|
474 |
((WF::(bool list * bool list => bool list * bool list => bool)
|
|
475 |
=> bool)
|
|
476 |
R)
|
|
477 |
((All::(bool => bool) => bool)
|
|
478 |
(%h'::bool.
|
|
479 |
(All::(bool => bool) => bool)
|
|
480 |
(%h::bool.
|
|
481 |
(All::(bool list => bool) => bool)
|
|
482 |
(%t'::bool list.
|
|
483 |
(All::(bool list => bool) => bool)
|
|
484 |
(%t::bool list.
|
|
485 |
R ((Pair::bool list
|
|
486 |
=> bool list => bool list * bool list)
|
|
487 |
t t')
|
|
488 |
((Pair::bool list
|
|
489 |
=> bool list => bool list * bool list)
|
|
490 |
((op #::bool => bool list => bool list) h
|
|
491 |
t)
|
|
492 |
((op #::bool => bool list => bool list) h'
|
|
493 |
t')))))))))
|
|
494 |
(%alg_order_tupled::bool list * bool list => bool.
|
|
495 |
(split::(bool list => bool list => bool)
|
|
496 |
=> bool list * bool list => bool)
|
|
497 |
(%(v::bool list) v1::bool list.
|
|
498 |
(list_case::bool
|
|
499 |
=> (bool => bool list => bool) => bool list => bool)
|
|
500 |
((list_case::bool
|
|
501 |
=> (bool => bool list => bool)
|
|
502 |
=> bool list => bool)
|
|
503 |
(True::bool) (%(v8::bool) v9::bool list. True::bool) v1)
|
|
504 |
(%(v4::bool) v5::bool list.
|
|
505 |
(list_case::bool
|
|
506 |
=> (bool => bool list => bool)
|
|
507 |
=> bool list => bool)
|
|
508 |
(False::bool)
|
|
509 |
(%(v10::bool) v11::bool list.
|
|
510 |
(op |::bool => bool => bool)
|
|
511 |
((op &::bool => bool => bool)
|
|
512 |
((op =::bool => bool => bool) v4 (True::bool))
|
|
513 |
((op =::bool => bool => bool) v10 (False::bool)))
|
|
514 |
((op &::bool => bool => bool)
|
|
515 |
((op =::bool => bool => bool) v4 v10)
|
|
516 |
(alg_order_tupled
|
|
517 |
((Pair::bool list
|
|
518 |
=> bool list => bool list * bool list)
|
|
519 |
v5 v11))))
|
|
520 |
v1)
|
|
521 |
v)))"
|
|
522 |
by (import prob_canon alg_order_tupled_primitive_def)
|
|
523 |
|
|
524 |
consts
|
|
525 |
alg_order :: "bool list => bool list => bool"
|
|
526 |
|
|
527 |
defs
|
17644
|
528 |
alg_order_primdef: "alg_order == %(x::bool list) x1::bool list. alg_order_tupled (x, x1)"
|
|
529 |
|
|
530 |
lemma alg_order_curried_def: "ALL (x::bool list) x1::bool list. alg_order x x1 = alg_order_tupled (x, x1)"
|
14516
|
531 |
by (import prob_canon alg_order_curried_def)
|
|
532 |
|
17694
|
533 |
lemma alg_order_ind: "ALL P::bool list => bool list => bool.
|
|
534 |
(ALL (x::bool) xa::bool list. P [] (x # xa)) &
|
|
535 |
P [] [] &
|
|
536 |
(ALL (x::bool) xa::bool list. P (x # xa) []) &
|
|
537 |
(ALL (x::bool) (xa::bool list) (xb::bool) xc::bool list.
|
|
538 |
P xa xc --> P (x # xa) (xb # xc)) -->
|
|
539 |
(ALL x::bool list. All (P x))"
|
14516
|
540 |
by (import prob_canon alg_order_ind)
|
|
541 |
|
17644
|
542 |
lemma alg_order_def: "alg_order [] ((v6::bool) # (v7::bool list)) = True &
|
14516
|
543 |
alg_order [] [] = True &
|
17644
|
544 |
alg_order ((v2::bool) # (v3::bool list)) [] = False &
|
|
545 |
alg_order ((h::bool) # (t::bool list)) ((h'::bool) # (t'::bool list)) =
|
14516
|
546 |
(h = True & h' = False | h = h' & alg_order t t')"
|
|
547 |
by (import prob_canon alg_order_def)
|
|
548 |
|
|
549 |
consts
|
|
550 |
alg_sorted :: "bool list list => bool"
|
|
551 |
|
|
552 |
defs
|
|
553 |
alg_sorted_primdef: "alg_sorted ==
|
17644
|
554 |
WFREC
|
|
555 |
(SOME R::bool list list => bool list list => bool.
|
|
556 |
WF R &
|
|
557 |
(ALL (x::bool list) (z::bool list list) y::bool list.
|
|
558 |
R (y # z) (x # y # z)))
|
|
559 |
(%alg_sorted::bool list list => bool.
|
14516
|
560 |
list_case True
|
17644
|
561 |
(%v2::bool list.
|
|
562 |
list_case True
|
|
563 |
(%(v6::bool list) v7::bool list list.
|
|
564 |
alg_order v2 v6 & alg_sorted (v6 # v7))))"
|
14516
|
565 |
|
|
566 |
lemma alg_sorted_primitive_def: "alg_sorted =
|
17644
|
567 |
WFREC
|
|
568 |
(SOME R::bool list list => bool list list => bool.
|
|
569 |
WF R &
|
|
570 |
(ALL (x::bool list) (z::bool list list) y::bool list.
|
|
571 |
R (y # z) (x # y # z)))
|
|
572 |
(%alg_sorted::bool list list => bool.
|
14516
|
573 |
list_case True
|
17644
|
574 |
(%v2::bool list.
|
|
575 |
list_case True
|
|
576 |
(%(v6::bool list) v7::bool list list.
|
|
577 |
alg_order v2 v6 & alg_sorted (v6 # v7))))"
|
14516
|
578 |
by (import prob_canon alg_sorted_primitive_def)
|
|
579 |
|
17694
|
580 |
lemma alg_sorted_ind: "ALL P::bool list list => bool.
|
|
581 |
(ALL (x::bool list) (y::bool list) z::bool list list.
|
|
582 |
P (y # z) --> P (x # y # z)) &
|
|
583 |
(ALL v::bool list. P [v]) & P [] -->
|
|
584 |
All P"
|
14516
|
585 |
by (import prob_canon alg_sorted_ind)
|
|
586 |
|
17644
|
587 |
lemma alg_sorted_def: "alg_sorted ((x::bool list) # (y::bool list) # (z::bool list list)) =
|
|
588 |
(alg_order x y & alg_sorted (y # z)) &
|
|
589 |
alg_sorted [v::bool list] = True & alg_sorted [] = True"
|
14516
|
590 |
by (import prob_canon alg_sorted_def)
|
|
591 |
|
|
592 |
consts
|
|
593 |
alg_prefixfree :: "bool list list => bool"
|
|
594 |
|
|
595 |
defs
|
|
596 |
alg_prefixfree_primdef: "alg_prefixfree ==
|
17644
|
597 |
WFREC
|
|
598 |
(SOME R::bool list list => bool list list => bool.
|
|
599 |
WF R &
|
|
600 |
(ALL (x::bool list) (z::bool list list) y::bool list.
|
|
601 |
R (y # z) (x # y # z)))
|
|
602 |
(%alg_prefixfree::bool list list => bool.
|
14516
|
603 |
list_case True
|
17644
|
604 |
(%v2::bool list.
|
|
605 |
list_case True
|
|
606 |
(%(v6::bool list) v7::bool list list.
|
|
607 |
~ IS_PREFIX v6 v2 & alg_prefixfree (v6 # v7))))"
|
14516
|
608 |
|
|
609 |
lemma alg_prefixfree_primitive_def: "alg_prefixfree =
|
17644
|
610 |
WFREC
|
|
611 |
(SOME R::bool list list => bool list list => bool.
|
|
612 |
WF R &
|
|
613 |
(ALL (x::bool list) (z::bool list list) y::bool list.
|
|
614 |
R (y # z) (x # y # z)))
|
|
615 |
(%alg_prefixfree::bool list list => bool.
|
14516
|
616 |
list_case True
|
17644
|
617 |
(%v2::bool list.
|
|
618 |
list_case True
|
|
619 |
(%(v6::bool list) v7::bool list list.
|
|
620 |
~ IS_PREFIX v6 v2 & alg_prefixfree (v6 # v7))))"
|
14516
|
621 |
by (import prob_canon alg_prefixfree_primitive_def)
|
|
622 |
|
17694
|
623 |
lemma alg_prefixfree_ind: "ALL P::bool list list => bool.
|
|
624 |
(ALL (x::bool list) (y::bool list) z::bool list list.
|
|
625 |
P (y # z) --> P (x # y # z)) &
|
|
626 |
(ALL v::bool list. P [v]) & P [] -->
|
|
627 |
All P"
|
14516
|
628 |
by (import prob_canon alg_prefixfree_ind)
|
|
629 |
|
17644
|
630 |
lemma alg_prefixfree_def: "alg_prefixfree ((x::bool list) # (y::bool list) # (z::bool list list)) =
|
|
631 |
(~ IS_PREFIX y x & alg_prefixfree (y # z)) &
|
|
632 |
alg_prefixfree [v::bool list] = True & alg_prefixfree [] = True"
|
14516
|
633 |
by (import prob_canon alg_prefixfree_def)
|
|
634 |
|
|
635 |
consts
|
|
636 |
alg_twinfree :: "bool list list => bool"
|
|
637 |
|
|
638 |
defs
|
|
639 |
alg_twinfree_primdef: "alg_twinfree ==
|
17644
|
640 |
WFREC
|
|
641 |
(SOME R::bool list list => bool list list => bool.
|
|
642 |
WF R &
|
|
643 |
(ALL (x::bool list) (z::bool list list) y::bool list.
|
|
644 |
R (y # z) (x # y # z)))
|
|
645 |
(%alg_twinfree::bool list list => bool.
|
14516
|
646 |
list_case True
|
17644
|
647 |
(%v2::bool list.
|
|
648 |
list_case True
|
|
649 |
(%(v6::bool list) v7::bool list list.
|
|
650 |
~ alg_twin v2 v6 & alg_twinfree (v6 # v7))))"
|
14516
|
651 |
|
|
652 |
lemma alg_twinfree_primitive_def: "alg_twinfree =
|
17644
|
653 |
WFREC
|
|
654 |
(SOME R::bool list list => bool list list => bool.
|
|
655 |
WF R &
|
|
656 |
(ALL (x::bool list) (z::bool list list) y::bool list.
|
|
657 |
R (y # z) (x # y # z)))
|
|
658 |
(%alg_twinfree::bool list list => bool.
|
14516
|
659 |
list_case True
|
17644
|
660 |
(%v2::bool list.
|
|
661 |
list_case True
|
|
662 |
(%(v6::bool list) v7::bool list list.
|
|
663 |
~ alg_twin v2 v6 & alg_twinfree (v6 # v7))))"
|
14516
|
664 |
by (import prob_canon alg_twinfree_primitive_def)
|
|
665 |
|
17694
|
666 |
lemma alg_twinfree_ind: "ALL P::bool list list => bool.
|
|
667 |
(ALL (x::bool list) (y::bool list) z::bool list list.
|
|
668 |
P (y # z) --> P (x # y # z)) &
|
|
669 |
(ALL v::bool list. P [v]) & P [] -->
|
|
670 |
All P"
|
14516
|
671 |
by (import prob_canon alg_twinfree_ind)
|
|
672 |
|
17644
|
673 |
lemma alg_twinfree_def: "alg_twinfree ((x::bool list) # (y::bool list) # (z::bool list list)) =
|
|
674 |
(~ alg_twin x y & alg_twinfree (y # z)) &
|
|
675 |
alg_twinfree [v::bool list] = True & alg_twinfree [] = True"
|
14516
|
676 |
by (import prob_canon alg_twinfree_def)
|
|
677 |
|
|
678 |
consts
|
|
679 |
alg_longest :: "bool list list => nat"
|
|
680 |
|
|
681 |
defs
|
17644
|
682 |
alg_longest_primdef: "alg_longest ==
|
17652
|
683 |
FOLDR (%(h::bool list) t::nat. if t <= length h then length h else t) 0"
|
17644
|
684 |
|
|
685 |
lemma alg_longest_def: "alg_longest =
|
17652
|
686 |
FOLDR (%(h::bool list) t::nat. if t <= length h then length h else t) 0"
|
14516
|
687 |
by (import prob_canon alg_longest_def)
|
|
688 |
|
|
689 |
consts
|
|
690 |
alg_canon_prefs :: "bool list => bool list list => bool list list"
|
|
691 |
|
17644
|
692 |
specification (alg_canon_prefs_primdef: alg_canon_prefs) alg_canon_prefs_def: "(ALL l::bool list. alg_canon_prefs l [] = [l]) &
|
|
693 |
(ALL (l::bool list) (h::bool list) t::bool list list.
|
14516
|
694 |
alg_canon_prefs l (h # t) =
|
|
695 |
(if IS_PREFIX h l then alg_canon_prefs l t else l # h # t))"
|
|
696 |
by (import prob_canon alg_canon_prefs_def)
|
|
697 |
|
|
698 |
consts
|
|
699 |
alg_canon_find :: "bool list => bool list list => bool list list"
|
|
700 |
|
17644
|
701 |
specification (alg_canon_find_primdef: alg_canon_find) alg_canon_find_def: "(ALL l::bool list. alg_canon_find l [] = [l]) &
|
|
702 |
(ALL (l::bool list) (h::bool list) t::bool list list.
|
14516
|
703 |
alg_canon_find l (h # t) =
|
|
704 |
(if alg_order h l
|
|
705 |
then if IS_PREFIX l h then h # t else h # alg_canon_find l t
|
|
706 |
else alg_canon_prefs l (h # t)))"
|
|
707 |
by (import prob_canon alg_canon_find_def)
|
|
708 |
|
|
709 |
consts
|
|
710 |
alg_canon1 :: "bool list list => bool list list"
|
|
711 |
|
|
712 |
defs
|
|
713 |
alg_canon1_primdef: "alg_canon1 == FOLDR alg_canon_find []"
|
|
714 |
|
|
715 |
lemma alg_canon1_def: "alg_canon1 = FOLDR alg_canon_find []"
|
|
716 |
by (import prob_canon alg_canon1_def)
|
|
717 |
|
|
718 |
consts
|
|
719 |
alg_canon_merge :: "bool list => bool list list => bool list list"
|
|
720 |
|
17644
|
721 |
specification (alg_canon_merge_primdef: alg_canon_merge) alg_canon_merge_def: "(ALL l::bool list. alg_canon_merge l [] = [l]) &
|
|
722 |
(ALL (l::bool list) (h::bool list) t::bool list list.
|
14516
|
723 |
alg_canon_merge l (h # t) =
|
|
724 |
(if alg_twin l h then alg_canon_merge (butlast h) t else l # h # t))"
|
|
725 |
by (import prob_canon alg_canon_merge_def)
|
|
726 |
|
|
727 |
consts
|
|
728 |
alg_canon2 :: "bool list list => bool list list"
|
|
729 |
|
|
730 |
defs
|
|
731 |
alg_canon2_primdef: "alg_canon2 == FOLDR alg_canon_merge []"
|
|
732 |
|
|
733 |
lemma alg_canon2_def: "alg_canon2 = FOLDR alg_canon_merge []"
|
|
734 |
by (import prob_canon alg_canon2_def)
|
|
735 |
|
|
736 |
consts
|
|
737 |
alg_canon :: "bool list list => bool list list"
|
|
738 |
|
|
739 |
defs
|
17644
|
740 |
alg_canon_primdef: "alg_canon == %l::bool list list. alg_canon2 (alg_canon1 l)"
|
|
741 |
|
|
742 |
lemma alg_canon_def: "ALL l::bool list list. alg_canon l = alg_canon2 (alg_canon1 l)"
|
14516
|
743 |
by (import prob_canon alg_canon_def)
|
|
744 |
|
|
745 |
consts
|
|
746 |
algebra_canon :: "bool list list => bool"
|
|
747 |
|
|
748 |
defs
|
17644
|
749 |
algebra_canon_primdef: "algebra_canon == %l::bool list list. alg_canon l = l"
|
|
750 |
|
|
751 |
lemma algebra_canon_def: "ALL l::bool list list. algebra_canon l = (alg_canon l = l)"
|
14516
|
752 |
by (import prob_canon algebra_canon_def)
|
|
753 |
|
17644
|
754 |
lemma ALG_TWIN_NIL: "ALL l::bool list. ~ alg_twin l [] & ~ alg_twin [] l"
|
14516
|
755 |
by (import prob_canon ALG_TWIN_NIL)
|
|
756 |
|
17644
|
757 |
lemma ALG_TWIN_SING: "ALL (x::bool) l::bool list.
|
14516
|
758 |
alg_twin [x] l = (x = True & l = [False]) &
|
|
759 |
alg_twin l [x] = (l = [True] & x = False)"
|
|
760 |
by (import prob_canon ALG_TWIN_SING)
|
|
761 |
|
17644
|
762 |
lemma ALG_TWIN_CONS: "ALL (x::bool) (y::bool) (z::bool list) (h::bool) t::bool list.
|
14516
|
763 |
alg_twin (x # y # z) (h # t) = (x = h & alg_twin (y # z) t) &
|
|
764 |
alg_twin (h # t) (x # y # z) = (x = h & alg_twin t (y # z))"
|
|
765 |
by (import prob_canon ALG_TWIN_CONS)
|
|
766 |
|
17644
|
767 |
lemma ALG_TWIN_REDUCE: "ALL (h::bool) (t::bool list) t'::bool list.
|
|
768 |
alg_twin (h # t) (h # t') = alg_twin t t'"
|
14516
|
769 |
by (import prob_canon ALG_TWIN_REDUCE)
|
|
770 |
|
17694
|
771 |
lemma ALG_TWINS_PREFIX: "ALL (x::bool list) l::bool list.
|
|
772 |
IS_PREFIX x l -->
|
|
773 |
x = l | IS_PREFIX x (SNOC True l) | IS_PREFIX x (SNOC False l)"
|
14516
|
774 |
by (import prob_canon ALG_TWINS_PREFIX)
|
|
775 |
|
17644
|
776 |
lemma ALG_ORDER_NIL: "ALL x::bool list. alg_order [] x & alg_order x [] = (x = [])"
|
14516
|
777 |
by (import prob_canon ALG_ORDER_NIL)
|
|
778 |
|
17644
|
779 |
lemma ALG_ORDER_REFL: "ALL x::bool list. alg_order x x"
|
14516
|
780 |
by (import prob_canon ALG_ORDER_REFL)
|
|
781 |
|
17694
|
782 |
lemma ALG_ORDER_ANTISYM: "ALL (x::bool list) y::bool list. alg_order x y & alg_order y x --> x = y"
|
14516
|
783 |
by (import prob_canon ALG_ORDER_ANTISYM)
|
|
784 |
|
17694
|
785 |
lemma ALG_ORDER_TRANS: "ALL (x::bool list) (y::bool list) z::bool list.
|
|
786 |
alg_order x y & alg_order y z --> alg_order x z"
|
14516
|
787 |
by (import prob_canon ALG_ORDER_TRANS)
|
|
788 |
|
17644
|
789 |
lemma ALG_ORDER_TOTAL: "ALL (x::bool list) y::bool list. alg_order x y | alg_order y x"
|
14516
|
790 |
by (import prob_canon ALG_ORDER_TOTAL)
|
|
791 |
|
17694
|
792 |
lemma ALG_ORDER_PREFIX: "ALL (x::bool list) y::bool list. IS_PREFIX y x --> alg_order x y"
|
14516
|
793 |
by (import prob_canon ALG_ORDER_PREFIX)
|
|
794 |
|
17694
|
795 |
lemma ALG_ORDER_PREFIX_ANTI: "ALL (x::bool list) y::bool list. alg_order x y & IS_PREFIX x y --> x = y"
|
14516
|
796 |
by (import prob_canon ALG_ORDER_PREFIX_ANTI)
|
|
797 |
|
17694
|
798 |
lemma ALG_ORDER_PREFIX_MONO: "ALL (x::bool list) (y::bool list) z::bool list.
|
|
799 |
alg_order x y & alg_order y z & IS_PREFIX z x --> IS_PREFIX y x"
|
14516
|
800 |
by (import prob_canon ALG_ORDER_PREFIX_MONO)
|
|
801 |
|
17694
|
802 |
lemma ALG_ORDER_PREFIX_TRANS: "ALL (x::bool list) (y::bool list) z::bool list.
|
|
803 |
alg_order x y & IS_PREFIX y z --> alg_order x z | IS_PREFIX x z"
|
14516
|
804 |
by (import prob_canon ALG_ORDER_PREFIX_TRANS)
|
|
805 |
|
17644
|
806 |
lemma ALG_ORDER_SNOC: "ALL (x::bool) l::bool list. ~ alg_order (SNOC x l) l"
|
14516
|
807 |
by (import prob_canon ALG_ORDER_SNOC)
|
|
808 |
|
17694
|
809 |
lemma ALG_SORTED_MIN: "ALL (h::bool list) t::bool list list.
|
|
810 |
alg_sorted (h # t) --> (ALL x::bool list. x mem t --> alg_order h x)"
|
14516
|
811 |
by (import prob_canon ALG_SORTED_MIN)
|
|
812 |
|
17694
|
813 |
lemma ALG_SORTED_DEF_ALT: "ALL (h::bool list) t::bool list list.
|
|
814 |
alg_sorted (h # t) =
|
|
815 |
((ALL x::bool list. x mem t --> alg_order h x) & alg_sorted t)"
|
14516
|
816 |
by (import prob_canon ALG_SORTED_DEF_ALT)
|
|
817 |
|
17694
|
818 |
lemma ALG_SORTED_TL: "ALL (h::bool list) t::bool list list. alg_sorted (h # t) --> alg_sorted t"
|
14516
|
819 |
by (import prob_canon ALG_SORTED_TL)
|
|
820 |
|
17694
|
821 |
lemma ALG_SORTED_MONO: "ALL (x::bool list) (y::bool list) z::bool list list.
|
|
822 |
alg_sorted (x # y # z) --> alg_sorted (x # z)"
|
14516
|
823 |
by (import prob_canon ALG_SORTED_MONO)
|
|
824 |
|
17644
|
825 |
lemma ALG_SORTED_TLS: "ALL (l::bool list list) b::bool. alg_sorted (map (op # b) l) = alg_sorted l"
|
14516
|
826 |
by (import prob_canon ALG_SORTED_TLS)
|
|
827 |
|
17644
|
828 |
lemma ALG_SORTED_STEP: "ALL (l1::bool list list) l2::bool list list.
|
14516
|
829 |
alg_sorted (map (op # True) l1 @ map (op # False) l2) =
|
|
830 |
(alg_sorted l1 & alg_sorted l2)"
|
|
831 |
by (import prob_canon ALG_SORTED_STEP)
|
|
832 |
|
17644
|
833 |
lemma ALG_SORTED_APPEND: "ALL (h::bool list) (h'::bool list) (t::bool list list) t'::bool list list.
|
14516
|
834 |
alg_sorted ((h # t) @ h' # t') =
|
|
835 |
(alg_sorted (h # t) & alg_sorted (h' # t') & alg_order (last (h # t)) h')"
|
|
836 |
by (import prob_canon ALG_SORTED_APPEND)
|
|
837 |
|
17694
|
838 |
lemma ALG_SORTED_FILTER: "ALL (P::bool list => bool) b::bool list list.
|
|
839 |
alg_sorted b --> alg_sorted (filter P b)"
|
14516
|
840 |
by (import prob_canon ALG_SORTED_FILTER)
|
|
841 |
|
17694
|
842 |
lemma ALG_PREFIXFREE_TL: "ALL (h::bool list) t::bool list list.
|
|
843 |
alg_prefixfree (h # t) --> alg_prefixfree t"
|
14516
|
844 |
by (import prob_canon ALG_PREFIXFREE_TL)
|
|
845 |
|
17694
|
846 |
lemma ALG_PREFIXFREE_MONO: "ALL (x::bool list) (y::bool list) z::bool list list.
|
|
847 |
alg_sorted (x # y # z) & alg_prefixfree (x # y # z) -->
|
|
848 |
alg_prefixfree (x # z)"
|
14516
|
849 |
by (import prob_canon ALG_PREFIXFREE_MONO)
|
|
850 |
|
17694
|
851 |
lemma ALG_PREFIXFREE_ELT: "ALL (h::bool list) t::bool list list.
|
|
852 |
alg_sorted (h # t) & alg_prefixfree (h # t) -->
|
|
853 |
(ALL x::bool list. x mem t --> ~ IS_PREFIX x h & ~ IS_PREFIX h x)"
|
14516
|
854 |
by (import prob_canon ALG_PREFIXFREE_ELT)
|
|
855 |
|
17644
|
856 |
lemma ALG_PREFIXFREE_TLS: "ALL (l::bool list list) b::bool.
|
|
857 |
alg_prefixfree (map (op # b) l) = alg_prefixfree l"
|
14516
|
858 |
by (import prob_canon ALG_PREFIXFREE_TLS)
|
|
859 |
|
17644
|
860 |
lemma ALG_PREFIXFREE_STEP: "ALL (l1::bool list list) l2::bool list list.
|
14516
|
861 |
alg_prefixfree (map (op # True) l1 @ map (op # False) l2) =
|
|
862 |
(alg_prefixfree l1 & alg_prefixfree l2)"
|
|
863 |
by (import prob_canon ALG_PREFIXFREE_STEP)
|
|
864 |
|
17644
|
865 |
lemma ALG_PREFIXFREE_APPEND: "ALL (h::bool list) (h'::bool list) (t::bool list list) t'::bool list list.
|
14516
|
866 |
alg_prefixfree ((h # t) @ h' # t') =
|
|
867 |
(alg_prefixfree (h # t) &
|
|
868 |
alg_prefixfree (h' # t') & ~ IS_PREFIX h' (last (h # t)))"
|
|
869 |
by (import prob_canon ALG_PREFIXFREE_APPEND)
|
|
870 |
|
17694
|
871 |
lemma ALG_PREFIXFREE_FILTER: "ALL (P::bool list => bool) b::bool list list.
|
|
872 |
alg_sorted b & alg_prefixfree b --> alg_prefixfree (filter P b)"
|
14516
|
873 |
by (import prob_canon ALG_PREFIXFREE_FILTER)
|
|
874 |
|
17694
|
875 |
lemma ALG_TWINFREE_TL: "ALL (h::bool list) t::bool list list.
|
|
876 |
alg_twinfree (h # t) --> alg_twinfree t"
|
14516
|
877 |
by (import prob_canon ALG_TWINFREE_TL)
|
|
878 |
|
17644
|
879 |
lemma ALG_TWINFREE_TLS: "ALL (l::bool list list) b::bool.
|
|
880 |
alg_twinfree (map (op # b) l) = alg_twinfree l"
|
14516
|
881 |
by (import prob_canon ALG_TWINFREE_TLS)
|
|
882 |
|
17694
|
883 |
lemma ALG_TWINFREE_STEP1: "ALL (l1::bool list list) l2::bool list list.
|
|
884 |
alg_twinfree (map (op # True) l1 @ map (op # False) l2) -->
|
|
885 |
alg_twinfree l1 & alg_twinfree l2"
|
14516
|
886 |
by (import prob_canon ALG_TWINFREE_STEP1)
|
|
887 |
|
17694
|
888 |
lemma ALG_TWINFREE_STEP2: "ALL (l1::bool list list) l2::bool list list.
|
|
889 |
(~ [] mem l1 | ~ [] mem l2) & alg_twinfree l1 & alg_twinfree l2 -->
|
|
890 |
alg_twinfree (map (op # True) l1 @ map (op # False) l2)"
|
14516
|
891 |
by (import prob_canon ALG_TWINFREE_STEP2)
|
|
892 |
|
17694
|
893 |
lemma ALG_TWINFREE_STEP: "ALL (l1::bool list list) l2::bool list list.
|
|
894 |
~ [] mem l1 | ~ [] mem l2 -->
|
|
895 |
alg_twinfree (map (op # True) l1 @ map (op # False) l2) =
|
|
896 |
(alg_twinfree l1 & alg_twinfree l2)"
|
14516
|
897 |
by (import prob_canon ALG_TWINFREE_STEP)
|
|
898 |
|
17644
|
899 |
lemma ALG_LONGEST_HD: "ALL (h::bool list) t::bool list list. length h <= alg_longest (h # t)"
|
14516
|
900 |
by (import prob_canon ALG_LONGEST_HD)
|
|
901 |
|
17644
|
902 |
lemma ALG_LONGEST_TL: "ALL (h::bool list) t::bool list list. alg_longest t <= alg_longest (h # t)"
|
14516
|
903 |
by (import prob_canon ALG_LONGEST_TL)
|
|
904 |
|
17644
|
905 |
lemma ALG_LONGEST_TLS: "ALL (h::bool list) (t::bool list list) b::bool.
|
|
906 |
alg_longest (map (op # b) (h # t)) = Suc (alg_longest (h # t))"
|
14516
|
907 |
by (import prob_canon ALG_LONGEST_TLS)
|
|
908 |
|
17644
|
909 |
lemma ALG_LONGEST_APPEND: "ALL (l1::bool list list) l2::bool list list.
|
14516
|
910 |
alg_longest l1 <= alg_longest (l1 @ l2) &
|
|
911 |
alg_longest l2 <= alg_longest (l1 @ l2)"
|
|
912 |
by (import prob_canon ALG_LONGEST_APPEND)
|
|
913 |
|
17644
|
914 |
lemma ALG_CANON_PREFS_HD: "ALL (l::bool list) b::bool list list. hd (alg_canon_prefs l b) = l"
|
14516
|
915 |
by (import prob_canon ALG_CANON_PREFS_HD)
|
|
916 |
|
17694
|
917 |
lemma ALG_CANON_PREFS_DELETES: "ALL (l::bool list) (b::bool list list) x::bool list.
|
|
918 |
x mem alg_canon_prefs l b --> x mem l # b"
|
14516
|
919 |
by (import prob_canon ALG_CANON_PREFS_DELETES)
|
|
920 |
|
17694
|
921 |
lemma ALG_CANON_PREFS_SORTED: "ALL (l::bool list) b::bool list list.
|
|
922 |
alg_sorted (l # b) --> alg_sorted (alg_canon_prefs l b)"
|
14516
|
923 |
by (import prob_canon ALG_CANON_PREFS_SORTED)
|
|
924 |
|
17694
|
925 |
lemma ALG_CANON_PREFS_PREFIXFREE: "ALL (l::bool list) b::bool list list.
|
|
926 |
alg_sorted b & alg_prefixfree b --> alg_prefixfree (alg_canon_prefs l b)"
|
14516
|
927 |
by (import prob_canon ALG_CANON_PREFS_PREFIXFREE)
|
|
928 |
|
17694
|
929 |
lemma ALG_CANON_PREFS_CONSTANT: "ALL (l::bool list) b::bool list list.
|
|
930 |
alg_prefixfree (l # b) --> alg_canon_prefs l b = l # b"
|
14516
|
931 |
by (import prob_canon ALG_CANON_PREFS_CONSTANT)
|
|
932 |
|
17644
|
933 |
lemma ALG_CANON_FIND_HD: "ALL (l::bool list) (h::bool list) t::bool list list.
|
14516
|
934 |
hd (alg_canon_find l (h # t)) = l | hd (alg_canon_find l (h # t)) = h"
|
|
935 |
by (import prob_canon ALG_CANON_FIND_HD)
|
|
936 |
|
17694
|
937 |
lemma ALG_CANON_FIND_DELETES: "ALL (l::bool list) (b::bool list list) x::bool list.
|
|
938 |
x mem alg_canon_find l b --> x mem l # b"
|
14516
|
939 |
by (import prob_canon ALG_CANON_FIND_DELETES)
|
|
940 |
|
17694
|
941 |
lemma ALG_CANON_FIND_SORTED: "ALL (l::bool list) b::bool list list.
|
|
942 |
alg_sorted b --> alg_sorted (alg_canon_find l b)"
|
14516
|
943 |
by (import prob_canon ALG_CANON_FIND_SORTED)
|
|
944 |
|
17694
|
945 |
lemma ALG_CANON_FIND_PREFIXFREE: "ALL (l::bool list) b::bool list list.
|
|
946 |
alg_sorted b & alg_prefixfree b --> alg_prefixfree (alg_canon_find l b)"
|
14516
|
947 |
by (import prob_canon ALG_CANON_FIND_PREFIXFREE)
|
|
948 |
|
17694
|
949 |
lemma ALG_CANON_FIND_CONSTANT: "ALL (l::bool list) b::bool list list.
|
|
950 |
alg_sorted (l # b) & alg_prefixfree (l # b) -->
|
|
951 |
alg_canon_find l b = l # b"
|
14516
|
952 |
by (import prob_canon ALG_CANON_FIND_CONSTANT)
|
|
953 |
|
17644
|
954 |
lemma ALG_CANON1_SORTED: "ALL x::bool list list. alg_sorted (alg_canon1 x)"
|
14516
|
955 |
by (import prob_canon ALG_CANON1_SORTED)
|
|
956 |
|
17644
|
957 |
lemma ALG_CANON1_PREFIXFREE: "ALL l::bool list list. alg_prefixfree (alg_canon1 l)"
|
14516
|
958 |
by (import prob_canon ALG_CANON1_PREFIXFREE)
|
|
959 |
|
17694
|
960 |
lemma ALG_CANON1_CONSTANT: "ALL l::bool list list. alg_sorted l & alg_prefixfree l --> alg_canon1 l = l"
|
14516
|
961 |
by (import prob_canon ALG_CANON1_CONSTANT)
|
|
962 |
|
17694
|
963 |
lemma ALG_CANON_MERGE_SORTED_PREFIXFREE_TWINFREE: "ALL (l::bool list) b::bool list list.
|
|
964 |
alg_sorted (l # b) & alg_prefixfree (l # b) & alg_twinfree b -->
|
|
965 |
alg_sorted (alg_canon_merge l b) &
|
|
966 |
alg_prefixfree (alg_canon_merge l b) & alg_twinfree (alg_canon_merge l b)"
|
14516
|
967 |
by (import prob_canon ALG_CANON_MERGE_SORTED_PREFIXFREE_TWINFREE)
|
|
968 |
|
17694
|
969 |
lemma ALG_CANON_MERGE_PREFIXFREE_PRESERVE: "ALL (l::bool list) (b::bool list list) h::bool list.
|
|
970 |
(ALL x::bool list. x mem l # b --> ~ IS_PREFIX h x & ~ IS_PREFIX x h) -->
|
|
971 |
(ALL x::bool list.
|
|
972 |
x mem alg_canon_merge l b --> ~ IS_PREFIX h x & ~ IS_PREFIX x h)"
|
14516
|
973 |
by (import prob_canon ALG_CANON_MERGE_PREFIXFREE_PRESERVE)
|
|
974 |
|
17694
|
975 |
lemma ALG_CANON_MERGE_SHORTENS: "ALL (l::bool list) (b::bool list list) x::bool list.
|
|
976 |
x mem alg_canon_merge l b -->
|
|
977 |
(EX y::bool list. y mem l # b & IS_PREFIX y x)"
|
14516
|
978 |
by (import prob_canon ALG_CANON_MERGE_SHORTENS)
|
|
979 |
|
17694
|
980 |
lemma ALG_CANON_MERGE_CONSTANT: "ALL (l::bool list) b::bool list list.
|
|
981 |
alg_twinfree (l # b) --> alg_canon_merge l b = l # b"
|
14516
|
982 |
by (import prob_canon ALG_CANON_MERGE_CONSTANT)
|
|
983 |
|
17694
|
984 |
lemma ALG_CANON2_PREFIXFREE_PRESERVE: "ALL (x::bool list list) xa::bool list.
|
|
985 |
(ALL xb::bool list.
|
|
986 |
xb mem x --> ~ IS_PREFIX xa xb & ~ IS_PREFIX xb xa) -->
|
|
987 |
(ALL xb::bool list.
|
|
988 |
xb mem alg_canon2 x --> ~ IS_PREFIX xa xb & ~ IS_PREFIX xb xa)"
|
14516
|
989 |
by (import prob_canon ALG_CANON2_PREFIXFREE_PRESERVE)
|
|
990 |
|
17694
|
991 |
lemma ALG_CANON2_SHORTENS: "ALL (x::bool list list) xa::bool list.
|
|
992 |
xa mem alg_canon2 x --> (EX y::bool list. y mem x & IS_PREFIX y xa)"
|
14516
|
993 |
by (import prob_canon ALG_CANON2_SHORTENS)
|
|
994 |
|
17694
|
995 |
lemma ALG_CANON2_SORTED_PREFIXFREE_TWINFREE: "ALL x::bool list list.
|
|
996 |
alg_sorted x & alg_prefixfree x -->
|
|
997 |
alg_sorted (alg_canon2 x) &
|
|
998 |
alg_prefixfree (alg_canon2 x) & alg_twinfree (alg_canon2 x)"
|
14516
|
999 |
by (import prob_canon ALG_CANON2_SORTED_PREFIXFREE_TWINFREE)
|
|
1000 |
|
17694
|
1001 |
lemma ALG_CANON2_CONSTANT: "ALL l::bool list list. alg_twinfree l --> alg_canon2 l = l"
|
14516
|
1002 |
by (import prob_canon ALG_CANON2_CONSTANT)
|
|
1003 |
|
17644
|
1004 |
lemma ALG_CANON_SORTED_PREFIXFREE_TWINFREE: "ALL l::bool list list.
|
14516
|
1005 |
alg_sorted (alg_canon l) &
|
|
1006 |
alg_prefixfree (alg_canon l) & alg_twinfree (alg_canon l)"
|
|
1007 |
by (import prob_canon ALG_CANON_SORTED_PREFIXFREE_TWINFREE)
|
|
1008 |
|
17694
|
1009 |
lemma ALG_CANON_CONSTANT: "ALL l::bool list list.
|
|
1010 |
alg_sorted l & alg_prefixfree l & alg_twinfree l --> alg_canon l = l"
|
14516
|
1011 |
by (import prob_canon ALG_CANON_CONSTANT)
|
|
1012 |
|
17644
|
1013 |
lemma ALG_CANON_IDEMPOT: "ALL l::bool list list. alg_canon (alg_canon l) = alg_canon l"
|
14516
|
1014 |
by (import prob_canon ALG_CANON_IDEMPOT)
|
|
1015 |
|
17644
|
1016 |
lemma ALGEBRA_CANON_DEF_ALT: "ALL l::bool list list.
|
|
1017 |
algebra_canon l = (alg_sorted l & alg_prefixfree l & alg_twinfree l)"
|
14516
|
1018 |
by (import prob_canon ALGEBRA_CANON_DEF_ALT)
|
|
1019 |
|
17644
|
1020 |
lemma ALGEBRA_CANON_BASIC: "algebra_canon [] &
|
|
1021 |
algebra_canon [[]] & (ALL x::bool list. algebra_canon [x])"
|
14516
|
1022 |
by (import prob_canon ALGEBRA_CANON_BASIC)
|
|
1023 |
|
17644
|
1024 |
lemma ALG_CANON_BASIC: "alg_canon [] = [] &
|
|
1025 |
alg_canon [[]] = [[]] & (ALL x::bool list. alg_canon [x] = [x])"
|
14516
|
1026 |
by (import prob_canon ALG_CANON_BASIC)
|
|
1027 |
|
17694
|
1028 |
lemma ALGEBRA_CANON_TL: "ALL (h::bool list) t::bool list list.
|
|
1029 |
algebra_canon (h # t) --> algebra_canon t"
|
14516
|
1030 |
by (import prob_canon ALGEBRA_CANON_TL)
|
|
1031 |
|
17644
|
1032 |
lemma ALGEBRA_CANON_NIL_MEM: "ALL l::bool list list. (algebra_canon l & [] mem l) = (l = [[]])"
|
14516
|
1033 |
by (import prob_canon ALGEBRA_CANON_NIL_MEM)
|
|
1034 |
|
17644
|
1035 |
lemma ALGEBRA_CANON_TLS: "ALL (l::bool list list) b::bool.
|
|
1036 |
algebra_canon (map (op # b) l) = algebra_canon l"
|
14516
|
1037 |
by (import prob_canon ALGEBRA_CANON_TLS)
|
|
1038 |
|
17694
|
1039 |
lemma ALGEBRA_CANON_STEP1: "ALL (l1::bool list list) l2::bool list list.
|
|
1040 |
algebra_canon (map (op # True) l1 @ map (op # False) l2) -->
|
|
1041 |
algebra_canon l1 & algebra_canon l2"
|
14516
|
1042 |
by (import prob_canon ALGEBRA_CANON_STEP1)
|
|
1043 |
|
17694
|
1044 |
lemma ALGEBRA_CANON_STEP2: "ALL (l1::bool list list) l2::bool list list.
|
|
1045 |
(l1 ~= [[]] | l2 ~= [[]]) & algebra_canon l1 & algebra_canon l2 -->
|
|
1046 |
algebra_canon (map (op # True) l1 @ map (op # False) l2)"
|
14516
|
1047 |
by (import prob_canon ALGEBRA_CANON_STEP2)
|
|
1048 |
|
17694
|
1049 |
lemma ALGEBRA_CANON_STEP: "ALL (l1::bool list list) l2::bool list list.
|
|
1050 |
l1 ~= [[]] | l2 ~= [[]] -->
|
|
1051 |
algebra_canon (map (op # True) l1 @ map (op # False) l2) =
|
|
1052 |
(algebra_canon l1 & algebra_canon l2)"
|
14516
|
1053 |
by (import prob_canon ALGEBRA_CANON_STEP)
|
|
1054 |
|
17694
|
1055 |
lemma ALGEBRA_CANON_CASES_THM: "ALL l::bool list list.
|
|
1056 |
algebra_canon l -->
|
|
1057 |
l = [] |
|
|
1058 |
l = [[]] |
|
|
1059 |
(EX (l1::bool list list) l2::bool list list.
|
|
1060 |
algebra_canon l1 &
|
|
1061 |
algebra_canon l2 & l = map (op # True) l1 @ map (op # False) l2)"
|
14516
|
1062 |
by (import prob_canon ALGEBRA_CANON_CASES_THM)
|
|
1063 |
|
17694
|
1064 |
lemma ALGEBRA_CANON_CASES: "ALL P::bool list list => bool.
|
|
1065 |
P [] &
|
|
1066 |
P [[]] &
|
|
1067 |
(ALL (l1::bool list list) l2::bool list list.
|
|
1068 |
algebra_canon l1 &
|
|
1069 |
algebra_canon l2 &
|
|
1070 |
algebra_canon (map (op # True) l1 @ map (op # False) l2) -->
|
|
1071 |
P (map (op # True) l1 @ map (op # False) l2)) -->
|
|
1072 |
(ALL l::bool list list. algebra_canon l --> P l)"
|
14516
|
1073 |
by (import prob_canon ALGEBRA_CANON_CASES)
|
|
1074 |
|
17694
|
1075 |
lemma ALGEBRA_CANON_INDUCTION: "ALL P::bool list list => bool.
|
|
1076 |
P [] &
|
|
1077 |
P [[]] &
|
|
1078 |
(ALL (l1::bool list list) l2::bool list list.
|
|
1079 |
algebra_canon l1 &
|
|
1080 |
algebra_canon l2 &
|
|
1081 |
P l1 &
|
|
1082 |
P l2 & algebra_canon (map (op # True) l1 @ map (op # False) l2) -->
|
|
1083 |
P (map (op # True) l1 @ map (op # False) l2)) -->
|
|
1084 |
(ALL l::bool list list. algebra_canon l --> P l)"
|
14516
|
1085 |
by (import prob_canon ALGEBRA_CANON_INDUCTION)
|
|
1086 |
|
17644
|
1087 |
lemma MEM_NIL_STEP: "ALL (l1::bool list list) l2::bool list list.
|
|
1088 |
~ [] mem map (op # True) l1 @ map (op # False) l2"
|
14516
|
1089 |
by (import prob_canon MEM_NIL_STEP)
|
|
1090 |
|
17644
|
1091 |
lemma ALG_SORTED_PREFIXFREE_MEM_NIL: "ALL l::bool list list.
|
|
1092 |
(alg_sorted l & alg_prefixfree l & [] mem l) = (l = [[]])"
|
14516
|
1093 |
by (import prob_canon ALG_SORTED_PREFIXFREE_MEM_NIL)
|
|
1094 |
|
17694
|
1095 |
lemma ALG_SORTED_PREFIXFREE_EQUALITY: "ALL (l::bool list list) l'::bool list list.
|
|
1096 |
(ALL x::bool list. x mem l = x mem l') &
|
|
1097 |
alg_sorted l & alg_sorted l' & alg_prefixfree l & alg_prefixfree l' -->
|
|
1098 |
l = l'"
|
14516
|
1099 |
by (import prob_canon ALG_SORTED_PREFIXFREE_EQUALITY)
|
|
1100 |
|
|
1101 |
;end_setup
|
|
1102 |
|
|
1103 |
;setup_theory boolean_sequence
|
|
1104 |
|
|
1105 |
consts
|
|
1106 |
SHD :: "(nat => bool) => bool"
|
|
1107 |
|
|
1108 |
defs
|
17652
|
1109 |
SHD_primdef: "SHD == %f::nat => bool. f 0"
|
|
1110 |
|
|
1111 |
lemma SHD_def: "ALL f::nat => bool. SHD f = f 0"
|
14516
|
1112 |
by (import boolean_sequence SHD_def)
|
|
1113 |
|
|
1114 |
consts
|
|
1115 |
STL :: "(nat => bool) => nat => bool"
|
|
1116 |
|
|
1117 |
defs
|
17644
|
1118 |
STL_primdef: "STL == %(f::nat => bool) n::nat. f (Suc n)"
|
|
1119 |
|
|
1120 |
lemma STL_def: "ALL (f::nat => bool) n::nat. STL f n = f (Suc n)"
|
14516
|
1121 |
by (import boolean_sequence STL_def)
|
|
1122 |
|
|
1123 |
consts
|
|
1124 |
SCONS :: "bool => (nat => bool) => nat => bool"
|
|
1125 |
|
17652
|
1126 |
specification (SCONS_primdef: SCONS) SCONS_def: "(ALL (h::bool) t::nat => bool. SCONS h t 0 = h) &
|
17644
|
1127 |
(ALL (h::bool) (t::nat => bool) n::nat. SCONS h t (Suc n) = t n)"
|
14516
|
1128 |
by (import boolean_sequence SCONS_def)
|
|
1129 |
|
|
1130 |
consts
|
|
1131 |
SDEST :: "(nat => bool) => bool * (nat => bool)"
|
|
1132 |
|
|
1133 |
defs
|
17644
|
1134 |
SDEST_primdef: "SDEST == %s::nat => bool. (SHD s, STL s)"
|
|
1135 |
|
|
1136 |
lemma SDEST_def: "SDEST = (%s::nat => bool. (SHD s, STL s))"
|
14516
|
1137 |
by (import boolean_sequence SDEST_def)
|
|
1138 |
|
|
1139 |
consts
|
|
1140 |
SCONST :: "bool => nat => bool"
|
|
1141 |
|
|
1142 |
defs
|
|
1143 |
SCONST_primdef: "SCONST == K"
|
|
1144 |
|
|
1145 |
lemma SCONST_def: "SCONST = K"
|
|
1146 |
by (import boolean_sequence SCONST_def)
|
|
1147 |
|
|
1148 |
consts
|
|
1149 |
STAKE :: "nat => (nat => bool) => bool list"
|
|
1150 |
|
17652
|
1151 |
specification (STAKE_primdef: STAKE) STAKE_def: "(ALL s::nat => bool. STAKE 0 s = []) &
|
17644
|
1152 |
(ALL (n::nat) s::nat => bool. STAKE (Suc n) s = SHD s # STAKE n (STL s))"
|
14516
|
1153 |
by (import boolean_sequence STAKE_def)
|
|
1154 |
|
|
1155 |
consts
|
|
1156 |
SDROP :: "nat => (nat => bool) => nat => bool"
|
|
1157 |
|
17652
|
1158 |
specification (SDROP_primdef: SDROP) SDROP_def: "SDROP 0 = I & (ALL n::nat. SDROP (Suc n) = SDROP n o STL)"
|
14516
|
1159 |
by (import boolean_sequence SDROP_def)
|
|
1160 |
|
17644
|
1161 |
lemma SCONS_SURJ: "ALL x::nat => bool. EX (xa::bool) t::nat => bool. x = SCONS xa t"
|
14516
|
1162 |
by (import boolean_sequence SCONS_SURJ)
|
|
1163 |
|
17644
|
1164 |
lemma SHD_STL_ISO: "ALL (h::bool) t::nat => bool. EX x::nat => bool. SHD x = h & STL x = t"
|
14516
|
1165 |
by (import boolean_sequence SHD_STL_ISO)
|
|
1166 |
|
17644
|
1167 |
lemma SHD_SCONS: "ALL (h::bool) t::nat => bool. SHD (SCONS h t) = h"
|
14516
|
1168 |
by (import boolean_sequence SHD_SCONS)
|
|
1169 |
|
17644
|
1170 |
lemma STL_SCONS: "ALL (h::bool) t::nat => bool. STL (SCONS h t) = t"
|
14516
|
1171 |
by (import boolean_sequence STL_SCONS)
|
|
1172 |
|
17644
|
1173 |
lemma SHD_SCONST: "ALL b::bool. SHD (SCONST b) = b"
|
14516
|
1174 |
by (import boolean_sequence SHD_SCONST)
|
|
1175 |
|
17644
|
1176 |
lemma STL_SCONST: "ALL b::bool. STL (SCONST b) = SCONST b"
|
14516
|
1177 |
by (import boolean_sequence STL_SCONST)
|
|
1178 |
|
|
1179 |
;end_setup
|
|
1180 |
|
|
1181 |
;setup_theory prob_algebra
|
|
1182 |
|
|
1183 |
consts
|
|
1184 |
alg_embed :: "bool list => (nat => bool) => bool"
|
|
1185 |
|
17644
|
1186 |
specification (alg_embed_primdef: alg_embed) alg_embed_def: "(ALL s::nat => bool. alg_embed [] s = True) &
|
|
1187 |
(ALL (h::bool) (t::bool list) s::nat => bool.
|
|
1188 |
alg_embed (h # t) s = (h = SHD s & alg_embed t (STL s)))"
|
14516
|
1189 |
by (import prob_algebra alg_embed_def)
|
|
1190 |
|
|
1191 |
consts
|
|
1192 |
algebra_embed :: "bool list list => (nat => bool) => bool"
|
|
1193 |
|
|
1194 |
specification (algebra_embed_primdef: algebra_embed) algebra_embed_def: "algebra_embed [] = EMPTY &
|
17644
|
1195 |
(ALL (h::bool list) t::bool list list.
|
14516
|
1196 |
algebra_embed (h # t) = pred_set.UNION (alg_embed h) (algebra_embed t))"
|
|
1197 |
by (import prob_algebra algebra_embed_def)
|
|
1198 |
|
|
1199 |
consts
|
|
1200 |
measurable :: "((nat => bool) => bool) => bool"
|
|
1201 |
|
|
1202 |
defs
|
17644
|
1203 |
measurable_primdef: "measurable ==
|
|
1204 |
%s::(nat => bool) => bool. EX b::bool list list. s = algebra_embed b"
|
|
1205 |
|
|
1206 |
lemma measurable_def: "ALL s::(nat => bool) => bool.
|
|
1207 |
measurable s = (EX b::bool list list. s = algebra_embed b)"
|
14516
|
1208 |
by (import prob_algebra measurable_def)
|
|
1209 |
|
17644
|
1210 |
lemma HALVES_INTER: "pred_set.INTER (%x::nat => bool. SHD x = True)
|
|
1211 |
(%x::nat => bool. SHD x = False) =
|
|
1212 |
EMPTY"
|
14516
|
1213 |
by (import prob_algebra HALVES_INTER)
|
|
1214 |
|
17644
|
1215 |
lemma INTER_STL: "ALL (p::(nat => bool) => bool) q::(nat => bool) => bool.
|
|
1216 |
pred_set.INTER p q o STL = pred_set.INTER (p o STL) (q o STL)"
|
14516
|
1217 |
by (import prob_algebra INTER_STL)
|
|
1218 |
|
17644
|
1219 |
lemma COMPL_SHD: "ALL b::bool.
|
|
1220 |
COMPL (%x::nat => bool. SHD x = b) = (%x::nat => bool. SHD x = (~ b))"
|
14516
|
1221 |
by (import prob_algebra COMPL_SHD)
|
|
1222 |
|
|
1223 |
lemma ALG_EMBED_BASIC: "alg_embed [] = pred_set.UNIV &
|
17644
|
1224 |
(ALL (h::bool) t::bool list.
|
|
1225 |
alg_embed (h # t) =
|
|
1226 |
pred_set.INTER (%x::nat => bool. SHD x = h) (alg_embed t o STL))"
|
14516
|
1227 |
by (import prob_algebra ALG_EMBED_BASIC)
|
|
1228 |
|
17644
|
1229 |
lemma ALG_EMBED_NIL: "ALL c::bool list. All (alg_embed c) = (c = [])"
|
14516
|
1230 |
by (import prob_algebra ALG_EMBED_NIL)
|
|
1231 |
|
17644
|
1232 |
lemma ALG_EMBED_POPULATED: "ALL b::bool list. Ex (alg_embed b)"
|
14516
|
1233 |
by (import prob_algebra ALG_EMBED_POPULATED)
|
|
1234 |
|
17694
|
1235 |
lemma ALG_EMBED_PREFIX: "ALL (b::bool list) (c::bool list) s::nat => bool.
|
|
1236 |
alg_embed b s & alg_embed c s --> IS_PREFIX b c | IS_PREFIX c b"
|
14516
|
1237 |
by (import prob_algebra ALG_EMBED_PREFIX)
|
|
1238 |
|
17644
|
1239 |
lemma ALG_EMBED_PREFIX_SUBSET: "ALL (b::bool list) c::bool list.
|
|
1240 |
SUBSET (alg_embed b) (alg_embed c) = IS_PREFIX b c"
|
14516
|
1241 |
by (import prob_algebra ALG_EMBED_PREFIX_SUBSET)
|
|
1242 |
|
17644
|
1243 |
lemma ALG_EMBED_TWINS: "ALL l::bool list.
|
14516
|
1244 |
pred_set.UNION (alg_embed (SNOC True l)) (alg_embed (SNOC False l)) =
|
|
1245 |
alg_embed l"
|
|
1246 |
by (import prob_algebra ALG_EMBED_TWINS)
|
|
1247 |
|
|
1248 |
lemma ALGEBRA_EMBED_BASIC: "algebra_embed [] = EMPTY &
|
|
1249 |
algebra_embed [[]] = pred_set.UNIV &
|
17644
|
1250 |
(ALL b::bool. algebra_embed [[b]] = (%s::nat => bool. SHD s = b))"
|
14516
|
1251 |
by (import prob_algebra ALGEBRA_EMBED_BASIC)
|
|
1252 |
|
17694
|
1253 |
lemma ALGEBRA_EMBED_MEM: "ALL (b::bool list list) x::nat => bool.
|
|
1254 |
algebra_embed b x --> (EX l::bool list. l mem b & alg_embed l x)"
|
14516
|
1255 |
by (import prob_algebra ALGEBRA_EMBED_MEM)
|
|
1256 |
|
17644
|
1257 |
lemma ALGEBRA_EMBED_APPEND: "ALL (l1::bool list list) l2::bool list list.
|
14516
|
1258 |
algebra_embed (l1 @ l2) =
|
|
1259 |
pred_set.UNION (algebra_embed l1) (algebra_embed l2)"
|
|
1260 |
by (import prob_algebra ALGEBRA_EMBED_APPEND)
|
|
1261 |
|
17644
|
1262 |
lemma ALGEBRA_EMBED_TLS: "ALL (l::bool list list) b::bool.
|
|
1263 |
algebra_embed (map (op # b) l) (SCONS (h::bool) (t::nat => bool)) =
|
|
1264 |
(h = b & algebra_embed l t)"
|
14516
|
1265 |
by (import prob_algebra ALGEBRA_EMBED_TLS)
|
|
1266 |
|
17644
|
1267 |
lemma ALG_CANON_PREFS_EMBED: "ALL (l::bool list) b::bool list list.
|
|
1268 |
algebra_embed (alg_canon_prefs l b) = algebra_embed (l # b)"
|
14516
|
1269 |
by (import prob_algebra ALG_CANON_PREFS_EMBED)
|
|
1270 |
|
17644
|
1271 |
lemma ALG_CANON_FIND_EMBED: "ALL (l::bool list) b::bool list list.
|
|
1272 |
algebra_embed (alg_canon_find l b) = algebra_embed (l # b)"
|
14516
|
1273 |
by (import prob_algebra ALG_CANON_FIND_EMBED)
|
|
1274 |
|
17644
|
1275 |
lemma ALG_CANON1_EMBED: "ALL x::bool list list. algebra_embed (alg_canon1 x) = algebra_embed x"
|
14516
|
1276 |
by (import prob_algebra ALG_CANON1_EMBED)
|
|
1277 |
|
17644
|
1278 |
lemma ALG_CANON_MERGE_EMBED: "ALL (l::bool list) b::bool list list.
|
|
1279 |
algebra_embed (alg_canon_merge l b) = algebra_embed (l # b)"
|
14516
|
1280 |
by (import prob_algebra ALG_CANON_MERGE_EMBED)
|
|
1281 |
|
17644
|
1282 |
lemma ALG_CANON2_EMBED: "ALL x::bool list list. algebra_embed (alg_canon2 x) = algebra_embed x"
|
14516
|
1283 |
by (import prob_algebra ALG_CANON2_EMBED)
|
|
1284 |
|
17644
|
1285 |
lemma ALG_CANON_EMBED: "ALL l::bool list list. algebra_embed (alg_canon l) = algebra_embed l"
|
14516
|
1286 |
by (import prob_algebra ALG_CANON_EMBED)
|
|
1287 |
|
17694
|
1288 |
lemma ALGEBRA_CANON_UNIV: "ALL l::bool list list.
|
|
1289 |
algebra_canon l --> algebra_embed l = pred_set.UNIV --> l = [[]]"
|
14516
|
1290 |
by (import prob_algebra ALGEBRA_CANON_UNIV)
|
|
1291 |
|
17644
|
1292 |
lemma ALG_CANON_REP: "ALL (b::bool list list) c::bool list list.
|
|
1293 |
(alg_canon b = alg_canon c) = (algebra_embed b = algebra_embed c)"
|
14516
|
1294 |
by (import prob_algebra ALG_CANON_REP)
|
|
1295 |
|
17694
|
1296 |
lemma ALGEBRA_CANON_EMBED_EMPTY: "ALL l::bool list list.
|
|
1297 |
algebra_canon l --> (ALL v::nat => bool. ~ algebra_embed l v) = (l = [])"
|
14516
|
1298 |
by (import prob_algebra ALGEBRA_CANON_EMBED_EMPTY)
|
|
1299 |
|
17694
|
1300 |
lemma ALGEBRA_CANON_EMBED_UNIV: "ALL l::bool list list.
|
|
1301 |
algebra_canon l --> All (algebra_embed l) = (l = [[]])"
|
14516
|
1302 |
by (import prob_algebra ALGEBRA_CANON_EMBED_UNIV)
|
|
1303 |
|
17644
|
1304 |
lemma MEASURABLE_ALGEBRA: "ALL b::bool list list. measurable (algebra_embed b)"
|
14516
|
1305 |
by (import prob_algebra MEASURABLE_ALGEBRA)
|
|
1306 |
|
|
1307 |
lemma MEASURABLE_BASIC: "measurable EMPTY &
|
17644
|
1308 |
measurable pred_set.UNIV &
|
|
1309 |
(ALL b::bool. measurable (%s::nat => bool. SHD s = b))"
|
14516
|
1310 |
by (import prob_algebra MEASURABLE_BASIC)
|
|
1311 |
|
17644
|
1312 |
lemma MEASURABLE_SHD: "ALL b::bool. measurable (%s::nat => bool. SHD s = b)"
|
14516
|
1313 |
by (import prob_algebra MEASURABLE_SHD)
|
|
1314 |
|
17644
|
1315 |
lemma ALGEBRA_EMBED_COMPL: "ALL l::bool list list.
|
|
1316 |
EX l'::bool list list. COMPL (algebra_embed l) = algebra_embed l'"
|
14516
|
1317 |
by (import prob_algebra ALGEBRA_EMBED_COMPL)
|
|
1318 |
|
17644
|
1319 |
lemma MEASURABLE_COMPL: "ALL s::(nat => bool) => bool. measurable (COMPL s) = measurable s"
|
14516
|
1320 |
by (import prob_algebra MEASURABLE_COMPL)
|
|
1321 |
|
17694
|
1322 |
lemma MEASURABLE_UNION: "ALL (s::(nat => bool) => bool) t::(nat => bool) => bool.
|
|
1323 |
measurable s & measurable t --> measurable (pred_set.UNION s t)"
|
14516
|
1324 |
by (import prob_algebra MEASURABLE_UNION)
|
|
1325 |
|
17694
|
1326 |
lemma MEASURABLE_INTER: "ALL (s::(nat => bool) => bool) t::(nat => bool) => bool.
|
|
1327 |
measurable s & measurable t --> measurable (pred_set.INTER s t)"
|
14516
|
1328 |
by (import prob_algebra MEASURABLE_INTER)
|
|
1329 |
|
17644
|
1330 |
lemma MEASURABLE_STL: "ALL p::(nat => bool) => bool. measurable (p o STL) = measurable p"
|
14516
|
1331 |
by (import prob_algebra MEASURABLE_STL)
|
|
1332 |
|
17644
|
1333 |
lemma MEASURABLE_SDROP: "ALL (n::nat) p::(nat => bool) => bool.
|
|
1334 |
measurable (p o SDROP n) = measurable p"
|
14516
|
1335 |
by (import prob_algebra MEASURABLE_SDROP)
|
|
1336 |
|
17644
|
1337 |
lemma MEASURABLE_INTER_HALVES: "ALL p::(nat => bool) => bool.
|
|
1338 |
(measurable (pred_set.INTER (%x::nat => bool. SHD x = True) p) &
|
|
1339 |
measurable (pred_set.INTER (%x::nat => bool. SHD x = False) p)) =
|
14516
|
1340 |
measurable p"
|
|
1341 |
by (import prob_algebra MEASURABLE_INTER_HALVES)
|
|
1342 |
|
17644
|
1343 |
lemma MEASURABLE_HALVES: "ALL (p::(nat => bool) => bool) q::(nat => bool) => bool.
|
14516
|
1344 |
measurable
|
17644
|
1345 |
(pred_set.UNION (pred_set.INTER (%x::nat => bool. SHD x = True) p)
|
|
1346 |
(pred_set.INTER (%x::nat => bool. SHD x = False) q)) =
|
|
1347 |
(measurable (pred_set.INTER (%x::nat => bool. SHD x = True) p) &
|
|
1348 |
measurable (pred_set.INTER (%x::nat => bool. SHD x = False) q))"
|
14516
|
1349 |
by (import prob_algebra MEASURABLE_HALVES)
|
|
1350 |
|
17644
|
1351 |
lemma MEASURABLE_INTER_SHD: "ALL (b::bool) p::(nat => bool) => bool.
|
|
1352 |
measurable (pred_set.INTER (%x::nat => bool. SHD x = b) (p o STL)) =
|
|
1353 |
measurable p"
|
14516
|
1354 |
by (import prob_algebra MEASURABLE_INTER_SHD)
|
|
1355 |
|
|
1356 |
;end_setup
|
|
1357 |
|
|
1358 |
;setup_theory prob
|
|
1359 |
|
|
1360 |
consts
|
|
1361 |
alg_measure :: "bool list list => real"
|
|
1362 |
|
17652
|
1363 |
specification (alg_measure_primdef: alg_measure) alg_measure_def: "alg_measure [] = 0 &
|
17644
|
1364 |
(ALL (l::bool list) rest::bool list list.
|
17652
|
1365 |
alg_measure (l # rest) = (1 / 2) ^ length l + alg_measure rest)"
|
14516
|
1366 |
by (import prob alg_measure_def)
|
|
1367 |
|
|
1368 |
consts
|
|
1369 |
algebra_measure :: "bool list list => real"
|
|
1370 |
|
|
1371 |
defs
|
|
1372 |
algebra_measure_primdef: "algebra_measure ==
|
17644
|
1373 |
%b::bool list list.
|
|
1374 |
inf (%r::real.
|
|
1375 |
EX c::bool list list.
|
|
1376 |
algebra_embed b = algebra_embed c & alg_measure c = r)"
|
|
1377 |
|
|
1378 |
lemma algebra_measure_def: "ALL b::bool list list.
|
14516
|
1379 |
algebra_measure b =
|
17644
|
1380 |
inf (%r::real.
|
|
1381 |
EX c::bool list list.
|
|
1382 |
algebra_embed b = algebra_embed c & alg_measure c = r)"
|
14516
|
1383 |
by (import prob algebra_measure_def)
|
|
1384 |
|
|
1385 |
consts
|
|
1386 |
prob :: "((nat => bool) => bool) => real"
|
|
1387 |
|
|
1388 |
defs
|
|
1389 |
prob_primdef: "prob ==
|
17644
|
1390 |
%s::(nat => bool) => bool.
|
|
1391 |
sup (%r::real.
|
|
1392 |
EX b::bool list list.
|
|
1393 |
algebra_measure b = r & SUBSET (algebra_embed b) s)"
|
|
1394 |
|
|
1395 |
lemma prob_def: "ALL s::(nat => bool) => bool.
|
14516
|
1396 |
prob s =
|
17644
|
1397 |
sup (%r::real.
|
|
1398 |
EX b::bool list list.
|
|
1399 |
algebra_measure b = r & SUBSET (algebra_embed b) s)"
|
14516
|
1400 |
by (import prob prob_def)
|
|
1401 |
|
17652
|
1402 |
lemma ALG_TWINS_MEASURE: "(All::(bool list => bool) => bool)
|
|
1403 |
(%l::bool list.
|
|
1404 |
(op =::real => real => bool)
|
|
1405 |
((op +::real => real => real)
|
|
1406 |
((op ^::real => nat => real)
|
|
1407 |
((op /::real => real => real) (1::real)
|
20485
|
1408 |
((number_of \<Colon> int => real)
|
|
1409 |
((op BIT \<Colon> int => bit => int)
|
|
1410 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
|
17652
|
1411 |
(bit.B1::bit))
|
|
1412 |
(bit.B0::bit))))
|
|
1413 |
((size::bool list => nat)
|
|
1414 |
((SNOC::bool => bool list => bool list) (True::bool) l)))
|
|
1415 |
((op ^::real => nat => real)
|
|
1416 |
((op /::real => real => real) (1::real)
|
20485
|
1417 |
((number_of \<Colon> int => real)
|
|
1418 |
((op BIT \<Colon> int => bit => int)
|
|
1419 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
|
17652
|
1420 |
(bit.B1::bit))
|
|
1421 |
(bit.B0::bit))))
|
|
1422 |
((size::bool list => nat)
|
|
1423 |
((SNOC::bool => bool list => bool list) (False::bool) l))))
|
|
1424 |
((op ^::real => nat => real)
|
|
1425 |
((op /::real => real => real) (1::real)
|
20485
|
1426 |
((number_of \<Colon> int => real)
|
|
1427 |
((op BIT \<Colon> int => bit => int)
|
|
1428 |
((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
|
17652
|
1429 |
(bit.B0::bit))))
|
|
1430 |
((size::bool list => nat) l)))"
|
14516
|
1431 |
by (import prob ALG_TWINS_MEASURE)
|
|
1432 |
|
17652
|
1433 |
lemma ALG_MEASURE_BASIC: "alg_measure [] = 0 &
|
|
1434 |
alg_measure [[]] = 1 & (ALL b::bool. alg_measure [[b]] = 1 / 2)"
|
14516
|
1435 |
by (import prob ALG_MEASURE_BASIC)
|
|
1436 |
|
17652
|
1437 |
lemma ALG_MEASURE_POS: "ALL l::bool list list. 0 <= alg_measure l"
|
14516
|
1438 |
by (import prob ALG_MEASURE_POS)
|
|
1439 |
|
17644
|
1440 |
lemma ALG_MEASURE_APPEND: "ALL (l1::bool list list) l2::bool list list.
|
|
1441 |
alg_measure (l1 @ l2) = alg_measure l1 + alg_measure l2"
|
14516
|
1442 |
by (import prob ALG_MEASURE_APPEND)
|
|
1443 |
|
17644
|
1444 |
lemma ALG_MEASURE_TLS: "ALL (l::bool list list) b::bool.
|
17652
|
1445 |
2 * alg_measure (map (op # b) l) = alg_measure l"
|
14516
|
1446 |
by (import prob ALG_MEASURE_TLS)
|
|
1447 |
|
17644
|
1448 |
lemma ALG_CANON_PREFS_MONO: "ALL (l::bool list) b::bool list list.
|
|
1449 |
alg_measure (alg_canon_prefs l b) <= alg_measure (l # b)"
|
14516
|
1450 |
by (import prob ALG_CANON_PREFS_MONO)
|
|
1451 |
|
17644
|
1452 |
lemma ALG_CANON_FIND_MONO: "ALL (l::bool list) b::bool list list.
|
|
1453 |
alg_measure (alg_canon_find l b) <= alg_measure (l # b)"
|
14516
|
1454 |
by (import prob ALG_CANON_FIND_MONO)
|
|
1455 |
|
17644
|
1456 |
lemma ALG_CANON1_MONO: "ALL x::bool list list. alg_measure (alg_canon1 x) <= alg_measure x"
|
14516
|
1457 |
by (import prob ALG_CANON1_MONO)
|
|
1458 |
|
17644
|
1459 |
lemma ALG_CANON_MERGE_MONO: "ALL (l::bool list) b::bool list list.
|
|
1460 |
alg_measure (alg_canon_merge l b) <= alg_measure (l # b)"
|
14516
|
1461 |
by (import prob ALG_CANON_MERGE_MONO)
|
|
1462 |
|
17644
|
1463 |
lemma ALG_CANON2_MONO: "ALL x::bool list list. alg_measure (alg_canon2 x) <= alg_measure x"
|
14516
|
1464 |
by (import prob ALG_CANON2_MONO)
|
|
1465 |
|
17644
|
1466 |
lemma ALG_CANON_MONO: "ALL l::bool list list. alg_measure (alg_canon l) <= alg_measure l"
|
14516
|
1467 |
by (import prob ALG_CANON_MONO)
|
|
1468 |
|
17644
|
1469 |
lemma ALGEBRA_MEASURE_DEF_ALT: "ALL l::bool list list. algebra_measure l = alg_measure (alg_canon l)"
|
14516
|
1470 |
by (import prob ALGEBRA_MEASURE_DEF_ALT)
|
|
1471 |
|
17652
|
1472 |
lemma ALGEBRA_MEASURE_BASIC: "algebra_measure [] = 0 &
|
|
1473 |
algebra_measure [[]] = 1 & (ALL b::bool. algebra_measure [[b]] = 1 / 2)"
|
14516
|
1474 |
by (import prob ALGEBRA_MEASURE_BASIC)
|
|
1475 |
|
17694
|
1476 |
lemma ALGEBRA_CANON_MEASURE_MAX: "ALL l::bool list list. algebra_canon l --> alg_measure l <= 1"
|
14516
|
1477 |
by (import prob ALGEBRA_CANON_MEASURE_MAX)
|
|
1478 |
|
17652
|
1479 |
lemma ALGEBRA_MEASURE_MAX: "ALL l::bool list list. algebra_measure l <= 1"
|
14516
|
1480 |
by (import prob ALGEBRA_MEASURE_MAX)
|
|
1481 |
|
17694
|
1482 |
lemma ALGEBRA_MEASURE_MONO_EMBED: "ALL (x::bool list list) xa::bool list list.
|
|
1483 |
SUBSET (algebra_embed x) (algebra_embed xa) -->
|
|
1484 |
algebra_measure x <= algebra_measure xa"
|
14516
|
1485 |
by (import prob ALGEBRA_MEASURE_MONO_EMBED)
|
|
1486 |
|
17694
|
1487 |
lemma ALG_MEASURE_COMPL: "ALL l::bool list list.
|
|
1488 |
algebra_canon l -->
|
|
1489 |
(ALL c::bool list list.
|
|
1490 |
algebra_canon c -->
|
|
1491 |
COMPL (algebra_embed l) = algebra_embed c -->
|
|
1492 |
alg_measure l + alg_measure c = 1)"
|
14516
|
1493 |
by (import prob ALG_MEASURE_COMPL)
|
|
1494 |
|
17694
|
1495 |
lemma ALG_MEASURE_ADDITIVE: "ALL l::bool list list.
|
|
1496 |
algebra_canon l -->
|
|
1497 |
(ALL c::bool list list.
|
|
1498 |
algebra_canon c -->
|
|
1499 |
(ALL d::bool list list.
|
|
1500 |
algebra_canon d -->
|
|
1501 |
pred_set.INTER (algebra_embed c) (algebra_embed d) = EMPTY &
|
|
1502 |
algebra_embed l =
|
|
1503 |
pred_set.UNION (algebra_embed c) (algebra_embed d) -->
|
|
1504 |
alg_measure l = alg_measure c + alg_measure d))"
|
14516
|
1505 |
by (import prob ALG_MEASURE_ADDITIVE)
|
|
1506 |
|
17644
|
1507 |
lemma PROB_ALGEBRA: "ALL l::bool list list. prob (algebra_embed l) = algebra_measure l"
|
14516
|
1508 |
by (import prob PROB_ALGEBRA)
|
|
1509 |
|
17652
|
1510 |
lemma PROB_BASIC: "prob EMPTY = 0 &
|
|
1511 |
prob pred_set.UNIV = 1 &
|
|
1512 |
(ALL b::bool. prob (%s::nat => bool. SHD s = b) = 1 / 2)"
|
14516
|
1513 |
by (import prob PROB_BASIC)
|
|
1514 |
|
17694
|
1515 |
lemma PROB_ADDITIVE: "ALL (s::(nat => bool) => bool) t::(nat => bool) => bool.
|
|
1516 |
measurable s & measurable t & pred_set.INTER s t = EMPTY -->
|
|
1517 |
prob (pred_set.UNION s t) = prob s + prob t"
|
14516
|
1518 |
by (import prob PROB_ADDITIVE)
|
|
1519 |
|
17694
|
1520 |
lemma PROB_COMPL: "ALL s::(nat => bool) => bool. measurable s --> prob (COMPL s) = 1 - prob s"
|
14516
|
1521 |
by (import prob PROB_COMPL)
|
|
1522 |
|
17644
|
1523 |
lemma PROB_SUP_EXISTS1: "ALL s::(nat => bool) => bool.
|
|
1524 |
EX (x::real) b::bool list list.
|
|
1525 |
algebra_measure b = x & SUBSET (algebra_embed b) s"
|
14516
|
1526 |
by (import prob PROB_SUP_EXISTS1)
|
|
1527 |
|
17694
|
1528 |
lemma PROB_SUP_EXISTS2: "ALL s::(nat => bool) => bool.
|
|
1529 |
EX x::real.
|
|
1530 |
ALL r::real.
|
|
1531 |
(EX b::bool list list.
|
|
1532 |
algebra_measure b = r & SUBSET (algebra_embed b) s) -->
|
|
1533 |
r <= x"
|
14516
|
1534 |
by (import prob PROB_SUP_EXISTS2)
|
|
1535 |
|
17694
|
1536 |
lemma PROB_LE_X: "ALL (s::(nat => bool) => bool) x::real.
|
|
1537 |
(ALL s'::(nat => bool) => bool.
|
|
1538 |
measurable s' & SUBSET s' s --> prob s' <= x) -->
|
|
1539 |
prob s <= x"
|
14516
|
1540 |
by (import prob PROB_LE_X)
|
|
1541 |
|
17694
|
1542 |
lemma X_LE_PROB: "ALL (s::(nat => bool) => bool) x::real.
|
|
1543 |
(EX s'::(nat => bool) => bool.
|
|
1544 |
measurable s' & SUBSET s' s & x <= prob s') -->
|
|
1545 |
x <= prob s"
|
14516
|
1546 |
by (import prob X_LE_PROB)
|
|
1547 |
|
17694
|
1548 |
lemma PROB_SUBSET_MONO: "ALL (s::(nat => bool) => bool) t::(nat => bool) => bool.
|
|
1549 |
SUBSET s t --> prob s <= prob t"
|
14516
|
1550 |
by (import prob PROB_SUBSET_MONO)
|
|
1551 |
|
17652
|
1552 |
lemma PROB_ALG: "ALL x::bool list. prob (alg_embed x) = (1 / 2) ^ length x"
|
14516
|
1553 |
by (import prob PROB_ALG)
|
|
1554 |
|
17694
|
1555 |
lemma PROB_STL: "ALL p::(nat => bool) => bool. measurable p --> prob (p o STL) = prob p"
|
14516
|
1556 |
by (import prob PROB_STL)
|
|
1557 |
|
17694
|
1558 |
lemma PROB_SDROP: "ALL (n::nat) p::(nat => bool) => bool.
|
|
1559 |
measurable p --> prob (p o SDROP n) = prob p"
|
14516
|
1560 |
by (import prob PROB_SDROP)
|
|
1561 |
|
17694
|
1562 |
lemma PROB_INTER_HALVES: "ALL p::(nat => bool) => bool.
|
|
1563 |
measurable p -->
|
|
1564 |
prob (pred_set.INTER (%x::nat => bool. SHD x = True) p) +
|
|
1565 |
prob (pred_set.INTER (%x::nat => bool. SHD x = False) p) =
|
|
1566 |
prob p"
|
14516
|
1567 |
by (import prob PROB_INTER_HALVES)
|
|
1568 |
|
17694
|
1569 |
lemma PROB_INTER_SHD: "ALL (b::bool) p::(nat => bool) => bool.
|
|
1570 |
measurable p -->
|
|
1571 |
prob (pred_set.INTER (%x::nat => bool. SHD x = b) (p o STL)) =
|
|
1572 |
1 / 2 * prob p"
|
14516
|
1573 |
by (import prob PROB_INTER_SHD)
|
|
1574 |
|
17652
|
1575 |
lemma ALGEBRA_MEASURE_POS: "ALL l::bool list list. 0 <= algebra_measure l"
|
14516
|
1576 |
by (import prob ALGEBRA_MEASURE_POS)
|
|
1577 |
|
17652
|
1578 |
lemma ALGEBRA_MEASURE_RANGE: "ALL l::bool list list. 0 <= algebra_measure l & algebra_measure l <= 1"
|
14516
|
1579 |
by (import prob ALGEBRA_MEASURE_RANGE)
|
|
1580 |
|
17652
|
1581 |
lemma PROB_POS: "ALL p::(nat => bool) => bool. 0 <= prob p"
|
14516
|
1582 |
by (import prob PROB_POS)
|
|
1583 |
|
17652
|
1584 |
lemma PROB_MAX: "ALL p::(nat => bool) => bool. prob p <= 1"
|
14516
|
1585 |
by (import prob PROB_MAX)
|
|
1586 |
|
17652
|
1587 |
lemma PROB_RANGE: "ALL p::(nat => bool) => bool. 0 <= prob p & prob p <= 1"
|
14516
|
1588 |
by (import prob PROB_RANGE)
|
|
1589 |
|
17644
|
1590 |
lemma ABS_PROB: "ALL p::(nat => bool) => bool. abs (prob p) = prob p"
|
14516
|
1591 |
by (import prob ABS_PROB)
|
|
1592 |
|
17652
|
1593 |
lemma PROB_SHD: "ALL b::bool. prob (%s::nat => bool. SHD s = b) = 1 / 2"
|
14516
|
1594 |
by (import prob PROB_SHD)
|
|
1595 |
|
17694
|
1596 |
lemma PROB_COMPL_LE1: "ALL (p::(nat => bool) => bool) r::real.
|
|
1597 |
measurable p --> (prob (COMPL p) <= r) = (1 - r <= prob p)"
|
14516
|
1598 |
by (import prob PROB_COMPL_LE1)
|
|
1599 |
|
|
1600 |
;end_setup
|
|
1601 |
|
|
1602 |
;setup_theory prob_pseudo
|
|
1603 |
|
|
1604 |
consts
|
|
1605 |
pseudo_linear_hd :: "nat => bool"
|
|
1606 |
|
|
1607 |
defs
|
|
1608 |
pseudo_linear_hd_primdef: "pseudo_linear_hd == EVEN"
|
|
1609 |
|
|
1610 |
lemma pseudo_linear_hd_def: "pseudo_linear_hd = EVEN"
|
|
1611 |
by (import prob_pseudo pseudo_linear_hd_def)
|
|
1612 |
|
|
1613 |
consts
|
|
1614 |
pseudo_linear_tl :: "nat => nat => nat => nat => nat"
|
|
1615 |
|
|
1616 |
defs
|
17644
|
1617 |
pseudo_linear_tl_primdef: "pseudo_linear_tl ==
|
17652
|
1618 |
%(a::nat) (b::nat) (n::nat) x::nat. (a * x + b) mod (2 * n + 1)"
|
17644
|
1619 |
|
|
1620 |
lemma pseudo_linear_tl_def: "ALL (a::nat) (b::nat) (n::nat) x::nat.
|
17652
|
1621 |
pseudo_linear_tl a b n x = (a * x + b) mod (2 * n + 1)"
|
14516
|
1622 |
by (import prob_pseudo pseudo_linear_tl_def)
|
|
1623 |
|
17644
|
1624 |
lemma PSEUDO_LINEAR1_EXECUTE: "EX x::nat => nat => bool.
|
|
1625 |
(ALL xa::nat. SHD (x xa) = pseudo_linear_hd xa) &
|
|
1626 |
(ALL xa::nat.
|
|
1627 |
STL (x xa) =
|
|
1628 |
x (pseudo_linear_tl
|
|
1629 |
(NUMERAL
|
|
1630 |
(NUMERAL_BIT1
|
|
1631 |
(NUMERAL_BIT1
|
|
1632 |
(NUMERAL_BIT1
|
|
1633 |
(NUMERAL_BIT2 (NUMERAL_BIT1 (NUMERAL_BIT2 ALT_ZERO)))))))
|
|
1634 |
(NUMERAL
|
|
1635 |
(NUMERAL_BIT1
|
|
1636 |
(NUMERAL_BIT1
|
|
1637 |
(NUMERAL_BIT1
|
|
1638 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT2 ALT_ZERO)))))))
|
|
1639 |
(NUMERAL
|
|
1640 |
(NUMERAL_BIT1
|
|
1641 |
(NUMERAL_BIT1
|
|
1642 |
(NUMERAL_BIT1
|
|
1643 |
(NUMERAL_BIT1 (NUMERAL_BIT2 (NUMERAL_BIT1 ALT_ZERO)))))))
|
|
1644 |
xa))"
|
14516
|
1645 |
by (import prob_pseudo PSEUDO_LINEAR1_EXECUTE)
|
|
1646 |
|
|
1647 |
consts
|
|
1648 |
pseudo_linear1 :: "nat => nat => bool"
|
|
1649 |
|
17644
|
1650 |
specification (pseudo_linear1_primdef: pseudo_linear1) pseudo_linear1_def: "(ALL x::nat. SHD (pseudo_linear1 x) = pseudo_linear_hd x) &
|
|
1651 |
(ALL x::nat.
|
14516
|
1652 |
STL (pseudo_linear1 x) =
|
|
1653 |
pseudo_linear1
|
|
1654 |
(pseudo_linear_tl
|
|
1655 |
(NUMERAL
|
|
1656 |
(NUMERAL_BIT1
|
|
1657 |
(NUMERAL_BIT1
|
|
1658 |
(NUMERAL_BIT1
|
|
1659 |
(NUMERAL_BIT2 (NUMERAL_BIT1 (NUMERAL_BIT2 ALT_ZERO)))))))
|
|
1660 |
(NUMERAL
|
|
1661 |
(NUMERAL_BIT1
|
|
1662 |
(NUMERAL_BIT1
|
|
1663 |
(NUMERAL_BIT1
|
|
1664 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT2 ALT_ZERO)))))))
|
|
1665 |
(NUMERAL
|
|
1666 |
(NUMERAL_BIT1
|
|
1667 |
(NUMERAL_BIT1
|
|
1668 |
(NUMERAL_BIT1
|
|
1669 |
(NUMERAL_BIT1 (NUMERAL_BIT2 (NUMERAL_BIT1 ALT_ZERO)))))))
|
|
1670 |
x))"
|
|
1671 |
by (import prob_pseudo pseudo_linear1_def)
|
|
1672 |
|
|
1673 |
consts
|
|
1674 |
pseudo :: "nat => nat => bool"
|
|
1675 |
|
|
1676 |
defs
|
|
1677 |
pseudo_primdef: "pseudo == pseudo_linear1"
|
|
1678 |
|
|
1679 |
lemma pseudo_def: "pseudo = pseudo_linear1"
|
|
1680 |
by (import prob_pseudo pseudo_def)
|
|
1681 |
|
|
1682 |
;end_setup
|
|
1683 |
|
|
1684 |
;setup_theory prob_indep
|
|
1685 |
|
|
1686 |
consts
|
|
1687 |
indep_set :: "((nat => bool) => bool) => ((nat => bool) => bool) => bool"
|
|
1688 |
|
|
1689 |
defs
|
|
1690 |
indep_set_primdef: "indep_set ==
|
17644
|
1691 |
%(p::(nat => bool) => bool) q::(nat => bool) => bool.
|
|
1692 |
measurable p & measurable q & prob (pred_set.INTER p q) = prob p * prob q"
|
|
1693 |
|
|
1694 |
lemma indep_set_def: "ALL (p::(nat => bool) => bool) q::(nat => bool) => bool.
|
14516
|
1695 |
indep_set p q =
|
|
1696 |
(measurable p &
|
|
1697 |
measurable q & prob (pred_set.INTER p q) = prob p * prob q)"
|
|
1698 |
by (import prob_indep indep_set_def)
|
|
1699 |
|
|
1700 |
consts
|
|
1701 |
alg_cover_set :: "bool list list => bool"
|
|
1702 |
|
|
1703 |
defs
|
|
1704 |
alg_cover_set_primdef: "alg_cover_set ==
|
17644
|
1705 |
%l::bool list list.
|
|
1706 |
alg_sorted l & alg_prefixfree l & algebra_embed l = pred_set.UNIV"
|
|
1707 |
|
|
1708 |
lemma alg_cover_set_def: "ALL l::bool list list.
|
14516
|
1709 |
alg_cover_set l =
|
|
1710 |
(alg_sorted l & alg_prefixfree l & algebra_embed l = pred_set.UNIV)"
|
|
1711 |
by (import prob_indep alg_cover_set_def)
|
|
1712 |
|
|
1713 |
consts
|
|
1714 |
alg_cover :: "bool list list => (nat => bool) => bool list"
|
|
1715 |
|
|
1716 |
defs
|
17644
|
1717 |
alg_cover_primdef: "alg_cover ==
|
|
1718 |
%(l::bool list list) x::nat => bool.
|
|
1719 |
SOME b::bool list. b mem l & alg_embed b x"
|
|
1720 |
|
|
1721 |
lemma alg_cover_def: "ALL (l::bool list list) x::nat => bool.
|
|
1722 |
alg_cover l x = (SOME b::bool list. b mem l & alg_embed b x)"
|
14516
|
1723 |
by (import prob_indep alg_cover_def)
|
|
1724 |
|
|
1725 |
consts
|
17652
|
1726 |
indep :: "((nat => bool) => 'a * (nat => bool)) => bool"
|
14516
|
1727 |
|
|
1728 |
defs
|
|
1729 |
indep_primdef: "indep ==
|
17644
|
1730 |
%f::(nat => bool) => 'a::type * (nat => bool).
|
|
1731 |
EX (l::bool list list) r::bool list => 'a::type.
|
|
1732 |
alg_cover_set l &
|
|
1733 |
(ALL s::nat => bool.
|
|
1734 |
f s =
|
|
1735 |
(let c::bool list = alg_cover l s in (r c, SDROP (length c) s)))"
|
|
1736 |
|
|
1737 |
lemma indep_def: "ALL f::(nat => bool) => 'a::type * (nat => bool).
|
|
1738 |
indep f =
|
|
1739 |
(EX (l::bool list list) r::bool list => 'a::type.
|
14516
|
1740 |
alg_cover_set l &
|
17644
|
1741 |
(ALL s::nat => bool.
|
|
1742 |
f s =
|
|
1743 |
(let c::bool list = alg_cover l s in (r c, SDROP (length c) s))))"
|
14516
|
1744 |
by (import prob_indep indep_def)
|
|
1745 |
|
17694
|
1746 |
lemma INDEP_SET_BASIC: "ALL p::(nat => bool) => bool.
|
|
1747 |
measurable p --> indep_set EMPTY p & indep_set pred_set.UNIV p"
|
14516
|
1748 |
by (import prob_indep INDEP_SET_BASIC)
|
|
1749 |
|
17644
|
1750 |
lemma INDEP_SET_SYM: "ALL (p::(nat => bool) => bool) q::(nat => bool) => bool.
|
|
1751 |
indep_set p q = indep_set p q"
|
14516
|
1752 |
by (import prob_indep INDEP_SET_SYM)
|
|
1753 |
|
17694
|
1754 |
lemma INDEP_SET_DISJOINT_DECOMP: "ALL (p::(nat => bool) => bool) (q::(nat => bool) => bool)
|
|
1755 |
r::(nat => bool) => bool.
|
|
1756 |
indep_set p r & indep_set q r & pred_set.INTER p q = EMPTY -->
|
|
1757 |
indep_set (pred_set.UNION p q) r"
|
14516
|
1758 |
by (import prob_indep INDEP_SET_DISJOINT_DECOMP)
|
|
1759 |
|
|
1760 |
lemma ALG_COVER_SET_BASIC: "~ alg_cover_set [] & alg_cover_set [[]] & alg_cover_set [[True], [False]]"
|
|
1761 |
by (import prob_indep ALG_COVER_SET_BASIC)
|
|
1762 |
|
17694
|
1763 |
lemma ALG_COVER_WELL_DEFINED: "ALL (l::bool list list) x::nat => bool.
|
|
1764 |
alg_cover_set l --> alg_cover l x mem l & alg_embed (alg_cover l x) x"
|
14516
|
1765 |
by (import prob_indep ALG_COVER_WELL_DEFINED)
|
|
1766 |
|
|
1767 |
lemma ALG_COVER_UNIV: "alg_cover [[]] = K []"
|
|
1768 |
by (import prob_indep ALG_COVER_UNIV)
|
|
1769 |
|
17694
|
1770 |
lemma MAP_CONS_TL_FILTER: "ALL (l::bool list list) b::bool.
|
|
1771 |
~ [] mem l -->
|
|
1772 |
map (op # b) (map tl [x::bool list:l. hd x = b]) =
|
|
1773 |
[x::bool list:l. hd x = b]"
|
14516
|
1774 |
by (import prob_indep MAP_CONS_TL_FILTER)
|
|
1775 |
|
17644
|
1776 |
lemma ALG_COVER_SET_CASES_THM: "ALL l::bool list list.
|
14516
|
1777 |
alg_cover_set l =
|
|
1778 |
(l = [[]] |
|
17644
|
1779 |
(EX (x::bool list list) xa::bool list list.
|
14516
|
1780 |
alg_cover_set x &
|
|
1781 |
alg_cover_set xa & l = map (op # True) x @ map (op # False) xa))"
|
|
1782 |
by (import prob_indep ALG_COVER_SET_CASES_THM)
|
|
1783 |
|
17694
|
1784 |
lemma ALG_COVER_SET_CASES: "ALL P::bool list list => bool.
|
|
1785 |
P [[]] &
|
|
1786 |
(ALL (l1::bool list list) l2::bool list list.
|
|
1787 |
alg_cover_set l1 &
|
|
1788 |
alg_cover_set l2 &
|
|
1789 |
alg_cover_set (map (op # True) l1 @ map (op # False) l2) -->
|
|
1790 |
P (map (op # True) l1 @ map (op # False) l2)) -->
|
|
1791 |
(ALL l::bool list list. alg_cover_set l --> P l)"
|
14516
|
1792 |
by (import prob_indep ALG_COVER_SET_CASES)
|
|
1793 |
|
17694
|
1794 |
lemma ALG_COVER_SET_INDUCTION: "ALL P::bool list list => bool.
|
|
1795 |
P [[]] &
|
|
1796 |
(ALL (l1::bool list list) l2::bool list list.
|
|
1797 |
alg_cover_set l1 &
|
|
1798 |
alg_cover_set l2 &
|
|
1799 |
P l1 &
|
|
1800 |
P l2 & alg_cover_set (map (op # True) l1 @ map (op # False) l2) -->
|
|
1801 |
P (map (op # True) l1 @ map (op # False) l2)) -->
|
|
1802 |
(ALL l::bool list list. alg_cover_set l --> P l)"
|
14516
|
1803 |
by (import prob_indep ALG_COVER_SET_INDUCTION)
|
|
1804 |
|
17694
|
1805 |
lemma ALG_COVER_EXISTS_UNIQUE: "ALL l::bool list list.
|
|
1806 |
alg_cover_set l -->
|
|
1807 |
(ALL s::nat => bool. EX! x::bool list. x mem l & alg_embed x s)"
|
14516
|
1808 |
by (import prob_indep ALG_COVER_EXISTS_UNIQUE)
|
|
1809 |
|
17694
|
1810 |
lemma ALG_COVER_UNIQUE: "ALL (l::bool list list) (x::bool list) s::nat => bool.
|
|
1811 |
alg_cover_set l & x mem l & alg_embed x s --> alg_cover l s = x"
|
14516
|
1812 |
by (import prob_indep ALG_COVER_UNIQUE)
|
|
1813 |
|
17694
|
1814 |
lemma ALG_COVER_STEP: "ALL (l1::bool list list) (l2::bool list list) (h::bool) t::nat => bool.
|
|
1815 |
alg_cover_set l1 & alg_cover_set l2 -->
|
|
1816 |
alg_cover (map (op # True) l1 @ map (op # False) l2) (SCONS h t) =
|
|
1817 |
(if h then True # alg_cover l1 t else False # alg_cover l2 t)"
|
14516
|
1818 |
by (import prob_indep ALG_COVER_STEP)
|
|
1819 |
|
17694
|
1820 |
lemma ALG_COVER_HEAD: "ALL l::bool list list.
|
|
1821 |
alg_cover_set l -->
|
|
1822 |
(ALL f::bool list => bool. f o alg_cover l = algebra_embed (filter f l))"
|
14516
|
1823 |
by (import prob_indep ALG_COVER_HEAD)
|
|
1824 |
|
17694
|
1825 |
lemma ALG_COVER_TAIL_STEP: "ALL (l1::bool list list) (l2::bool list list) q::(nat => bool) => bool.
|
|
1826 |
alg_cover_set l1 & alg_cover_set l2 -->
|
|
1827 |
q o
|
|
1828 |
(%x::nat => bool.
|
|
1829 |
SDROP
|
|
1830 |
(length (alg_cover (map (op # True) l1 @ map (op # False) l2) x))
|
|
1831 |
x) =
|
|
1832 |
pred_set.UNION
|
|
1833 |
(pred_set.INTER (%x::nat => bool. SHD x = True)
|
|
1834 |
(q o ((%x::nat => bool. SDROP (length (alg_cover l1 x)) x) o STL)))
|
|
1835 |
(pred_set.INTER (%x::nat => bool. SHD x = False)
|
|
1836 |
(q o ((%x::nat => bool. SDROP (length (alg_cover l2 x)) x) o STL)))"
|
14516
|
1837 |
by (import prob_indep ALG_COVER_TAIL_STEP)
|
|
1838 |
|
17694
|
1839 |
lemma ALG_COVER_TAIL_MEASURABLE: "ALL l::bool list list.
|
|
1840 |
alg_cover_set l -->
|
|
1841 |
(ALL q::(nat => bool) => bool.
|
|
1842 |
measurable
|
|
1843 |
(q o (%x::nat => bool. SDROP (length (alg_cover l x)) x)) =
|
|
1844 |
measurable q)"
|
14516
|
1845 |
by (import prob_indep ALG_COVER_TAIL_MEASURABLE)
|
|
1846 |
|
17694
|
1847 |
lemma ALG_COVER_TAIL_PROB: "ALL l::bool list list.
|
|
1848 |
alg_cover_set l -->
|
|
1849 |
(ALL q::(nat => bool) => bool.
|
|
1850 |
measurable q -->
|
|
1851 |
prob (q o (%x::nat => bool. SDROP (length (alg_cover l x)) x)) =
|
|
1852 |
prob q)"
|
14516
|
1853 |
by (import prob_indep ALG_COVER_TAIL_PROB)
|
|
1854 |
|
17694
|
1855 |
lemma INDEP_INDEP_SET_LEMMA: "ALL l::bool list list.
|
|
1856 |
alg_cover_set l -->
|
|
1857 |
(ALL q::(nat => bool) => bool.
|
|
1858 |
measurable q -->
|
|
1859 |
(ALL x::bool list.
|
|
1860 |
x mem l -->
|
|
1861 |
prob
|
|
1862 |
(pred_set.INTER (alg_embed x)
|
|
1863 |
(q o (%x::nat => bool. SDROP (length (alg_cover l x)) x))) =
|
|
1864 |
(1 / 2) ^ length x * prob q))"
|
14516
|
1865 |
by (import prob_indep INDEP_INDEP_SET_LEMMA)
|
|
1866 |
|
17694
|
1867 |
lemma INDEP_SET_LIST: "ALL (q::(nat => bool) => bool) l::bool list list.
|
|
1868 |
alg_sorted l &
|
|
1869 |
alg_prefixfree l &
|
|
1870 |
measurable q &
|
|
1871 |
(ALL x::bool list. x mem l --> indep_set (alg_embed x) q) -->
|
|
1872 |
indep_set (algebra_embed l) q"
|
14516
|
1873 |
by (import prob_indep INDEP_SET_LIST)
|
|
1874 |
|
17694
|
1875 |
lemma INDEP_INDEP_SET: "ALL (f::(nat => bool) => 'a::type * (nat => bool)) (p::'a::type => bool)
|
|
1876 |
q::(nat => bool) => bool.
|
|
1877 |
indep f & measurable q --> indep_set (p o (fst o f)) (q o (snd o f))"
|
14516
|
1878 |
by (import prob_indep INDEP_INDEP_SET)
|
|
1879 |
|
17644
|
1880 |
lemma INDEP_UNIT: "ALL x::'a::type. indep (UNIT x)"
|
14516
|
1881 |
by (import prob_indep INDEP_UNIT)
|
|
1882 |
|
|
1883 |
lemma INDEP_SDEST: "indep SDEST"
|
|
1884 |
by (import prob_indep INDEP_SDEST)
|
|
1885 |
|
17644
|
1886 |
lemma BIND_STEP: "ALL f::(nat => bool) => 'a::type * (nat => bool).
|
|
1887 |
BIND SDEST (%k::bool. f o SCONS k) = f"
|
14516
|
1888 |
by (import prob_indep BIND_STEP)
|
|
1889 |
|
17694
|
1890 |
lemma INDEP_BIND_SDEST: "ALL f::bool => (nat => bool) => 'a::type * (nat => bool).
|
|
1891 |
(ALL x::bool. indep (f x)) --> indep (BIND SDEST f)"
|
14516
|
1892 |
by (import prob_indep INDEP_BIND_SDEST)
|
|
1893 |
|
17694
|
1894 |
lemma INDEP_BIND: "ALL (f::(nat => bool) => 'a::type * (nat => bool))
|
|
1895 |
g::'a::type => (nat => bool) => 'b::type * (nat => bool).
|
|
1896 |
indep f & (ALL x::'a::type. indep (g x)) --> indep (BIND f g)"
|
14516
|
1897 |
by (import prob_indep INDEP_BIND)
|
|
1898 |
|
17694
|
1899 |
lemma INDEP_PROB: "ALL (f::(nat => bool) => 'a::type * (nat => bool)) (p::'a::type => bool)
|
|
1900 |
q::(nat => bool) => bool.
|
|
1901 |
indep f & measurable q -->
|
|
1902 |
prob (pred_set.INTER (p o (fst o f)) (q o (snd o f))) =
|
|
1903 |
prob (p o (fst o f)) * prob q"
|
14516
|
1904 |
by (import prob_indep INDEP_PROB)
|
|
1905 |
|
17694
|
1906 |
lemma INDEP_MEASURABLE1: "ALL (f::(nat => bool) => 'a::type * (nat => bool)) p::'a::type => bool.
|
|
1907 |
indep f --> measurable (p o (fst o f))"
|
14516
|
1908 |
by (import prob_indep INDEP_MEASURABLE1)
|
|
1909 |
|
17694
|
1910 |
lemma INDEP_MEASURABLE2: "ALL (f::(nat => bool) => 'a::type * (nat => bool)) q::(nat => bool) => bool.
|
|
1911 |
indep f & measurable q --> measurable (q o (snd o f))"
|
14516
|
1912 |
by (import prob_indep INDEP_MEASURABLE2)
|
|
1913 |
|
17694
|
1914 |
lemma PROB_INDEP_BOUND: "ALL (f::(nat => bool) => nat * (nat => bool)) n::nat.
|
|
1915 |
indep f -->
|
|
1916 |
prob (%s::nat => bool. fst (f s) < Suc n) =
|
|
1917 |
prob (%s::nat => bool. fst (f s) < n) +
|
|
1918 |
prob (%s::nat => bool. fst (f s) = n)"
|
14516
|
1919 |
by (import prob_indep PROB_INDEP_BOUND)
|
|
1920 |
|
|
1921 |
;end_setup
|
|
1922 |
|
|
1923 |
;setup_theory prob_uniform
|
|
1924 |
|
|
1925 |
consts
|
|
1926 |
unif_bound :: "nat => nat"
|
|
1927 |
|
|
1928 |
defs
|
|
1929 |
unif_bound_primdef: "unif_bound ==
|
17644
|
1930 |
WFREC
|
17652
|
1931 |
(SOME R::nat => nat => bool. WF R & (ALL v::nat. R (Suc v div 2) (Suc v)))
|
17644
|
1932 |
(%unif_bound::nat => nat.
|
17652
|
1933 |
nat_case 0 (%v1::nat. Suc (unif_bound (Suc v1 div 2))))"
|
14516
|
1934 |
|
|
1935 |
lemma unif_bound_primitive_def: "unif_bound =
|
17644
|
1936 |
WFREC
|
17652
|
1937 |
(SOME R::nat => nat => bool. WF R & (ALL v::nat. R (Suc v div 2) (Suc v)))
|
17644
|
1938 |
(%unif_bound::nat => nat.
|
17652
|
1939 |
nat_case 0 (%v1::nat. Suc (unif_bound (Suc v1 div 2))))"
|
14516
|
1940 |
by (import prob_uniform unif_bound_primitive_def)
|
|
1941 |
|
17652
|
1942 |
lemma unif_bound_def: "unif_bound 0 = 0 &
|
|
1943 |
unif_bound (Suc (v::nat)) = Suc (unif_bound (Suc v div 2))"
|
14516
|
1944 |
by (import prob_uniform unif_bound_def)
|
|
1945 |
|
17694
|
1946 |
lemma unif_bound_ind: "ALL P::nat => bool.
|
|
1947 |
P 0 & (ALL v::nat. P (Suc v div 2) --> P (Suc v)) --> All P"
|
14516
|
1948 |
by (import prob_uniform unif_bound_ind)
|
|
1949 |
|
|
1950 |
constdefs
|
|
1951 |
unif_tupled :: "nat * (nat => bool) => nat * (nat => bool)"
|
|
1952 |
"unif_tupled ==
|
17644
|
1953 |
WFREC
|
|
1954 |
(SOME R::nat * (nat => bool) => nat * (nat => bool) => bool.
|
17652
|
1955 |
WF R & (ALL (s::nat => bool) v2::nat. R (Suc v2 div 2, s) (Suc v2, s)))
|
17644
|
1956 |
(%(unif_tupled::nat * (nat => bool) => nat * (nat => bool)) (v::nat,
|
|
1957 |
v1::nat => bool).
|
17652
|
1958 |
case v of 0 => (0, v1)
|
17644
|
1959 |
| Suc (v3::nat) =>
|
17652
|
1960 |
let (m::nat, s'::nat => bool) = unif_tupled (Suc v3 div 2, v1)
|
|
1961 |
in (if SHD s' then 2 * m + 1 else 2 * m, STL s'))"
|
14516
|
1962 |
|
|
1963 |
lemma unif_tupled_primitive_def: "unif_tupled =
|
17644
|
1964 |
WFREC
|
|
1965 |
(SOME R::nat * (nat => bool) => nat * (nat => bool) => bool.
|
17652
|
1966 |
WF R & (ALL (s::nat => bool) v2::nat. R (Suc v2 div 2, s) (Suc v2, s)))
|
17644
|
1967 |
(%(unif_tupled::nat * (nat => bool) => nat * (nat => bool)) (v::nat,
|
|
1968 |
v1::nat => bool).
|
17652
|
1969 |
case v of 0 => (0, v1)
|
17644
|
1970 |
| Suc (v3::nat) =>
|
17652
|
1971 |
let (m::nat, s'::nat => bool) = unif_tupled (Suc v3 div 2, v1)
|
|
1972 |
in (if SHD s' then 2 * m + 1 else 2 * m, STL s'))"
|
14516
|
1973 |
by (import prob_uniform unif_tupled_primitive_def)
|
|
1974 |
|
|
1975 |
consts
|
|
1976 |
unif :: "nat => (nat => bool) => nat * (nat => bool)"
|
|
1977 |
|
|
1978 |
defs
|
17644
|
1979 |
unif_primdef: "unif == %(x::nat) x1::nat => bool. unif_tupled (x, x1)"
|
|
1980 |
|
|
1981 |
lemma unif_curried_def: "ALL (x::nat) x1::nat => bool. unif x x1 = unif_tupled (x, x1)"
|
14516
|
1982 |
by (import prob_uniform unif_curried_def)
|
|
1983 |
|
17652
|
1984 |
lemma unif_def: "unif 0 (s::nat => bool) = (0, s) &
|
17644
|
1985 |
unif (Suc (v2::nat)) s =
|
17652
|
1986 |
(let (m::nat, s'::nat => bool) = unif (Suc v2 div 2) s
|
|
1987 |
in (if SHD s' then 2 * m + 1 else 2 * m, STL s'))"
|
14516
|
1988 |
by (import prob_uniform unif_def)
|
|
1989 |
|
17694
|
1990 |
lemma unif_ind: "ALL P::nat => (nat => bool) => bool.
|
|
1991 |
All (P 0) &
|
|
1992 |
(ALL (v2::nat) s::nat => bool. P (Suc v2 div 2) s --> P (Suc v2) s) -->
|
|
1993 |
(ALL v::nat. All (P v))"
|
14516
|
1994 |
by (import prob_uniform unif_ind)
|
|
1995 |
|
|
1996 |
constdefs
|
|
1997 |
uniform_tupled :: "nat * nat * (nat => bool) => nat * (nat => bool)"
|
17694
|
1998 |
"uniform_tupled ==
|
|
1999 |
WFREC
|
|
2000 |
(SOME R::nat * nat * (nat => bool) => nat * nat * (nat => bool) => bool.
|
|
2001 |
WF R &
|
|
2002 |
(ALL (t::nat) (s::nat => bool) (n::nat) (res::nat) s'::nat => bool.
|
|
2003 |
(res, s') = unif n s & ~ res < Suc n -->
|
|
2004 |
R (t, Suc n, s') (Suc t, Suc n, s)))
|
|
2005 |
(%(uniform_tupled::nat * nat * (nat => bool) => nat * (nat => bool))
|
|
2006 |
(v::nat, v1::nat * (nat => bool)).
|
|
2007 |
case v of
|
|
2008 |
0 => (%(v3::nat, v4::nat => bool).
|
|
2009 |
case v3 of 0 => ARB | Suc (v5::nat) => (0, v4))
|
|
2010 |
v1
|
|
2011 |
| Suc (v2::nat) =>
|
|
2012 |
(%(v7::nat, v8::nat => bool).
|
|
2013 |
case v7 of 0 => ARB
|
|
2014 |
| Suc (v9::nat) =>
|
|
2015 |
let (res::nat, s'::nat => bool) = unif v9 v8
|
|
2016 |
in if res < Suc v9 then (res, s')
|
|
2017 |
else uniform_tupled (v2, Suc v9, s'))
|
|
2018 |
v1)"
|
14516
|
2019 |
|
17694
|
2020 |
lemma uniform_tupled_primitive_def: "uniform_tupled =
|
|
2021 |
WFREC
|
|
2022 |
(SOME R::nat * nat * (nat => bool) => nat * nat * (nat => bool) => bool.
|
|
2023 |
WF R &
|
|
2024 |
(ALL (t::nat) (s::nat => bool) (n::nat) (res::nat) s'::nat => bool.
|
|
2025 |
(res, s') = unif n s & ~ res < Suc n -->
|
|
2026 |
R (t, Suc n, s') (Suc t, Suc n, s)))
|
|
2027 |
(%(uniform_tupled::nat * nat * (nat => bool) => nat * (nat => bool))
|
|
2028 |
(v::nat, v1::nat * (nat => bool)).
|
|
2029 |
case v of
|
|
2030 |
0 => (%(v3::nat, v4::nat => bool).
|
|
2031 |
case v3 of 0 => ARB | Suc (v5::nat) => (0, v4))
|
|
2032 |
v1
|
|
2033 |
| Suc (v2::nat) =>
|
|
2034 |
(%(v7::nat, v8::nat => bool).
|
|
2035 |
case v7 of 0 => ARB
|
|
2036 |
| Suc (v9::nat) =>
|
|
2037 |
let (res::nat, s'::nat => bool) = unif v9 v8
|
|
2038 |
in if res < Suc v9 then (res, s')
|
|
2039 |
else uniform_tupled (v2, Suc v9, s'))
|
|
2040 |
v1)"
|
14516
|
2041 |
by (import prob_uniform uniform_tupled_primitive_def)
|
|
2042 |
|
|
2043 |
consts
|
|
2044 |
uniform :: "nat => nat => (nat => bool) => nat * (nat => bool)"
|
|
2045 |
|
|
2046 |
defs
|
17644
|
2047 |
uniform_primdef: "uniform == %(x::nat) (x1::nat) x2::nat => bool. uniform_tupled (x, x1, x2)"
|
|
2048 |
|
|
2049 |
lemma uniform_curried_def: "ALL (x::nat) (x1::nat) x2::nat => bool.
|
|
2050 |
uniform x x1 x2 = uniform_tupled (x, x1, x2)"
|
14516
|
2051 |
by (import prob_uniform uniform_curried_def)
|
|
2052 |
|
17694
|
2053 |
lemma uniform_ind: "ALL P::nat => nat => (nat => bool) => bool.
|
|
2054 |
(ALL x::nat. All (P (Suc x) 0)) &
|
|
2055 |
All (P 0 0) &
|
|
2056 |
(ALL x::nat. All (P 0 (Suc x))) &
|
|
2057 |
(ALL (x::nat) (xa::nat) xb::nat => bool.
|
|
2058 |
(ALL (xc::nat) xd::nat => bool.
|
|
2059 |
(xc, xd) = unif xa xb & ~ xc < Suc xa --> P x (Suc xa) xd) -->
|
|
2060 |
P (Suc x) (Suc xa) xb) -->
|
|
2061 |
(ALL (x::nat) xa::nat. All (P x xa))"
|
14516
|
2062 |
by (import prob_uniform uniform_ind)
|
|
2063 |
|
17652
|
2064 |
lemma uniform_def: "uniform 0 (Suc (n::nat)) (s::nat => bool) = (0, s) &
|
17644
|
2065 |
uniform (Suc (t::nat)) (Suc n) s =
|
|
2066 |
(let (xa::nat, x::nat => bool) = unif n s
|
14516
|
2067 |
in if xa < Suc n then (xa, x) else uniform t (Suc n) x)"
|
|
2068 |
by (import prob_uniform uniform_def)
|
|
2069 |
|
17652
|
2070 |
lemma SUC_DIV_TWO_ZERO: "ALL n::nat. (Suc n div 2 = 0) = (n = 0)"
|
14516
|
2071 |
by (import prob_uniform SUC_DIV_TWO_ZERO)
|
|
2072 |
|
17652
|
2073 |
lemma UNIF_BOUND_LOWER: "ALL n::nat. n < 2 ^ unif_bound n"
|
14516
|
2074 |
by (import prob_uniform UNIF_BOUND_LOWER)
|
|
2075 |
|
17652
|
2076 |
lemma UNIF_BOUND_LOWER_SUC: "ALL n::nat. Suc n <= 2 ^ unif_bound n"
|
14516
|
2077 |
by (import prob_uniform UNIF_BOUND_LOWER_SUC)
|
|
2078 |
|
17694
|
2079 |
lemma UNIF_BOUND_UPPER: "ALL n::nat. n ~= 0 --> 2 ^ unif_bound n <= 2 * n"
|
14516
|
2080 |
by (import prob_uniform UNIF_BOUND_UPPER)
|
|
2081 |
|
17652
|
2082 |
lemma UNIF_BOUND_UPPER_SUC: "ALL n::nat. 2 ^ unif_bound n <= Suc (2 * n)"
|
14516
|
2083 |
by (import prob_uniform UNIF_BOUND_UPPER_SUC)
|
|
2084 |
|
17652
|
2085 |
lemma UNIF_DEF_MONAD: "unif 0 = UNIT 0 &
|
17644
|
2086 |
(ALL n::nat.
|
14516
|
2087 |
unif (Suc n) =
|
17652
|
2088 |
BIND (unif (Suc n div 2))
|
17644
|
2089 |
(%m::nat.
|
17652
|
2090 |
BIND SDEST (%b::bool. UNIT (if b then 2 * m + 1 else 2 * m))))"
|
14516
|
2091 |
by (import prob_uniform UNIF_DEF_MONAD)
|
|
2092 |
|
17652
|
2093 |
lemma UNIFORM_DEF_MONAD: "(ALL x::nat. uniform 0 (Suc x) = UNIT 0) &
|
17644
|
2094 |
(ALL (x::nat) xa::nat.
|
14516
|
2095 |
uniform (Suc x) (Suc xa) =
|
17644
|
2096 |
BIND (unif xa)
|
|
2097 |
(%m::nat. if m < Suc xa then UNIT m else uniform x (Suc xa)))"
|
14516
|
2098 |
by (import prob_uniform UNIFORM_DEF_MONAD)
|
|
2099 |
|
17644
|
2100 |
lemma INDEP_UNIF: "ALL n::nat. indep (unif n)"
|
14516
|
2101 |
by (import prob_uniform INDEP_UNIF)
|
|
2102 |
|
17644
|
2103 |
lemma INDEP_UNIFORM: "ALL (t::nat) n::nat. indep (uniform t (Suc n))"
|
14516
|
2104 |
by (import prob_uniform INDEP_UNIFORM)
|
|
2105 |
|
17652
|
2106 |
lemma PROB_UNIF: "ALL (n::nat) k::nat.
|
|
2107 |
prob (%s::nat => bool. fst (unif n s) = k) =
|
|
2108 |
(if k < 2 ^ unif_bound n then (1 / 2) ^ unif_bound n else 0)"
|
14516
|
2109 |
by (import prob_uniform PROB_UNIF)
|
|
2110 |
|
17652
|
2111 |
lemma UNIF_RANGE: "ALL (n::nat) s::nat => bool. fst (unif n s) < 2 ^ unif_bound n"
|
14516
|
2112 |
by (import prob_uniform UNIF_RANGE)
|
|
2113 |
|
17644
|
2114 |
lemma PROB_UNIF_PAIR: "ALL (n::nat) (k::nat) k'::nat.
|
|
2115 |
(prob (%s::nat => bool. fst (unif n s) = k) =
|
|
2116 |
prob (%s::nat => bool. fst (unif n s) = k')) =
|
17652
|
2117 |
((k < 2 ^ unif_bound n) = (k' < 2 ^ unif_bound n))"
|
14516
|
2118 |
by (import prob_uniform PROB_UNIF_PAIR)
|
|
2119 |
|
17694
|
2120 |
lemma PROB_UNIF_BOUND: "ALL (n::nat) k::nat.
|
|
2121 |
k <= 2 ^ unif_bound n -->
|
|
2122 |
prob (%s::nat => bool. fst (unif n s) < k) =
|
|
2123 |
real k * (1 / 2) ^ unif_bound n"
|
14516
|
2124 |
by (import prob_uniform PROB_UNIF_BOUND)
|
|
2125 |
|
17652
|
2126 |
lemma PROB_UNIF_GOOD: "ALL n::nat. 1 / 2 <= prob (%s::nat => bool. fst (unif n s) < Suc n)"
|
14516
|
2127 |
by (import prob_uniform PROB_UNIF_GOOD)
|
|
2128 |
|
17644
|
2129 |
lemma UNIFORM_RANGE: "ALL (t::nat) (n::nat) s::nat => bool. fst (uniform t (Suc n) s) < Suc n"
|
14516
|
2130 |
by (import prob_uniform UNIFORM_RANGE)
|
|
2131 |
|
|
2132 |
lemma PROB_UNIFORM_LOWER_BOUND: "(All::(real => bool) => bool)
|
|
2133 |
(%b::real.
|
|
2134 |
(op -->::bool => bool => bool)
|
|
2135 |
((All::(nat => bool) => bool)
|
|
2136 |
(%k::nat.
|
|
2137 |
(op -->::bool => bool => bool)
|
|
2138 |
((op <::nat => nat => bool) k ((Suc::nat => nat) (n::nat)))
|
|
2139 |
((op <::real => real => bool)
|
|
2140 |
((prob::((nat => bool) => bool) => real)
|
|
2141 |
(%s::nat => bool.
|
|
2142 |
(op =::nat => nat => bool)
|
|
2143 |
((fst::nat * (nat => bool) => nat)
|
|
2144 |
((uniform::nat
|
|
2145 |
=> nat
|
|
2146 |
=> (nat => bool) => nat * (nat => bool))
|
|
2147 |
(t::nat) ((Suc::nat => nat) n) s))
|
|
2148 |
k))
|
|
2149 |
b)))
|
|
2150 |
((All::(nat => bool) => bool)
|
|
2151 |
(%m::nat.
|
|
2152 |
(op -->::bool => bool => bool)
|
|
2153 |
((op <::nat => nat => bool) m ((Suc::nat => nat) n))
|
|
2154 |
((op <::real => real => bool)
|
|
2155 |
((prob::((nat => bool) => bool) => real)
|
|
2156 |
(%s::nat => bool.
|
|
2157 |
(op <::nat => nat => bool)
|
|
2158 |
((fst::nat * (nat => bool) => nat)
|
|
2159 |
((uniform::nat
|
|
2160 |
=> nat
|
|
2161 |
=> (nat => bool) => nat * (nat => bool))
|
|
2162 |
t ((Suc::nat => nat) n) s))
|
|
2163 |
((Suc::nat => nat) m)))
|
|
2164 |
((op *::real => real => real)
|
|
2165 |
((real::nat => real) ((Suc::nat => nat) m)) b)))))"
|
|
2166 |
by (import prob_uniform PROB_UNIFORM_LOWER_BOUND)
|
|
2167 |
|
|
2168 |
lemma PROB_UNIFORM_UPPER_BOUND: "(All::(real => bool) => bool)
|
|
2169 |
(%b::real.
|
|
2170 |
(op -->::bool => bool => bool)
|
|
2171 |
((All::(nat => bool) => bool)
|
|
2172 |
(%k::nat.
|
|
2173 |
(op -->::bool => bool => bool)
|
|
2174 |
((op <::nat => nat => bool) k ((Suc::nat => nat) (n::nat)))
|
|
2175 |
((op <::real => real => bool) b
|
|
2176 |
((prob::((nat => bool) => bool) => real)
|
|
2177 |
(%s::nat => bool.
|
|
2178 |
(op =::nat => nat => bool)
|
|
2179 |
((fst::nat * (nat => bool) => nat)
|
|
2180 |
((uniform::nat
|
|
2181 |
=> nat
|
|
2182 |
=> (nat => bool) => nat * (nat => bool))
|
|
2183 |
(t::nat) ((Suc::nat => nat) n) s))
|
|
2184 |
k)))))
|
|
2185 |
((All::(nat => bool) => bool)
|
|
2186 |
(%m::nat.
|
|
2187 |
(op -->::bool => bool => bool)
|
|
2188 |
((op <::nat => nat => bool) m ((Suc::nat => nat) n))
|
|
2189 |
((op <::real => real => bool)
|
|
2190 |
((op *::real => real => real)
|
|
2191 |
((real::nat => real) ((Suc::nat => nat) m)) b)
|
|
2192 |
((prob::((nat => bool) => bool) => real)
|
|
2193 |
(%s::nat => bool.
|
|
2194 |
(op <::nat => nat => bool)
|
|
2195 |
((fst::nat * (nat => bool) => nat)
|
|
2196 |
((uniform::nat
|
|
2197 |
=> nat
|
|
2198 |
=> (nat => bool) => nat * (nat => bool))
|
|
2199 |
t ((Suc::nat => nat) n) s))
|
|
2200 |
((Suc::nat => nat) m)))))))"
|
|
2201 |
by (import prob_uniform PROB_UNIFORM_UPPER_BOUND)
|
|
2202 |
|
17694
|
2203 |
lemma PROB_UNIFORM_PAIR_SUC: "ALL (t::nat) (n::nat) (k::nat) k'::nat.
|
|
2204 |
k < Suc n & k' < Suc n -->
|
|
2205 |
abs (prob (%s::nat => bool. fst (uniform t (Suc n) s) = k) -
|
|
2206 |
prob (%s::nat => bool. fst (uniform t (Suc n) s) = k'))
|
|
2207 |
<= (1 / 2) ^ t"
|
14516
|
2208 |
by (import prob_uniform PROB_UNIFORM_PAIR_SUC)
|
|
2209 |
|
17694
|
2210 |
lemma PROB_UNIFORM_SUC: "ALL (t::nat) (n::nat) k::nat.
|
|
2211 |
k < Suc n -->
|
|
2212 |
abs (prob (%s::nat => bool. fst (uniform t (Suc n) s) = k) -
|
|
2213 |
1 / real (Suc n))
|
|
2214 |
<= (1 / 2) ^ t"
|
14516
|
2215 |
by (import prob_uniform PROB_UNIFORM_SUC)
|
|
2216 |
|
17694
|
2217 |
lemma PROB_UNIFORM: "ALL (t::nat) (n::nat) k::nat.
|
|
2218 |
k < n -->
|
|
2219 |
abs (prob (%s::nat => bool. fst (uniform t n s) = k) - 1 / real n)
|
|
2220 |
<= (1 / 2) ^ t"
|
14516
|
2221 |
by (import prob_uniform PROB_UNIFORM)
|
|
2222 |
|
|
2223 |
;end_setup
|
|
2224 |
|
|
2225 |
end
|
|
2226 |
|