summaryrefslogtreecommitdiff
path: root/backends/hol4/divDefLibTestTheory.sig
blob: d8cc4ab5c45d83362a09646c364d03df27368cec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
signature divDefLibTestTheory =
sig
  type thm = Thm.thm
  
  (*  Definitions  *)
    val btree_TY_DEF : thm
    val btree_case_def : thm
    val btree_height_def : thm
    val btree_size_def : thm
    val even_def : thm
    val list_t_TY_DEF : thm
    val list_t_case_def : thm
    val list_t_size_def : thm
    val node_TY_DEF : thm
    val node_case_def : thm
    val nth0_def : thm
    val nth_def : thm
    val odd_def : thm
    val tree_TY_DEF : thm
    val tree_case_def : thm
    val tree_height_def : thm
    val tree_nodes_height_def : thm
    val tree_size_def : thm
  
  (*  Theorems  *)
    val btree_11 : thm
    val btree_Axiom : thm
    val btree_case_cong : thm
    val btree_case_eq : thm
    val btree_distinct : thm
    val btree_induction : thm
    val btree_nchotomy : thm
    val datatype_btree : thm
    val datatype_list_t : thm
    val datatype_tree : thm
    val list_t_11 : thm
    val list_t_Axiom : thm
    val list_t_case_cong : thm
    val list_t_case_eq : thm
    val list_t_distinct : thm
    val list_t_induction : thm
    val list_t_nchotomy : thm
    val node_11 : thm
    val node_Axiom : thm
    val node_case_cong : thm
    val node_case_eq : thm
    val node_induction : thm
    val node_nchotomy : thm
    val tree_11 : thm
    val tree_Axiom : thm
    val tree_case_cong : thm
    val tree_case_eq : thm
    val tree_distinct : thm
    val tree_induction : thm
    val tree_nchotomy : thm
    val tree_size_eq : thm
  
  val divDefLibTest_grammars : type_grammar.grammar * term_grammar.grammar
