5 inductive even :: "nat \<Rightarrow> bool" and odd :: "nat \<Rightarrow> bool" where |
5 inductive even :: "nat \<Rightarrow> bool" and odd :: "nat \<Rightarrow> bool" where |
6 "even 0" |
6 "even 0" |
7 | "even n \<Longrightarrow> odd (Suc n)" |
7 | "even n \<Longrightarrow> odd (Suc n)" |
8 | "odd n \<Longrightarrow> even (Suc n)" |
8 | "odd n \<Longrightarrow> even (Suc n)" |
9 |
9 |
10 code_pred (mode: [], [1]) [show_steps] even . |
10 code_pred (mode: [], [1]) even . |
11 code_pred [depth_limited, show_compilation] even . |
11 code_pred [depth_limited] even . |
12 (*code_pred [rpred] even .*) |
12 code_pred [rpred] even . |
13 |
13 |
14 thm odd.equation |
14 thm odd.equation |
15 thm even.equation |
15 thm even.equation |
16 thm odd.depth_limited_equation |
16 thm odd.depth_limited_equation |
17 thm even.depth_limited_equation |
17 thm even.depth_limited_equation |
18 (* |
|
19 thm even.rpred_equation |
18 thm even.rpred_equation |
20 thm odd.rpred_equation |
19 thm odd.rpred_equation |
21 *) |
20 |
22 (* |
|
23 lemma unit: "unit_case f = (\<lambda>x. f)" |
|
24 apply (rule ext) |
|
25 apply (case_tac x) |
|
26 apply (simp only: unit.cases) |
|
27 done |
|
28 |
|
29 lemma "even_1 (Suc (Suc n)) = even_1 n" |
|
30 thm even.equation(2) |
|
31 unfolding even.equation(1)[of "Suc (Suc n)"] |
|
32 unfolding odd.equation |
|
33 unfolding single_bind |
|
34 apply simp |
|
35 apply (simp add: unit) |
|
36 unfolding bind_single |
|
37 apply (rule refl) |
|
38 done |
|
39 *) |
|
40 values "{x. even 2}" |
21 values "{x. even 2}" |
41 values "{x. odd 2}" |
22 values "{x. odd 2}" |
42 values 10 "{n. even n}" |
23 values 10 "{n. even n}" |
43 values 10 "{n. odd n}" |
24 values 10 "{n. odd n}" |
44 values [depth_limit = 2] "{x. even 6}" |
25 values [depth_limit = 2] "{x. even 6}" |
45 values [depth_limit = 7] "{x. even 6}" |
26 values [depth_limit = 7] "{x. even 6}" |
46 values [depth_limit = 2] "{x. odd 7}" |
27 values [depth_limit = 2] "{x. odd 7}" |
47 values [depth_limit = 8] "{x. odd 7}" |
28 values [depth_limit = 8] "{x. odd 7}" |
48 |
29 |
49 values [depth_limit = 7] 10 "{n. even n}" |
30 values [depth_limit = 7] 10 "{n. even n}" |
|
31 |
50 definition odd' where "odd' x == \<not> even x" |
32 definition odd' where "odd' x == \<not> even x" |
51 |
33 |
52 code_pred [inductify] odd' . |
34 code_pred [inductify] odd' . |
53 code_pred [inductify, depth_limited] odd' . |
35 code_pred [inductify, depth_limited] odd' . |
54 (*code_pred [inductify, rpred] odd' .*) |
36 code_pred [inductify, rpred] odd' . |
55 |
37 |
56 thm odd'.depth_limited_equation |
38 thm odd'.depth_limited_equation |
57 values [depth_limit = 2] "{x. odd' 7}" |
39 values [depth_limit = 2] "{x. odd' 7}" |
58 values [depth_limit = 9] "{x. odd' 7}" |
40 values [depth_limit = 9] "{x. odd' 7}" |
59 |
41 |
60 definition even'' where "even'' = even" |
|
61 definition odd'' where "odd'' = odd" |
|
62 |
|
63 |
|
64 |
|
65 lemma [code_pred_intros]: |
|
66 "even'' 0" |
|
67 "odd'' x ==> even'' (Suc x)" |
|
68 "\<not> even'' x ==> odd'' x" |
|
69 apply (auto simp add: even''_def odd''_def intro: even_odd.intros) |
|
70 sorry |
|
71 |
|
72 code_pred odd'' sorry |
|
73 thm odd''.equation |
|
74 code_pred [depth_limited] odd'' sorry |
|
75 |
|
76 values "{x. odd'' 10}" |
|
77 values "{x. even'' 10}" |
|
78 values [depth_limit=5] "{x. odd'' 10}" |
|
79 |
|
80 inductive append :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" where |
42 inductive append :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" where |
81 "append [] xs xs" |
43 "append [] xs xs" |
82 | "append xs ys zs \<Longrightarrow> append (x # xs) ys (x # zs)" |
44 | "append xs ys zs \<Longrightarrow> append (x # xs) ys (x # zs)" |
83 |
45 |
84 code_pred (mode: [1, 2], [3], [2, 3], [1, 3], [1, 2, 3]) [inductify] append . |
46 code_pred (mode: [1, 2], [3], [2, 3], [1, 3], [1, 2, 3]) [inductify] append . |
85 code_pred [depth_limited] append . |
47 code_pred [depth_limited] append . |
86 (*code_pred [rpred] append .*) |
48 code_pred [rpred] append . |
87 |
49 |
88 thm append.equation |
50 thm append.equation |
89 thm append.depth_limited_equation |
51 thm append.depth_limited_equation |
90 (*thm append.rpred_equation*) |
52 thm append.rpred_equation |
91 |
53 |
92 values "{(ys, xs). append xs ys [0, Suc 0, 2]}" |
54 values "{(ys, xs). append xs ys [0, Suc 0, 2]}" |
93 values "{zs. append [0, Suc 0, 2] [17, 8] zs}" |
55 values "{zs. append [0, Suc 0, 2] [17, 8] zs}" |
94 values "{ys. append [0, Suc 0, 2] ys [0, Suc 0, 2, 17, 0, 5]}" |
56 values "{ys. append [0, Suc 0, 2] ys [0, Suc 0, 2, 17, 0, 5]}" |
95 values [depth_limit = 3] "{(xs, ys). append xs ys [1, 2, 3, 4, (5::nat)]}" |
57 values [depth_limit = 3] "{(xs, ys). append xs ys [1, 2, 3, 4, (5::nat)]}" |
96 (*values [depth_limit = 10 random] 15 "{(ys, zs). append [1::nat, 2] ys zs}"*) |
58 values [depth_limit = 10 random] 15 "{(ys, zs). append [1::nat, 2] ys zs}" |
97 |
59 |
98 value [code] "Predicate.the (append_1_2 [0::int, 1, 2] [3, 4, 5])" |
60 value [code] "Predicate.the (append_1_2 [0::int, 1, 2] [3, 4, 5])" |
99 value [code] "Predicate.the (append_3 ([]::int list))" |
61 value [code] "Predicate.the (append_3 ([]::int list))" |
100 |
62 |
101 subsection {* Tricky case with alternative rules *} |
63 subsection {* Tricky case with alternative rules *} |
162 "tupled_append''' ([], xs, xs)" |
124 "tupled_append''' ([], xs, xs)" |
163 | "yszs = (ys, zs) ==> tupled_append''' (xs, yszs) \<Longrightarrow> tupled_append''' (x # xs, ys, x # zs)" |
125 | "yszs = (ys, zs) ==> tupled_append''' (xs, yszs) \<Longrightarrow> tupled_append''' (x # xs, ys, x # zs)" |
164 |
126 |
165 code_pred [inductify] tupled_append''' . |
127 code_pred [inductify] tupled_append''' . |
166 thm tupled_append'''.equation |
128 thm tupled_append'''.equation |
167 (* TODO: Missing a few modes *) |
|
168 |
129 |
169 inductive map_ofP :: "('a \<times> 'b) list \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" |
130 inductive map_ofP :: "('a \<times> 'b) list \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" |
170 where |
131 where |
171 "map_ofP ((a, b)#xs) a b" |
132 "map_ofP ((a, b)#xs) a b" |
172 | "map_ofP xs a b \<Longrightarrow> map_ofP (x#xs) a b" |
133 | "map_ofP xs a b \<Longrightarrow> map_ofP (x#xs) a b" |
173 |
134 |
174 code_pred (mode: [1], [1, 2], [1, 2, 3], [1, 3]) map_ofP . |
135 code_pred (mode: [1], [1, 2], [1, 2, 3], [1, 3]) map_ofP . |
175 thm map_ofP.equation |
136 thm map_ofP.equation |
|
137 |
176 section {* reverse *} |
138 section {* reverse *} |
177 |
139 |
178 inductive rev where |
140 inductive rev where |
179 "rev [] []" |
141 "rev [] []" |
180 | "rev xs xs' ==> append xs' [x] ys ==> rev (x#xs) ys" |
142 | "rev xs xs' ==> append xs' [x] ys ==> rev (x#xs) ys" |
197 "partition f [] [] []" |
159 "partition f [] [] []" |
198 | "f x \<Longrightarrow> partition f xs ys zs \<Longrightarrow> partition f (x # xs) (x # ys) zs" |
160 | "f x \<Longrightarrow> partition f xs ys zs \<Longrightarrow> partition f (x # xs) (x # ys) zs" |
199 | "\<not> f x \<Longrightarrow> partition f xs ys zs \<Longrightarrow> partition f (x # xs) ys (x # zs)" |
161 | "\<not> f x \<Longrightarrow> partition f xs ys zs \<Longrightarrow> partition f (x # xs) ys (x # zs)" |
200 |
162 |
201 code_pred (mode: [1], [2, 3], [1, 2], [1, 3], [1, 2, 3]) partition . |
163 code_pred (mode: [1], [2, 3], [1, 2], [1, 3], [1, 2, 3]) partition . |
202 (*code_pred [depth_limited] partition .*) |
164 code_pred [depth_limited] partition . |
203 (*thm partition.depth_limited_equation*) |
165 code_pred [rpred] partition . |
204 (*code_pred [rpred] partition .*) |
|
205 |
166 |
206 inductive tupled_partition :: "('a \<Rightarrow> bool) \<Rightarrow> ('a list \<times> 'a list \<times> 'a list) \<Rightarrow> bool" |
167 inductive tupled_partition :: "('a \<Rightarrow> bool) \<Rightarrow> ('a list \<times> 'a list \<times> 'a list) \<Rightarrow> bool" |
207 for f where |
168 for f where |
208 "tupled_partition f ([], [], [])" |
169 "tupled_partition f ([], [], [])" |
209 | "f x \<Longrightarrow> tupled_partition f (xs, ys, zs) \<Longrightarrow> tupled_partition f (x # xs, x # ys, zs)" |
170 | "f x \<Longrightarrow> tupled_partition f (xs, ys, zs) \<Longrightarrow> tupled_partition f (x # xs, x # ys, zs)" |
370 where "Min s r x \<equiv> s x \<and> (\<forall>y. r x y \<longrightarrow> x = y)" |
318 where "Min s r x \<equiv> s x \<and> (\<forall>y. r x y \<longrightarrow> x = y)" |
371 |
319 |
372 code_pred [inductify] Min . |
320 code_pred [inductify] Min . |
373 |
321 |
374 subsection {* Examples with lists *} |
322 subsection {* Examples with lists *} |
375 (* |
323 |
376 inductive filterP for Pa where |
324 subsubsection {* Lexicographic order *} |
377 "(filterP::('a => bool) => 'a list => 'a list => bool) (Pa::'a => bool) [] []" |
325 |
378 | "[| (res::'a list) = (y::'a) # (resa::'a list); (filterP::('a => bool) => 'a list => 'a list => bool) (Pa::'a => bool) (xt::'a list) resa; Pa y |] |
|
379 ==> filterP Pa (y # xt) res" |
|
380 | "[| (filterP::('a => bool) => 'a list => 'a list => bool) (Pa::'a => bool) (xt::'a list) (res::'a list); ~ Pa (y::'a) |] ==> filterP Pa (y # xt) res" |
|
381 *) |
|
382 (* |
|
383 code_pred (inductify_all) (rpred) filterP . |
|
384 thm filterP.rpred_equation |
|
385 *) |
|
386 thm lexord_def |
326 thm lexord_def |
387 code_pred [inductify] lexord . |
327 code_pred [inductify] lexord . |
388 (*code_pred [inductify, rpred] lexord .*) |
328 code_pred [inductify, rpred] lexord . |
389 thm lexord.equation |
329 thm lexord.equation |
|
330 thm lexord.rpred_equation |
|
331 |
390 inductive less_than_nat :: "nat * nat => bool" |
332 inductive less_than_nat :: "nat * nat => bool" |
391 where |
333 where |
392 "less_than_nat (0, x)" |
334 "less_than_nat (0, x)" |
393 | "less_than_nat (x, y) ==> less_than_nat (Suc x, Suc y)" |
335 | "less_than_nat (x, y) ==> less_than_nat (Suc x, Suc y)" |
394 |
336 |
395 code_pred less_than_nat . |
337 code_pred less_than_nat . |
|
338 |
396 code_pred [depth_limited] less_than_nat . |
339 code_pred [depth_limited] less_than_nat . |
397 (*code_pred [rpred] less_than_nat .*) |
340 code_pred [rpred] less_than_nat . |
398 |
341 |
399 inductive test_lexord :: "nat list * nat list => bool" |
342 inductive test_lexord :: "nat list * nat list => bool" |
400 where |
343 where |
401 "lexord less_than_nat (xs, ys) ==> test_lexord (xs, ys)" |
344 "lexord less_than_nat (xs, ys) ==> test_lexord (xs, ys)" |
402 |
345 |
403 (*code_pred [rpred] test_lexord .*) |
346 code_pred [rpred] test_lexord . |
404 code_pred [depth_limited] test_lexord . |
347 code_pred [depth_limited] test_lexord . |
405 thm test_lexord.depth_limited_equation |
348 thm test_lexord.depth_limited_equation |
406 (*thm test_lexord.rpred_equation*) |
349 thm test_lexord.rpred_equation |
407 |
350 |
408 (*values [depth_limit = 5] "{x. test_lexord ([1, 2, 3], [1, 2, 5])}"*) |
351 values "{x. test_lexord ([1, 2, 3], [1, 2, 5])}" |
409 |
352 values [depth_limit = 5] "{x. test_lexord ([1, 2, 3], [1, 2, 5])}" |
410 (*values [depth_limit = 25 random] "{xys. test_lexord xys}"*) |
353 values [depth_limit = 12 random] "{xys. test_lexord xys}" |
411 |
354 values [depth_limit = 5 random] "{xy. lexord less_than_nat xy}" |
412 (*values [depth_limit = 5 random] "{xy. lexord less_than_nat xy}"*) |
355 (* |
413 |
|
414 lemma "(u, v) : lexord less_than_nat ==> (x @ u, y @ v) : lexord less_than_nat" |
356 lemma "(u, v) : lexord less_than_nat ==> (x @ u, y @ v) : lexord less_than_nat" |
415 (*quickcheck[generator=pred_compile]*) |
357 quickcheck[generator=pred_compile] |
416 oops |
358 oops |
417 |
359 *) |
418 lemmas [code_pred_def] = lexn_conv lex_conv lenlex_conv |
360 lemmas [code_pred_def] = lexn_conv lex_conv lenlex_conv |
419 (* |
361 |
420 code_pred [inductify] lexn . |
362 code_pred [inductify] lexn . |
421 thm lexn.equation |
363 thm lexn.equation |
422 *) |
364 |
423 (*code_pred [inductify, rpred] lexn .*) |
365 code_pred [rpred] lexn . |
424 |
366 |
425 (*thm lexn.rpred_equation*) |
367 thm lexn.rpred_equation |
426 |
368 |
427 code_pred [inductify] lenlex . |
369 code_pred [inductify] lenlex . |
428 thm lenlex.equation |
370 thm lenlex.equation |
429 (* |
371 |
430 code_pred [inductify, rpred] lenlex . |
372 code_pred [inductify, rpred] lenlex . |
431 thm lenlex.rpred_equation |
373 thm lenlex.rpred_equation |
432 *) |
374 |
433 thm lists.intros |
375 thm lists.intros |
434 code_pred [inductify] lists . |
376 code_pred [inductify] lists . |
435 |
377 |
436 thm lists.equation |
378 thm lists.equation |
437 |
379 |
489 |
428 |
490 section {* List functions *} |
429 section {* List functions *} |
491 |
430 |
492 code_pred [inductify] length . |
431 code_pred [inductify] length . |
493 thm size_listP.equation |
432 thm size_listP.equation |
494 (* |
|
495 code_pred [inductify, rpred] length . |
433 code_pred [inductify, rpred] length . |
496 thm size_listP.rpred_equation |
434 thm size_listP.rpred_equation |
497 values [depth_limit = 10 random] 20 "{xs. size_listP (xs::nat list) (5::nat)}" |
435 values [depth_limit = 10 random] 20 "{xs. size_listP (xs::nat list) (5::nat)}" |
498 *) |
436 |
499 code_pred [inductify] concat . |
437 code_pred [inductify] concat . |
500 thm concatP.equation |
|
501 |
|
502 code_pred [inductify] hd . |
438 code_pred [inductify] hd . |
503 code_pred [inductify] tl . |
439 code_pred [inductify] tl . |
504 code_pred [inductify] last . |
440 code_pred [inductify] last . |
505 code_pred [inductify] butlast . |
441 code_pred [inductify] butlast . |
506 thm listsum.simps |
|
507 (*code_pred [inductify] listsum .*) |
442 (*code_pred [inductify] listsum .*) |
508 code_pred [inductify] take . |
443 code_pred [inductify] take . |
509 code_pred [inductify] drop . |
444 code_pred [inductify] drop . |
510 code_pred [inductify] zip . |
445 code_pred [inductify] zip . |
511 code_pred [inductify] upt . |
446 code_pred [inductify] upt . |
518 code_pred [inductify] List.rev . |
453 code_pred [inductify] List.rev . |
519 code_pred [inductify] map . |
454 code_pred [inductify] map . |
520 code_pred [inductify] foldr . |
455 code_pred [inductify] foldr . |
521 code_pred [inductify] foldl . |
456 code_pred [inductify] foldl . |
522 code_pred [inductify] filter . |
457 code_pred [inductify] filter . |
523 (* |
|
524 code_pred [inductify, rpred] filter . |
458 code_pred [inductify, rpred] filter . |
525 thm filterP.equation |
459 thm filterP.rpred_equation |
526 *) |
460 |
527 definition test where "test xs = filter (\<lambda>x. x = (1::nat)) xs" |
461 definition test where "test xs = filter (\<lambda>x. x = (1::nat)) xs" |
528 |
|
529 (* TODO: implement higher-order replacement correctly *) |
|
530 code_pred [inductify] test . |
462 code_pred [inductify] test . |
531 thm testP.equation |
463 thm testP.equation |
532 (* |
|
533 code_pred [inductify, rpred] test . |
464 code_pred [inductify, rpred] test . |
534 *) |
465 thm testP.rpred_equation |
535 section {* Handling set operations *} |
|
536 |
|
537 |
|
538 |
466 |
539 section {* Context Free Grammar *} |
467 section {* Context Free Grammar *} |
540 |
468 |
541 datatype alphabet = a | b |
469 datatype alphabet = a | b |
542 |
470 |
547 | "w \<in> S\<^isub>1 \<Longrightarrow> a # w \<in> A\<^isub>1" |
475 | "w \<in> S\<^isub>1 \<Longrightarrow> a # w \<in> A\<^isub>1" |
548 | "w \<in> S\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1" |
476 | "w \<in> S\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1" |
549 | "\<lbrakk>v \<in> B\<^isub>1; v \<in> B\<^isub>1\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>1" |
477 | "\<lbrakk>v \<in> B\<^isub>1; v \<in> B\<^isub>1\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>1" |
550 |
478 |
551 code_pred [inductify] S\<^isub>1p . |
479 code_pred [inductify] S\<^isub>1p . |
552 |
480 code_pred [inductify, rpred] S\<^isub>1p . |
553 thm S\<^isub>1p.equation |
481 thm S\<^isub>1p.equation |
554 (*thm S\<^isub>1p.rpred_equation*) |
482 thm S\<^isub>1p.rpred_equation |
555 |
483 |
556 (*values [depth_limit = 5 random] "{x. S\<^isub>1p x}"*) |
484 values [depth_limit = 5 random] "{x. S\<^isub>1p x}" |
557 |
485 |
558 inductive is_a where |
486 inductive is_a where |
559 "is_a a" |
487 "is_a a" |
560 |
488 |
561 inductive is_b where |
489 inductive is_b where |
562 "is_b b" |
490 "is_b b" |
563 |
491 |
564 code_pred is_a . |
492 code_pred is_a . |
565 code_pred [depth_limited] is_a . |
493 code_pred [depth_limited] is_a . |
566 code_pred [rpred] is_a . |
494 code_pred [rpred] is_a . |
567 |
495 |
568 values [depth_limit=5 random] "{x. is_a x}" |
496 values [depth_limit=5 random] "{x. is_a x}" |
|
497 code_pred [depth_limited] is_b . |
569 code_pred [rpred] is_b . |
498 code_pred [rpred] is_b . |
570 |
499 |
571 (*code_pred [rpred] filterP .*) |
500 code_pred [inductify, depth_limited] filter . |
572 (*values [depth_limit=5 random] "{x. filterP is_a [a, b] x}" |
501 |
573 values [depth_limit=3 random] "{x. filterP is_b [a, b] x}" |
502 values [depth_limit=5] "{x. filterP is_a [a, b] x}" |
574 *) |
503 values [depth_limit=3] "{x. filterP is_b [a, b] x}" |
575 (* |
504 |
576 lemma "w \<in> S\<^isub>1 \<Longrightarrow> length (filter (\<lambda>x. x = a) w) = 1" |
505 lemma "w \<in> S\<^isub>1 \<Longrightarrow> length (filter (\<lambda>x. x = a) w) = 1" |
577 quickcheck[generator=pred_compile, size=10] |
506 quickcheck[generator=pred_compile, size=10] |
578 oops |
507 oops |
579 *) |
508 |
580 inductive test_lemma where |
509 inductive test_lemma where |
581 "S\<^isub>1p w ==> filterP is_a w r1 ==> size_listP r1 r2 ==> filterP is_b w r3 ==> size_listP r3 r4 ==> r2 \<noteq> r4 ==> test_lemma w" |
510 "S\<^isub>1p w ==> filterP is_a w r1 ==> size_listP r1 r2 ==> filterP is_b w r3 ==> size_listP r3 r4 ==> r2 \<noteq> r4 ==> test_lemma w" |
582 (* |
511 (* |
583 code_pred [rpred] test_lemma . |
512 code_pred [rpred] test_lemma . |
584 *) |
513 *) |
618 thm filterP.intros |
547 thm filterP.intros |
619 thm filterP.depth_limited_equation |
548 thm filterP.depth_limited_equation |
620 values [depth_limit=3] "{x. filterP test_lemma'_hoaux [a, b] x}" |
549 values [depth_limit=3] "{x. filterP test_lemma'_hoaux [a, b] x}" |
621 values [depth_limit=4 random] "{w. test_lemma w}" |
550 values [depth_limit=4 random] "{w. test_lemma w}" |
622 values [depth_limit=4 random] "{w. test_lemma' w}" |
551 values [depth_limit=4 random] "{w. test_lemma' w}" |
623 |
552 *) |
|
553 (* |
624 theorem S\<^isub>1_sound: |
554 theorem S\<^isub>1_sound: |
625 "w \<in> S\<^isub>1p \<Longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
555 "w \<in> S\<^isub>1p \<Longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
626 quickcheck[generator=pred_compile, size=5] |
556 quickcheck[generator=pred_compile, size=15] |
627 oops |
557 oops |
628 |
558 *) |
629 |
|
630 inductive_set S\<^isub>2 and A\<^isub>2 and B\<^isub>2 where |
559 inductive_set S\<^isub>2 and A\<^isub>2 and B\<^isub>2 where |
631 "[] \<in> S\<^isub>2" |
560 "[] \<in> S\<^isub>2" |
632 | "w \<in> A\<^isub>2 \<Longrightarrow> b # w \<in> S\<^isub>2" |
561 | "w \<in> A\<^isub>2 \<Longrightarrow> b # w \<in> S\<^isub>2" |
633 | "w \<in> B\<^isub>2 \<Longrightarrow> a # w \<in> S\<^isub>2" |
562 | "w \<in> B\<^isub>2 \<Longrightarrow> a # w \<in> S\<^isub>2" |
634 | "w \<in> S\<^isub>2 \<Longrightarrow> a # w \<in> A\<^isub>2" |
563 | "w \<in> S\<^isub>2 \<Longrightarrow> a # w \<in> A\<^isub>2" |
638 code_pred [inductify, rpred] S\<^isub>2 . |
567 code_pred [inductify, rpred] S\<^isub>2 . |
639 thm S\<^isub>2.rpred_equation |
568 thm S\<^isub>2.rpred_equation |
640 thm A\<^isub>2.rpred_equation |
569 thm A\<^isub>2.rpred_equation |
641 thm B\<^isub>2.rpred_equation |
570 thm B\<^isub>2.rpred_equation |
642 |
571 |
643 values [depth_limit = 4 random] "{x. S\<^isub>2 x}" |
572 values [depth_limit = 15 random] "{x. S\<^isub>2 x}" |
644 |
573 |
645 theorem S\<^isub>2_sound: |
574 theorem S\<^isub>2_sound: |
646 "w \<in> S\<^isub>2 \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
575 "w \<in> S\<^isub>2 \<longrightarrow> length [x \<leftarrow> w. x = a] = length [x \<leftarrow> w. x = b]" |
647 (*quickcheck[generator=SML]*) |
576 (*quickcheck[generator=SML]*) |
648 quickcheck[generator=pred_compile, size=4, iterations=1] |
577 (*quickcheck[generator=pred_compile, size=15, iterations=1]*) |
649 oops |
578 oops |
650 |
579 |
651 inductive_set S\<^isub>3 and A\<^isub>3 and B\<^isub>3 where |
580 inductive_set S\<^isub>3 and A\<^isub>3 and B\<^isub>3 where |
652 "[] \<in> S\<^isub>3" |
581 "[] \<in> S\<^isub>3" |
653 | "w \<in> A\<^isub>3 \<Longrightarrow> b # w \<in> S\<^isub>3" |
582 | "w \<in> A\<^isub>3 \<Longrightarrow> b # w \<in> S\<^isub>3" |