(*
   [divDef] Parent theory of "divDefLibTest"
   
   [btree_TY_DEF]  Definition
      
      ⊢ ∃rep.
          TYPE_DEFINITION
            (λa0'.
                 ∀ $var$('btree').
                   (∀a0'.
                      (∃a. a0' =
                           (λa. ind_type$CONSTR 0 a (λn. ind_type$BOTTOM))
                             a) ∨
                      (∃a0 a1.
                         a0' =
                         (λa0 a1.
                              ind_type$CONSTR (SUC 0) ARB
                                (ind_type$FCONS a0
                                   (ind_type$FCONS a1 (λn. ind_type$BOTTOM))))
                           a0 a1 ∧ $var$('btree') a0 ∧ $var$('btree') a1) ⇒
                      $var$('btree') a0') ⇒
                   $var$('btree') a0') rep
   
   [btree_case_def]  Definition
      
      ⊢ (∀a f f1. btree_CASE (BLeaf a) f f1 = f a) ∧
        ∀a0 a1 f f1. btree_CASE (BNode a0 a1) f f1 = f1 a0 a1
   
   [btree_height_def]  Definition
      
      ⊢ ∀tree.
          btree_height tree =
          case tree of
            BLeaf v => Return 1
          | BNode l r =>
            do
              hl <- btree_height l;
              hr <- btree_height r;
              Return (hl + hr)
            od
   
   [btree_size_def]  Definition
      
      ⊢ (∀f a. btree_size f (BLeaf a) = 1 + f a) ∧
        ∀f a0 a1.
          btree_size f (BNode a0 a1) =
          1 + (btree_size f a0 + btree_size f a1)
   
   [even_def]  Definition
      
      ⊢ ∀i. even i = if i = 0 then Return T else odd (i − 1)
   
   [list_t_TY_DEF]  Definition
      
      ⊢ ∃rep.
          TYPE_DEFINITION
            (λa0'.
                 ∀ $var$('list_t').
                   (∀a0'.
                      (∃a0 a1.
                         a0' =
                         (λa0 a1.
                              ind_type$CONSTR 0 a0
                                (ind_type$FCONS a1 (λn. ind_type$BOTTOM)))
                           a0 a1 ∧ $var$('list_t') a1) ∨
                      a0' =
                      ind_type$CONSTR (SUC 0) ARB (λn. ind_type$BOTTOM) ⇒
                      $var$('list_t') a0') ⇒
                   $var$('list_t') a0') rep
   
   [list_t_case_def]  Definition
      
      ⊢ (∀a0 a1 f v. list_t_CASE (ListCons a0 a1) f v = f a0 a1) ∧
        ∀f v. list_t_CASE ListNil f v = v
   
   [list_t_size_def]  Definition
      
      ⊢ (∀f a0 a1.
           list_t_size f (ListCons a0 a1) = 1 + (f a0 + list_t_size f a1)) ∧
        ∀f. list_t_size f ListNil = 0
   
   [node_TY_DEF]  Definition
      
      ⊢ ∃rep.
          TYPE_DEFINITION
            (λa1'.
                 ∀ $var$('tree') $var$('node')
                     $var$('@temp @ind_typedivDefLibTest8list').
                   (∀a0'.
                      (∃a. a0' =
                           (λa. ind_type$CONSTR 0 a (λn. ind_type$BOTTOM))
                             a) ∨
                      (∃a. a0' =
                           (λa.
                                ind_type$CONSTR (SUC 0) ARB
                                  (ind_type$FCONS a (λn. ind_type$BOTTOM)))
                             a ∧ $var$('node') a) ⇒
                      $var$('tree') a0') ∧
                   (∀a1'.
                      (∃a. a1' =
                           (λa.
                                ind_type$CONSTR (SUC (SUC 0)) ARB
                                  (ind_type$FCONS a (λn. ind_type$BOTTOM)))
                             a ∧
                           $var$('@temp @ind_typedivDefLibTest8list') a) ⇒
                      $var$('node') a1') ∧
                   (∀a2.
                      a2 =
                      ind_type$CONSTR (SUC (SUC (SUC 0))) ARB
                        (λn. ind_type$BOTTOM) ∨
                      (∃a0 a1.
                         a2 =
                         (λa0 a1.
                              ind_type$CONSTR (SUC (SUC (SUC (SUC 0)))) ARB
                                (ind_type$FCONS a0
                                   (ind_type$FCONS a1 (λn. ind_type$BOTTOM))))
                           a0 a1 ∧ $var$('tree') a0 ∧
                         $var$('@temp @ind_typedivDefLibTest8list') a1) ⇒
                      $var$('@temp @ind_typedivDefLibTest8list') a2) ⇒
                   $var$('node') a1') rep
   
   [node_case_def]  Definition
      
      ⊢ ∀a f. node_CASE (Node a) f = f a
   
   [nth0_def]  Definition
      
      ⊢ ∀ls i.
          nth0 ls i =
          case ls of
            ListCons x tl => if i = 0 then Return x else nth0 tl (i − 1)
          | ListNil => Fail Failure
   
   [nth_def]  Definition
      
      ⊢ ∀ls i.
          nth ls i =
          case ls of
            ListCons x tl =>
              if u32_to_int i = 0 then Return x
              else do i0 <- u32_sub i (int_to_u32 1); nth tl i0 od
          | ListNil => Fail Failure
   
   [odd_def]  Definition
      
      ⊢ ∀i. odd i = if i = 0 then Return F else even (i − 1)
   
   [tree_TY_DEF]  Definition
      
      ⊢ ∃rep.
          TYPE_DEFINITION
            (λa0'.
                 ∀ $var$('tree') $var$('node')
                     $var$('@temp @ind_typedivDefLibTest8list').
                   (∀a0'.
                      (∃a. a0' =
                           (λa. ind_type$CONSTR 0 a (λn. ind_type$BOTTOM))
                             a) ∨
                      (∃a. a0' =
                           (λa.
                                ind_type$CONSTR (SUC 0) ARB
                                  (ind_type$FCONS a (λn. ind_type$BOTTOM)))
                             a ∧ $var$('node') a) ⇒
                      $var$('tree') a0') ∧
                   (∀a1'.
                      (∃a. a1' =
                           (λa.
                                ind_type$CONSTR (SUC (SUC 0)) ARB
                                  (ind_type$FCONS a (λn. ind_type$BOTTOM)))
                             a ∧
                           $var$('@temp @ind_typedivDefLibTest8list') a) ⇒
                      $var$('node') a1') ∧
                   (∀a2.
                      a2 =
                      ind_type$CONSTR (SUC (SUC (SUC 0))) ARB
                        (λn. ind_type$BOTTOM) ∨
                      (∃a0 a1.
                         a2 =
                         (λa0 a1.
                              ind_type$CONSTR (SUC (SUC (SUC (SUC 0)))) ARB
                                (ind_type$FCONS a0
                                   (ind_type$FCONS a1 (λn. ind_type$BOTTOM))))
                           a0 a1 ∧ $var$('tree') a0 ∧
                         $var$('@temp @ind_typedivDefLibTest8list') a1) ⇒
                      $var$('@temp @ind_typedivDefLibTest8list') a2) ⇒
                   $var$('tree') a0') rep
   
   [tree_case_def]  Definition
      
      ⊢ (∀a f f1. tree_CASE (TLeaf a) f f1 = f a) ∧
        ∀a f f1. tree_CASE (TNode a) f f1 = f1 a
   
   [tree_height_def]  Definition
      
      ⊢ ∀tree.
          tree_height tree =
          case tree of
            TLeaf v => Return 1
          | TNode (Node ls) => tree_nodes_height ls
   
   [tree_nodes_height_def]  Definition
      
      ⊢ ∀ls.
          tree_nodes_height ls =
          case ls of
            [] => Return 0
          | t::tl =>
            do
              h1 <- tree_height t;
              h2 <- tree_nodes_height tl;
              Return (h1 + h2)
            od
   
   [tree_size_def]  Definition
      
      ⊢ (∀f a. tree_size f (TLeaf a) = 1 + f a) ∧
        (∀f a. tree_size f (TNode a) = 1 + node_size f a) ∧
        (∀f a. node_size f (Node a) = 1 + tree1_size f a) ∧
        (∀f. tree1_size f [] = 0) ∧
        ∀f a0 a1.
          tree1_size f (a0::a1) = 1 + (tree_size f a0 + tree1_size f a1)
   
   [btree_11]  Theorem
      
      ⊢ (∀a a'. BLeaf a = BLeaf a' ⇔ a = a') ∧
        ∀a0 a1 a0' a1'. BNode a0 a1 = BNode a0' a1' ⇔ a0 = a0' ∧ a1 = a1'
   
   [btree_Axiom]  Theorem
      
      ⊢ ∀f0 f1. ∃fn.
          (∀a. fn (BLeaf a) = f0 a) ∧
          ∀a0 a1. fn (BNode a0 a1) = f1 a0 a1 (fn a0) (fn a1)
   
   [btree_case_cong]  Theorem
      
      ⊢ ∀M M' f f1.
          M = M' ∧ (∀a. M' = BLeaf a ⇒ f a = f' a) ∧
          (∀a0 a1. M' = BNode a0 a1 ⇒ f1 a0 a1 = f1' a0 a1) ⇒
          btree_CASE M f f1 = btree_CASE M' f' f1'
   
   [btree_case_eq]  Theorem
      
      ⊢ btree_CASE x f f1 = v ⇔
        (∃a. x = BLeaf a ∧ f a = v) ∨ ∃b b0. x = BNode b b0 ∧ f1 b b0 = v
   
   [btree_distinct]  Theorem
      
      ⊢ ∀a1 a0 a. BLeaf a ≠ BNode a0 a1
   
   [btree_induction]  Theorem
      
      ⊢ ∀P. (∀a. P (BLeaf a)) ∧ (∀b b0. P b ∧ P b0 ⇒ P (BNode b b0)) ⇒
            ∀b. P b
   
   [btree_nchotomy]  Theorem
      
      ⊢ ∀bb. (∃a. bb = BLeaf a) ∨ ∃b b0. bb = BNode b b0
   
   [datatype_btree]  Theorem
      
      ⊢ DATATYPE (btree BLeaf BNode)
   
   [datatype_list_t]  Theorem
      
      ⊢ DATATYPE (list_t ListCons ListNil)
   
   [datatype_tree]  Theorem
      
      ⊢ DATATYPE (tree TLeaf TNode ∧ node Node)
   
   [list_t_11]  Theorem
      
      ⊢ ∀a0 a1 a0' a1'.
          ListCons a0 a1 = ListCons a0' a1' ⇔ a0 = a0' ∧ a1 = a1'
   
   [list_t_Axiom]  Theorem
      
      ⊢ ∀f0 f1. ∃fn.
          (∀a0 a1. fn (ListCons a0 a1) = f0 a0 a1 (fn a1)) ∧
          fn ListNil = f1
   
   [list_t_case_cong]  Theorem
      
      ⊢ ∀M M' f v.
          M = M' ∧ (∀a0 a1. M' = ListCons a0 a1 ⇒ f a0 a1 = f' a0 a1) ∧
          (M' = ListNil ⇒ v = v') ⇒
          list_t_CASE M f v = list_t_CASE M' f' v'
   
   [list_t_case_eq]  Theorem
      
      ⊢ list_t_CASE x f v = v' ⇔
        (∃t l. x = ListCons t l ∧ f t l = v') ∨ x = ListNil ∧ v = v'
   
   [list_t_distinct]  Theorem
      
      ⊢ ∀a1 a0. ListCons a0 a1 ≠ ListNil
   
   [list_t_induction]  Theorem
      
      ⊢ ∀P. (∀l. P l ⇒ ∀t. P (ListCons t l)) ∧ P ListNil ⇒ ∀l. P l
   
   [list_t_nchotomy]  Theorem
      
      ⊢ ∀ll. (∃t l. ll = ListCons t l) ∨ ll = ListNil
   
   [node_11]  Theorem
      
      ⊢ ∀a a'. Node a = Node a' ⇔ a = a'
   
   [node_Axiom]  Theorem
      
      ⊢ ∀f0 f1 f2 f3 f4. ∃fn0 fn1 fn2.
          (∀a. fn0 (TLeaf a) = f0 a) ∧ (∀a. fn0 (TNode a) = f1 a (fn1 a)) ∧
          (∀a. fn1 (Node a) = f2 a (fn2 a)) ∧ fn2 [] = f3 ∧
          ∀a0 a1. fn2 (a0::a1) = f4 a0 a1 (fn0 a0) (fn2 a1)
   
   [node_case_cong]  Theorem
      
      ⊢ ∀M M' f.
          M = M' ∧ (∀a. M' = Node a ⇒ f a = f' a) ⇒
          node_CASE M f = node_CASE M' f'
   
   [node_case_eq]  Theorem
      
      ⊢ node_CASE x f = v ⇔ ∃l. x = Node l ∧ f l = v
   
   [node_induction]  Theorem
      
      ⊢ ∀P0 P1 P2.
          (∀a. P0 (TLeaf a)) ∧ (∀n. P1 n ⇒ P0 (TNode n)) ∧
          (∀l. P2 l ⇒ P1 (Node l)) ∧ P2 [] ∧
          (∀t l. P0 t ∧ P2 l ⇒ P2 (t::l)) ⇒
          (∀t. P0 t) ∧ (∀n. P1 n) ∧ ∀l. P2 l
   
   [node_nchotomy]  Theorem
      
      ⊢ ∀nn. ∃l. nn = Node l
   
   [tree_11]  Theorem
      
      ⊢ (∀a a'. TLeaf a = TLeaf a' ⇔ a = a') ∧
        ∀a a'. TNode a = TNode a' ⇔ a = a'
   
   [tree_Axiom]  Theorem
      
      ⊢ ∀f0 f1 f2 f3 f4. ∃fn0 fn1 fn2.
          (∀a. fn0 (TLeaf a) = f0 a) ∧ (∀a. fn0 (TNode a) = f1 a (fn1 a)) ∧
          (∀a. fn1 (Node a) = f2 a (fn2 a)) ∧ fn2 [] = f3 ∧
          ∀a0 a1. fn2 (a0::a1) = f4 a0 a1 (fn0 a0) (fn2 a1)
   
   [tree_case_cong]  Theorem
      
      ⊢ ∀M M' f f1.
          M = M' ∧ (∀a. M' = TLeaf a ⇒ f a = f' a) ∧
          (∀a. M' = TNode a ⇒ f1 a = f1' a) ⇒
          tree_CASE M f f1 = tree_CASE M' f' f1'
   
   [tree_case_eq]  Theorem
      
      ⊢ tree_CASE x f f1 = v ⇔
        (∃a. x = TLeaf a ∧ f a = v) ∨ ∃n. x = TNode n ∧ f1 n = v
   
   [tree_distinct]  Theorem
      
      ⊢ ∀a' a. TLeaf a ≠ TNode a'
   
   [tree_induction]  Theorem
      
      ⊢ ∀P0 P1 P2.
          (∀a. P0 (TLeaf a)) ∧ (∀n. P1 n ⇒ P0 (TNode n)) ∧
          (∀l. P2 l ⇒ P1 (Node l)) ∧ P2 [] ∧
          (∀t l. P0 t ∧ P2 l ⇒ P2 (t::l)) ⇒
          (∀t. P0 t) ∧ (∀n. P1 n) ∧ ∀l. P2 l
   
   [tree_nchotomy]  Theorem
      
      ⊢ ∀tt. (∃a. tt = TLeaf a) ∨ ∃n. tt = TNode n
   
   [tree_size_eq]  Theorem
      
      ⊢ tree1_size f = list_size (tree_size f)
   
   
*)
end