author | bulwahn |
Tue, 27 Oct 2009 09:03:56 +0100 | |
changeset 33253 | d9ca0c3bf680 |
parent 33250 | 5c2af18a3237 |
child 33255 | 75b01355e5d4 |
permissions | -rw-r--r-- |
31129
d2cead76fca2
split Predicate_Compile examples into separate theory
haftmann
parents:
31123
diff
changeset
|
1 |
theory Predicate_Compile_ex |
33120 | 2 |
imports Main Predicate_Compile_Alternative_Defs |
30374
7311a1546d85
added predicate compiler, as formally checked prototype, not as user package
haftmann
parents:
diff
changeset
|
3 |
begin |
7311a1546d85
added predicate compiler, as formally checked prototype, not as user package
haftmann
parents:
diff
changeset
|
4 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
5 |
subsection {* Basic predicates *} |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
6 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
7 |
inductive False' :: "bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
8 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
9 |
code_pred (mode: []) False' . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
10 |
code_pred [depth_limited] False' . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
11 |
code_pred [rpred, show_compilation] False' . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
12 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
13 |
inductive EmptySet :: "'a \<Rightarrow> bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
14 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
15 |
code_pred (mode: [], [1]) EmptySet . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
16 |
|
33253 | 17 |
definition EmptySet' :: "'a \<Rightarrow> bool" |
18 |
where "EmptySet' = {}" |
|
19 |
||
20 |
code_pred (mode: [], [1]) [inductify, show_intermediate_results] EmptySet' . |
|
21 |
||
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
22 |
inductive EmptyRel :: "'a \<Rightarrow> 'b \<Rightarrow> bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
23 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
24 |
code_pred (mode: [], [1], [2], [1, 2]) EmptyRel . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
25 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
26 |
inductive EmptyClosure :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
27 |
for r :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
28 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
29 |
code_pred (mode: [], [1], [2], [1, 2])EmptyClosure . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
30 |
thm EmptyClosure.equation |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
31 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
32 |
inductive False'' :: "bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
33 |
where |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
34 |
"False \<Longrightarrow> False''" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
35 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
36 |
code_pred (mode: []) False'' . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
37 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
38 |
inductive EmptySet' :: "'a \<Rightarrow> bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
39 |
where |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
40 |
"False \<Longrightarrow> EmptySet' x" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
41 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
42 |
code_pred (mode: [1]) EmptySet' . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
43 |
code_pred (mode: [], [1]) [inductify] EmptySet' . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
44 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
45 |
inductive True' :: "bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
46 |
where |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
47 |
"True \<Longrightarrow> True'" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
48 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
49 |
code_pred (mode: []) True' . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
50 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
51 |
consts a' :: 'a |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
52 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
53 |
inductive Fact :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
54 |
where |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
55 |
"Fact a' a'" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
56 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
57 |
code_pred (mode: [], [1], [2], [1, 2]) Fact . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
58 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
59 |
inductive zerozero :: "nat * nat => bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
60 |
where |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
61 |
"zerozero (0, 0)" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
62 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
63 |
code_pred zerozero . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
64 |
code_pred [rpred, show_compilation] zerozero . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
65 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
66 |
subsection {* even predicate *} |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
67 |
|
30972
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
68 |
inductive even :: "nat \<Rightarrow> bool" and odd :: "nat \<Rightarrow> bool" where |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
69 |
"even 0" |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
70 |
| "even n \<Longrightarrow> odd (Suc n)" |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
71 |
| "odd n \<Longrightarrow> even (Suc n)" |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
72 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
73 |
code_pred (mode: [], [1]) even . |
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
74 |
code_pred [depth_limited] even . |
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
75 |
code_pred [rpred] even . |
33137
0d16c07f8d24
added option to generate random values to values command in the predicate compiler
bulwahn
parents:
33136
diff
changeset
|
76 |
|
31514 | 77 |
thm odd.equation |
31123 | 78 |
thm even.equation |
33136
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
79 |
thm odd.depth_limited_equation |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
80 |
thm even.depth_limited_equation |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
81 |
thm even.rpred_equation |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
82 |
thm odd.rpred_equation |
30972
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
83 |
|
31217 | 84 |
values "{x. even 2}" |
85 |
values "{x. odd 2}" |
|
86 |
values 10 "{n. even n}" |
|
87 |
values 10 "{n. odd n}" |
|
33136
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
88 |
values [depth_limit = 2] "{x. even 6}" |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
89 |
values [depth_limit = 7] "{x. even 6}" |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
90 |
values [depth_limit = 2] "{x. odd 7}" |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
91 |
values [depth_limit = 8] "{x. odd 7}" |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
92 |
values [depth_limit = 7] 10 "{n. even n}" |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
93 |
|
33136
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
94 |
definition odd' where "odd' x == \<not> even x" |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
95 |
|
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
96 |
code_pred [inductify] odd' . |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
97 |
code_pred [inductify, depth_limited] odd' . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
98 |
code_pred [inductify, rpred] odd' . |
33136
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
99 |
|
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
100 |
thm odd'.depth_limited_equation |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
101 |
values [depth_limit = 2] "{x. odd' 7}" |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
102 |
values [depth_limit = 9] "{x. odd' 7}" |
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
103 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
104 |
inductive is_even :: "nat \<Rightarrow> bool" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
105 |
where |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
106 |
"n mod 2 = 0 \<Longrightarrow> is_even n" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
107 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
108 |
code_pred is_even . |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
109 |
|
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
110 |
subsection {* append predicate *} |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
111 |
|
30972
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
112 |
inductive append :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" where |
32340 | 113 |
"append [] xs xs" |
114 |
| "append xs ys zs \<Longrightarrow> append (x # xs) ys (x # zs)" |
|
30972
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
115 |
|
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33145
diff
changeset
|
116 |
code_pred (mode: [1, 2], [3], [2, 3], [1, 3], [1, 2, 3]) append . |
33136
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
117 |
code_pred [depth_limited] append . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
118 |
code_pred [rpred] append . |
31123 | 119 |
|
120 |
thm append.equation |
|
33136
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
121 |
thm append.depth_limited_equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
122 |
thm append.rpred_equation |
30972
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
123 |
|
31217 | 124 |
values "{(ys, xs). append xs ys [0, Suc 0, 2]}" |
125 |
values "{zs. append [0, Suc 0, 2] [17, 8] zs}" |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
126 |
values "{ys. append [0, Suc 0, 2] ys [0, Suc 0, 2, 17, 0, 5]}" |
33136
74d51fb3be2e
commented out the random generator compilation in the example file
bulwahn
parents:
33129
diff
changeset
|
127 |
values [depth_limit = 3] "{(xs, ys). append xs ys [1, 2, 3, 4, (5::nat)]}" |
33143
730a2e8a6ec6
modularized the compilation in the predicate compiler
bulwahn
parents:
33141
diff
changeset
|
128 |
values [random] 15 "{(ys, zs). append [1::nat, 2] ys zs}" |
31195 | 129 |
|
33111 | 130 |
value [code] "Predicate.the (append_1_2 [0::int, 1, 2] [3, 4, 5])" |
131 |
value [code] "Predicate.the (append_3 ([]::int list))" |
|
132 |
||
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
133 |
text {* tricky case with alternative rules *} |
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
134 |
|
33116
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
135 |
inductive append2 |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
136 |
where |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
137 |
"append2 [] xs xs" |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
138 |
| "append2 xs ys zs \<Longrightarrow> append2 (x # xs) ys (x # zs)" |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
139 |
|
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
140 |
lemma append2_Nil: "append2 [] (xs::'b list) xs" |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
141 |
by (simp add: append2.intros(1)) |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
142 |
|
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
143 |
lemmas [code_pred_intros] = append2_Nil append2.intros(2) |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
144 |
|
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
145 |
code_pred append2 |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
146 |
proof - |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
147 |
case append2 |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
148 |
from append2.cases[OF append2(1)] append2(2-3) show thesis by blast |
b379ee2cddb1
changed importing introduction rules to fix the same type variables in all introduction rules; improved mode analysis for partially applied relations; added test case; tuned
bulwahn
parents:
33114
diff
changeset
|
149 |
qed |
33128 | 150 |
|
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
151 |
inductive tupled_append :: "'a list \<times> 'a list \<times> 'a list \<Rightarrow> bool" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
152 |
where |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
153 |
"tupled_append ([], xs, xs)" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
154 |
| "tupled_append (xs, ys, zs) \<Longrightarrow> tupled_append (x # xs, ys, x # zs)" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
155 |
|
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
156 |
code_pred tupled_append . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
157 |
code_pred [rpred] tupled_append . |
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
158 |
thm tupled_append.equation |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
159 |
(* |
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
160 |
TODO: values with tupled modes |
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
161 |
values "{xs. tupled_append ([1,2,3], [4,5], xs)}" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
162 |
*) |
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
163 |
|
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
164 |
inductive tupled_append' |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
165 |
where |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
166 |
"tupled_append' ([], xs, xs)" |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
167 |
| "[| ys = fst (xa, y); x # zs = snd (xa, y); |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
168 |
tupled_append' (xs, ys, zs) |] ==> tupled_append' (x # xs, xa, y)" |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
169 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
170 |
code_pred tupled_append' . |
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
171 |
thm tupled_append'.equation |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
172 |
|
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
173 |
inductive tupled_append'' :: "'a list \<times> 'a list \<times> 'a list \<Rightarrow> bool" |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
174 |
where |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
175 |
"tupled_append'' ([], xs, xs)" |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
176 |
| "ys = fst yszs ==> x # zs = snd yszs ==> tupled_append'' (xs, ys, zs) \<Longrightarrow> tupled_append'' (x # xs, yszs)" |
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
177 |
|
33113 | 178 |
thm tupled_append''.cases |
179 |
||
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
180 |
code_pred [inductify] tupled_append'' . |
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
181 |
thm tupled_append''.equation |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
182 |
|
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
183 |
inductive tupled_append''' :: "'a list \<times> 'a list \<times> 'a list \<Rightarrow> bool" |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
184 |
where |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
185 |
"tupled_append''' ([], xs, xs)" |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
186 |
| "yszs = (ys, zs) ==> tupled_append''' (xs, yszs) \<Longrightarrow> tupled_append''' (x # xs, ys, x # zs)" |
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
187 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
188 |
code_pred [inductify] tupled_append''' . |
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
189 |
thm tupled_append'''.equation |
33114
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
bulwahn
parents:
33113
diff
changeset
|
190 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
191 |
subsection {* map_ofP predicate *} |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
192 |
|
33113 | 193 |
inductive map_ofP :: "('a \<times> 'b) list \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool" |
194 |
where |
|
195 |
"map_ofP ((a, b)#xs) a b" |
|
196 |
| "map_ofP xs a b \<Longrightarrow> map_ofP (x#xs) a b" |
|
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
197 |
|
33120 | 198 |
code_pred (mode: [1], [1, 2], [1, 2, 3], [1, 3]) map_ofP . |
33113 | 199 |
thm map_ofP.equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
200 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
201 |
subsection {* filter predicate *} |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
202 |
|
33147
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
203 |
inductive filter1 |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
204 |
for P |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
205 |
where |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
206 |
"filter1 P [] []" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
207 |
| "P x ==> filter1 P xs ys ==> filter1 P (x#xs) (x#ys)" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
208 |
| "\<not> P x ==> filter1 P xs ys ==> filter1 P (x#xs) ys" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
209 |
|
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
210 |
code_pred (mode: [1], [1, 2]) filter1 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
211 |
code_pred [depth_limited] filter1 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
212 |
code_pred [rpred] filter1 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
213 |
|
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
214 |
thm filter1.equation |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
215 |
|
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
216 |
inductive filter2 |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
217 |
where |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
218 |
"filter2 P [] []" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
219 |
| "P x ==> filter2 P xs ys ==> filter2 P (x#xs) (x#ys)" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
220 |
| "\<not> P x ==> filter2 P xs ys ==> filter2 P (x#xs) ys" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
221 |
|
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
222 |
code_pred (mode: [1, 2, 3], [1, 2]) filter2 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
223 |
code_pred [depth_limited] filter2 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
224 |
code_pred [rpred] filter2 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
225 |
thm filter2.equation |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
226 |
thm filter2.rpred_equation |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
227 |
|
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
228 |
inductive filter3 |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
229 |
for P |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
230 |
where |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
231 |
"List.filter P xs = ys ==> filter3 P xs ys" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
232 |
|
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
233 |
code_pred filter3 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
234 |
code_pred [depth_limited] filter3 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
235 |
thm filter3.depth_limited_equation |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
236 |
|
33147
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
237 |
inductive filter4 |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
238 |
where |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
239 |
"List.filter P xs = ys ==> filter4 P xs ys" |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
240 |
|
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
241 |
code_pred filter4 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
242 |
code_pred [depth_limited] filter4 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
243 |
code_pred [rpred] filter4 . |
180dc60bd88c
improving the compilation with higher-order arguments in the predicate compiler
bulwahn
parents:
33146
diff
changeset
|
244 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
245 |
subsection {* reverse predicate *} |
33112
6672184a736b
added a few tricky examples with tuples; added alternative introduction rules for some constants; corrected mode analysis with negation; improved fetching of definitions
bulwahn
parents:
33111
diff
changeset
|
246 |
|
32340 | 247 |
inductive rev where |
248 |
"rev [] []" |
|
249 |
| "rev xs xs' ==> append xs' [x] ys ==> rev (x#xs) ys" |
|
250 |
||
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
251 |
code_pred (mode: [1], [2], [1, 2]) rev . |
32340 | 252 |
|
253 |
thm rev.equation |
|
254 |
||
255 |
values "{xs. rev [0, 1, 2, 3::nat] xs}" |
|
30972
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
256 |
|
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
257 |
inductive tupled_rev where |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
258 |
"tupled_rev ([], [])" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
259 |
| "tupled_rev (xs, xs') \<Longrightarrow> tupled_append (xs', [x], ys) \<Longrightarrow> tupled_rev (x#xs, ys)" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
260 |
|
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
261 |
code_pred tupled_rev . |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
262 |
thm tupled_rev.equation |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
263 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
264 |
subsection {* partition predicate *} |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
265 |
|
30972
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
266 |
inductive partition :: "('a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
267 |
for f where |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
268 |
"partition f [] [] []" |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
269 |
| "f x \<Longrightarrow> partition f xs ys zs \<Longrightarrow> partition f (x # xs) (x # ys) zs" |
5b65835ccc92
some experiements towards user interface for predicate compiler
haftmann
parents:
30953
diff
changeset
|
270 |
| "\<not> f x \<Longrightarrow> partition f xs ys zs \<Longrightarrow> partition f (x # xs) ys (x # zs)" |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
271 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
272 |
code_pred (mode: [1], [2, 3], [1, 2], [1, 3], [1, 2, 3]) partition . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
273 |
code_pred [depth_limited] partition . |
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
274 |
code_pred [rpred] partition . |
31123 | 275 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
276 |
values 10 "{(ys, zs). partition is_even |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
277 |
[0, Suc 0, 2, 3, 4, 5, 6, 7] ys zs}" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
278 |
values 10 "{zs. partition is_even zs [0, 2] [3, 5]}" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
279 |
values 10 "{zs. partition is_even zs [0, 7] [3, 5]}" |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
280 |
|
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
281 |
inductive tupled_partition :: "('a \<Rightarrow> bool) \<Rightarrow> ('a list \<times> 'a list \<times> 'a list) \<Rightarrow> bool" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
282 |
for f where |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
283 |
"tupled_partition f ([], [], [])" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
284 |
| "f x \<Longrightarrow> tupled_partition f (xs, ys, zs) \<Longrightarrow> tupled_partition f (x # xs, x # ys, zs)" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
285 |
| "\<not> f x \<Longrightarrow> tupled_partition f (xs, ys, zs) \<Longrightarrow> tupled_partition f (x # xs, ys, x # zs)" |
32314
66bbad0bfef9
changed resolving depending predicates and fetching in the predicate compiler
bulwahn
parents:
32310
diff
changeset
|
286 |
|
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
287 |
code_pred tupled_partition . |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
288 |
|
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
289 |
thm tupled_partition.equation |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
290 |
|
31550
b63d253ed9e2
code_pred command now also requires proofs for dependent predicates; changed handling of parameters in introrules of executable function
bulwahn
parents:
31514
diff
changeset
|
291 |
lemma [code_pred_intros]: |
32340 | 292 |
"r a b \<Longrightarrow> tranclp r a b" |
293 |
"r a b \<Longrightarrow> tranclp r b c \<Longrightarrow> tranclp r a c" |
|
294 |
by auto |
|
31573
0047df9eb347
improved infrastructure of predicate compiler for adding manual introduction rules
bulwahn
parents:
31551
diff
changeset
|
295 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
296 |
subsection {* transitive predicate *} |
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
297 |
|
31573
0047df9eb347
improved infrastructure of predicate compiler for adding manual introduction rules
bulwahn
parents:
31551
diff
changeset
|
298 |
code_pred tranclp |
0047df9eb347
improved infrastructure of predicate compiler for adding manual introduction rules
bulwahn
parents:
31551
diff
changeset
|
299 |
proof - |
31580 | 300 |
case tranclp |
301 |
from this converse_tranclpE[OF this(1)] show thesis by metis |
|
31573
0047df9eb347
improved infrastructure of predicate compiler for adding manual introduction rules
bulwahn
parents:
31551
diff
changeset
|
302 |
qed |
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
303 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
304 |
code_pred [depth_limited] tranclp . |
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
305 |
code_pred [rpred] tranclp . |
31123 | 306 |
thm tranclp.equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
307 |
thm tranclp.rpred_equation |
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
308 |
|
31217 | 309 |
inductive succ :: "nat \<Rightarrow> nat \<Rightarrow> bool" where |
310 |
"succ 0 1" |
|
311 |
| "succ m n \<Longrightarrow> succ (Suc m) (Suc n)" |
|
312 |
||
31550
b63d253ed9e2
code_pred command now also requires proofs for dependent predicates; changed handling of parameters in introrules of executable function
bulwahn
parents:
31514
diff
changeset
|
313 |
code_pred succ . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
314 |
code_pred [rpred] succ . |
31217 | 315 |
thm succ.equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
316 |
thm succ.rpred_equation |
32340 | 317 |
|
318 |
values 10 "{(m, n). succ n m}" |
|
319 |
values "{m. succ 0 m}" |
|
320 |
values "{m. succ m 0}" |
|
321 |
||
32314
66bbad0bfef9
changed resolving depending predicates and fetching in the predicate compiler
bulwahn
parents:
32310
diff
changeset
|
322 |
(* FIXME: why does this not terminate? -- value chooses mode [] --> [1] and then starts enumerating all successors *) |
32355 | 323 |
|
31514 | 324 |
(* |
31217 | 325 |
values 20 "{n. tranclp succ 10 n}" |
326 |
values "{n. tranclp succ n 10}" |
|
327 |
values 20 "{(n, m). tranclp succ n m}" |
|
31514 | 328 |
*) |
31217 | 329 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
330 |
subsection {* IMP *} |
32424 | 331 |
|
332 |
types |
|
333 |
var = nat |
|
334 |
state = "int list" |
|
335 |
||
336 |
datatype com = |
|
337 |
Skip | |
|
338 |
Ass var "state => int" | |
|
339 |
Seq com com | |
|
340 |
IF "state => bool" com com | |
|
341 |
While "state => bool" com |
|
342 |
||
343 |
inductive exec :: "com => state => state => bool" where |
|
344 |
"exec Skip s s" | |
|
345 |
"exec (Ass x e) s (s[x := e(s)])" | |
|
346 |
"exec c1 s1 s2 ==> exec c2 s2 s3 ==> exec (Seq c1 c2) s1 s3" | |
|
347 |
"b s ==> exec c1 s t ==> exec (IF b c1 c2) s t" | |
|
348 |
"~b s ==> exec c2 s t ==> exec (IF b c1 c2) s t" | |
|
349 |
"~b s ==> exec (While b c) s s" | |
|
350 |
"b s1 ==> exec c s1 s2 ==> exec (While b c) s2 s3 ==> exec (While b c) s1 s3" |
|
351 |
||
352 |
code_pred exec . |
|
353 |
||
354 |
values "{t. exec |
|
355 |
(While (%s. s!0 > 0) (Seq (Ass 0 (%s. s!0 - 1)) (Ass 1 (%s. s!1 + 1)))) |
|
356 |
[3,5] t}" |
|
357 |
||
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
358 |
inductive tupled_exec :: "(com \<times> state \<times> state) \<Rightarrow> bool" where |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
359 |
"tupled_exec (Skip, s, s)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
360 |
"tupled_exec (Ass x e, s, s[x := e(s)])" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
361 |
"tupled_exec (c1, s1, s2) ==> tupled_exec (c2, s2, s3) ==> tupled_exec (Seq c1 c2, s1, s3)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
362 |
"b s ==> tupled_exec (c1, s, t) ==> tupled_exec (IF b c1 c2, s, t)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
363 |
"~b s ==> tupled_exec (c2, s, t) ==> tupled_exec (IF b c1 c2, s, t)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
364 |
"~b s ==> tupled_exec (While b c, s, s)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
365 |
"b s1 ==> tupled_exec (c, s1, s2) ==> tupled_exec (While b c, s2, s3) ==> tupled_exec (While b c, s1, s3)" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
366 |
|
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
367 |
code_pred tupled_exec . |
32424 | 368 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
369 |
subsection {* CCS *} |
32408 | 370 |
|
371 |
text{* This example formalizes finite CCS processes without communication or |
|
372 |
recursion. For simplicity, labels are natural numbers. *} |
|
373 |
||
374 |
datatype proc = nil | pre nat proc | or proc proc | par proc proc |
|
375 |
||
376 |
inductive step :: "proc \<Rightarrow> nat \<Rightarrow> proc \<Rightarrow> bool" where |
|
377 |
"step (pre n p) n p" | |
|
378 |
"step p1 a q \<Longrightarrow> step (or p1 p2) a q" | |
|
379 |
"step p2 a q \<Longrightarrow> step (or p1 p2) a q" | |
|
380 |
"step p1 a q \<Longrightarrow> step (par p1 p2) a (par q p2)" | |
|
381 |
"step p2 a q \<Longrightarrow> step (par p1 p2) a (par p1 q)" |
|
382 |
||
383 |
code_pred step . |
|
384 |
||
385 |
inductive steps where |
|
386 |
"steps p [] p" | |
|
387 |
"step p a q \<Longrightarrow> steps q as r \<Longrightarrow> steps p (a#as) r" |
|
388 |
||
389 |
code_pred steps . |
|
390 |
||
391 |
values 5 |
|
392 |
"{as . steps (par (or (pre 0 nil) (pre 1 nil)) (pre 2 nil)) as (par nil nil)}" |
|
393 |
||
394 |
(* FIXME |
|
395 |
values 3 "{(a,q). step (par nil nil) a q}" |
|
396 |
*) |
|
397 |
||
33105
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
398 |
inductive tupled_step :: "(proc \<times> nat \<times> proc) \<Rightarrow> bool" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
399 |
where |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
400 |
"tupled_step (pre n p, n, p)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
401 |
"tupled_step (p1, a, q) \<Longrightarrow> tupled_step (or p1 p2, a, q)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
402 |
"tupled_step (p2, a, q) \<Longrightarrow> tupled_step (or p1 p2, a, q)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
403 |
"tupled_step (p1, a, q) \<Longrightarrow> tupled_step (par p1 p2, a, par q p2)" | |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
404 |
"tupled_step (p2, a, q) \<Longrightarrow> tupled_step (par p1 p2, a, par p1 q)" |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
405 |
|
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
406 |
code_pred tupled_step . |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
407 |
thm tupled_step.equation |
1e4146bf841c
added tupled versions of examples for the predicate compiler
bulwahn
parents:
33104
diff
changeset
|
408 |
|
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
409 |
subsection {* divmod *} |
32579 | 410 |
|
411 |
inductive divmod_rel :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> bool" where |
|
412 |
"k < l \<Longrightarrow> divmod_rel k l 0 k" |
|
413 |
| "k \<ge> l \<Longrightarrow> divmod_rel (k - l) l q r \<Longrightarrow> divmod_rel k l (Suc q) r" |
|
414 |
||
415 |
code_pred divmod_rel .. |
|
416 |
||
33111 | 417 |
value [code] "Predicate.the (divmod_rel_1_2 1705 42)" |
32579 | 418 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
419 |
subsection {* Minimum *} |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
420 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
421 |
definition Min |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
422 |
where "Min s r x \<equiv> s x \<and> (\<forall>y. r x y \<longrightarrow> x = y)" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
423 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
424 |
code_pred [inductify] Min . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
425 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
426 |
subsection {* Lexicographic order *} |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
427 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
428 |
code_pred [inductify] lexord . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
429 |
code_pred [inductify, rpred] lexord . |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
430 |
thm lexord.equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
431 |
thm lexord.rpred_equation |
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
432 |
|
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
433 |
inductive less_than_nat :: "nat * nat => bool" |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
434 |
where |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
435 |
"less_than_nat (0, x)" |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
436 |
| "less_than_nat (x, y) ==> less_than_nat (Suc x, Suc y)" |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
437 |
|
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
438 |
code_pred less_than_nat . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
439 |
|
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
440 |
code_pred [depth_limited] less_than_nat . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
441 |
code_pred [rpred] less_than_nat . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
442 |
|
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
443 |
inductive test_lexord :: "nat list * nat list => bool" |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
444 |
where |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
445 |
"lexord less_than_nat (xs, ys) ==> test_lexord (xs, ys)" |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
446 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
447 |
code_pred [rpred] test_lexord . |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
448 |
code_pred [depth_limited] test_lexord . |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
449 |
thm test_lexord.depth_limited_equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
450 |
thm test_lexord.rpred_equation |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
451 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
452 |
values "{x. test_lexord ([1, 2, 3], [1, 2, 5])}" |
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
453 |
values [depth_limit = 5] "{x. test_lexord ([1, 2, 3], [1, 2, 5])}" |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
454 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
455 |
lemmas [code_pred_def] = lexn_conv lex_conv lenlex_conv |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
456 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
457 |
code_pred [inductify] lexn . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
458 |
thm lexn.equation |
33139
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
bulwahn
parents:
33138
diff
changeset
|
459 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
460 |
code_pred [rpred] lexn . |
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
461 |
|
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
462 |
thm lexn.rpred_equation |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
463 |
|
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33145
diff
changeset
|
464 |
code_pred [inductify, show_steps] lenlex . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
465 |
thm lenlex.equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
466 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
467 |
code_pred [inductify, rpred] lenlex . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
468 |
thm lenlex.rpred_equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
469 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
470 |
code_pred [inductify] lists . |
32670 | 471 |
thm lists.equation |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
472 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
473 |
subsection {* AVL Tree *} |
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
474 |
|
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
475 |
datatype 'a tree = ET | MKT 'a "'a tree" "'a tree" nat |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
476 |
fun height :: "'a tree => nat" where |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
477 |
"height ET = 0" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
478 |
| "height (MKT x l r h) = max (height l) (height r) + 1" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
479 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
480 |
consts avl :: "'a tree => bool" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
481 |
primrec |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
482 |
"avl ET = True" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
483 |
"avl (MKT x l r h) = ((height l = height r \<or> height l = 1 + height r \<or> height r = 1+height l) \<and> |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
484 |
h = max (height l) (height r) + 1 \<and> avl l \<and> avl r)" |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
485 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
486 |
code_pred [inductify] avl . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
487 |
thm avl.equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
488 |
|
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
489 |
code_pred [rpred] avl . |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
490 |
thm avl.rpred_equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
491 |
|
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
492 |
fun set_of |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
493 |
where |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
494 |
"set_of ET = {}" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
495 |
| "set_of (MKT n l r h) = insert n (set_of l \<union> set_of r)" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
496 |
|
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33120
diff
changeset
|
497 |
fun is_ord :: "nat tree => bool" |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
498 |
where |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
499 |
"is_ord ET = True" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
500 |
| "is_ord (MKT n l r h) = |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
501 |
((\<forall>n' \<in> set_of l. n' < n) \<and> (\<forall>n' \<in> set_of r. n < n') \<and> is_ord l \<and> is_ord r)" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
502 |
|
33140
83951822bfd0
cleaning the signature of the predicate compiler core; renaming signature and structures to uniform long names
bulwahn
parents:
33139
diff
changeset
|
503 |
code_pred (mode: [1], [1, 2]) [inductify] set_of . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
504 |
thm set_of.equation |
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
505 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
506 |
code_pred [inductify] is_ord . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
507 |
thm is_ord.equation |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
508 |
|
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
509 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
510 |
subsection {* Definitions about Relations *} |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
511 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
512 |
code_pred [inductify] converse . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
513 |
thm converse.equation |
33145 | 514 |
code_pred [inductify] rel_comp . |
515 |
thm rel_comp.equation |
|
516 |
code_pred [inductify] Image . |
|
517 |
thm Image.equation |
|
518 |
(*TODO: *) |
|
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33145
diff
changeset
|
519 |
declare Id_on_def[unfolded UNION_def, code_pred_def] |
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33145
diff
changeset
|
520 |
|
33253 | 521 |
(*code_pred [inductify] Id_on . |
522 |
thm Id_on.equation*) |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
523 |
code_pred [inductify] Domain . |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
524 |
thm Domain.equation |
33145 | 525 |
code_pred [inductify] Range . |
33253 | 526 |
thm Range.equation |
33145 | 527 |
code_pred [inductify] Field . |
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33145
diff
changeset
|
528 |
declare Sigma_def[unfolded UNION_def, code_pred_def] |
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33145
diff
changeset
|
529 |
declare refl_on_def[unfolded UNION_def, code_pred_def] |
33253 | 530 |
(*code_pred [inductify] refl_on . |
531 |
thm refl_on.equation*) |
|
33145 | 532 |
code_pred [inductify] total_on . |
533 |
thm total_on.equation |
|
534 |
code_pred [inductify] antisym . |
|
535 |
thm antisym.equation |
|
536 |
code_pred [inductify] trans . |
|
537 |
thm trans.equation |
|
538 |
code_pred [inductify] single_valued . |
|
539 |
thm single_valued.equation |
|
540 |
code_pred [inductify] inv_image . |
|
541 |
thm inv_image.equation |
|
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
32665
diff
changeset
|
542 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
543 |
subsection {* Inverting list functions *} |
33114
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
bulwahn
parents:
33113
diff
changeset
|
544 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
545 |
code_pred [inductify] length . |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
546 |
code_pred [inductify, rpred] length . |
33114
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
bulwahn
parents:
33113
diff
changeset
|
547 |
thm size_listP.equation |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
548 |
thm size_listP.rpred_equation |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
549 |
|
33143
730a2e8a6ec6
modularized the compilation in the predicate compiler
bulwahn
parents:
33141
diff
changeset
|
550 |
values [random] 20 "{xs. size_listP (xs::nat list) (5::nat)}" |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
551 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
552 |
code_pred [inductify] concat . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
553 |
code_pred [inductify] hd . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
554 |
code_pred [inductify] tl . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
555 |
code_pred [inductify] last . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
556 |
code_pred [inductify] butlast . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
557 |
code_pred [inductify] take . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
558 |
code_pred [inductify] drop . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
559 |
code_pred [inductify] zip . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
560 |
code_pred [inductify] upt . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
561 |
code_pred [inductify] remdups . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
562 |
code_pred [inductify] remove1 . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
563 |
code_pred [inductify] removeAll . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
564 |
code_pred [inductify] distinct . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
565 |
code_pred [inductify] replicate . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
566 |
code_pred [inductify] splice . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
567 |
code_pred [inductify] List.rev . |
33129
3085da75ed54
changed import_intros to handle parameters differently; changed handling of higher-order function compilation; reverted MicroJava change; tuned
bulwahn
parents:
33128
diff
changeset
|
568 |
code_pred [inductify] map . |
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
569 |
code_pred [inductify] foldr . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
570 |
code_pred [inductify] foldl . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
571 |
code_pred [inductify] filter . |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
572 |
code_pred [inductify, rpred] filter . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
573 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
574 |
subsection {* Context Free Grammar *} |
32669
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
575 |
|
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
576 |
datatype alphabet = a | b |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
577 |
|
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
578 |
inductive_set S\<^isub>1 and A\<^isub>1 and B\<^isub>1 where |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
579 |
"[] \<in> S\<^isub>1" |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
580 |
| "w \<in> A\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1" |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
581 |
| "w \<in> B\<^isub>1 \<Longrightarrow> a # w \<in> S\<^isub>1" |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
582 |
| "w \<in> S\<^isub>1 \<Longrightarrow> a # w \<in> A\<^isub>1" |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
583 |
| "w \<in> S\<^isub>1 \<Longrightarrow> b # w \<in> S\<^isub>1" |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
584 |
| "\<lbrakk>v \<in> B\<^isub>1; v \<in> B\<^isub>1\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>1" |
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
585 |
|
33140
83951822bfd0
cleaning the signature of the predicate compiler core; renaming signature and structures to uniform long names
bulwahn
parents:
33139
diff
changeset
|
586 |
code_pred [inductify] S\<^isub>1p . |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
587 |
code_pred [inductify, rpred] S\<^isub>1p . |
32669
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
588 |
thm S\<^isub>1p.equation |
33141
89b23fad5e02
modifying the depth-limited compilation to be sound, but now throws an error undefined in case of hitting the depth limit in an negative context; cleaning up the examples
bulwahn
parents:
33140
diff
changeset
|
589 |
thm S\<^isub>1p.rpred_equation |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
590 |
|
33143
730a2e8a6ec6
modularized the compilation in the predicate compiler
bulwahn
parents:
33141
diff
changeset
|
591 |
values [random] 5 "{x. S\<^isub>1p x}" |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
592 |
|
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
593 |
inductive_set S\<^isub>2 and A\<^isub>2 and B\<^isub>2 where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
594 |
"[] \<in> S\<^isub>2" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
595 |
| "w \<in> A\<^isub>2 \<Longrightarrow> b # w \<in> S\<^isub>2" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
596 |
| "w \<in> B\<^isub>2 \<Longrightarrow> a # w \<in> S\<^isub>2" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
597 |
| "w \<in> S\<^isub>2 \<Longrightarrow> a # w \<in> A\<^isub>2" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
598 |
| "w \<in> S\<^isub>2 \<Longrightarrow> b # w \<in> B\<^isub>2" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
599 |
| "\<lbrakk>v \<in> B\<^isub>2; v \<in> B\<^isub>2\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>2" |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
600 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
601 |
code_pred [inductify, rpred] S\<^isub>2 . |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
602 |
thm S\<^isub>2.rpred_equation |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
603 |
thm A\<^isub>2.rpred_equation |
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
604 |
thm B\<^isub>2.rpred_equation |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
605 |
|
33143
730a2e8a6ec6
modularized the compilation in the predicate compiler
bulwahn
parents:
33141
diff
changeset
|
606 |
values [random] 10 "{x. S\<^isub>2 x}" |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
607 |
|
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
608 |
inductive_set S\<^isub>3 and A\<^isub>3 and B\<^isub>3 where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
609 |
"[] \<in> S\<^isub>3" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
610 |
| "w \<in> A\<^isub>3 \<Longrightarrow> b # w \<in> S\<^isub>3" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
611 |
| "w \<in> B\<^isub>3 \<Longrightarrow> a # w \<in> S\<^isub>3" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
612 |
| "w \<in> S\<^isub>3 \<Longrightarrow> a # w \<in> A\<^isub>3" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
613 |
| "w \<in> S\<^isub>3 \<Longrightarrow> b # w \<in> B\<^isub>3" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
614 |
| "\<lbrakk>v \<in> B\<^isub>3; w \<in> B\<^isub>3\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>3" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
615 |
|
33124
5378e61add1a
continued cleaning up; moved tuple expanding to core
bulwahn
parents:
33123
diff
changeset
|
616 |
code_pred [inductify] S\<^isub>3 . |
33138
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
617 |
thm S\<^isub>3.equation |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
618 |
|
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
619 |
values 10 "{x. S\<^isub>3 x}" |
e2e23987c59a
reinvestigating the compilation of the random computation in the predicate compiler
bulwahn
parents:
33137
diff
changeset
|
620 |
|
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
621 |
inductive_set S\<^isub>4 and A\<^isub>4 and B\<^isub>4 where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
622 |
"[] \<in> S\<^isub>4" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
623 |
| "w \<in> A\<^isub>4 \<Longrightarrow> b # w \<in> S\<^isub>4" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
624 |
| "w \<in> B\<^isub>4 \<Longrightarrow> a # w \<in> S\<^isub>4" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
625 |
| "w \<in> S\<^isub>4 \<Longrightarrow> a # w \<in> A\<^isub>4" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
626 |
| "\<lbrakk>v \<in> A\<^isub>4; w \<in> A\<^isub>4\<rbrakk> \<Longrightarrow> b # v @ w \<in> A\<^isub>4" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
627 |
| "w \<in> S\<^isub>4 \<Longrightarrow> b # w \<in> B\<^isub>4" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
628 |
| "\<lbrakk>v \<in> B\<^isub>4; w \<in> B\<^isub>4\<rbrakk> \<Longrightarrow> a # v @ w \<in> B\<^isub>4" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
629 |
|
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
630 |
subsection {* Lambda *} |
32669
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
631 |
|
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
632 |
datatype type = |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
633 |
Atom nat |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
634 |
| Fun type type (infixr "\<Rightarrow>" 200) |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
635 |
|
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
636 |
datatype dB = |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
637 |
Var nat |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
638 |
| App dB dB (infixl "\<degree>" 200) |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
639 |
| Abs type dB |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
640 |
|
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
641 |
primrec |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
642 |
nth_el :: "'a list \<Rightarrow> nat \<Rightarrow> 'a option" ("_\<langle>_\<rangle>" [90, 0] 91) |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
643 |
where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
644 |
"[]\<langle>i\<rangle> = None" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
645 |
| "(x # xs)\<langle>i\<rangle> = (case i of 0 \<Rightarrow> Some x | Suc j \<Rightarrow> xs \<langle>j\<rangle>)" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
646 |
|
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
647 |
inductive nth_el' :: "'a list \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> bool" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
648 |
where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
649 |
"nth_el' (x # xs) 0 x" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
650 |
| "nth_el' xs i y \<Longrightarrow> nth_el' (x # xs) (Suc i) y" |
33128 | 651 |
|
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
652 |
inductive typing :: "type list \<Rightarrow> dB \<Rightarrow> type \<Rightarrow> bool" ("_ \<turnstile> _ : _" [50, 50, 50] 50) |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
653 |
where |
33128 | 654 |
Var [intro!]: "nth_el' env x T \<Longrightarrow> env \<turnstile> Var x : T" |
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
655 |
| Abs [intro!]: "T # env \<turnstile> t : U \<Longrightarrow> env \<turnstile> Abs T t : (T \<Rightarrow> U)" |
33250
5c2af18a3237
including the predicate compiler in HOL-Main; added RandomPredicate monad to Quickcheck
bulwahn
parents:
33147
diff
changeset
|
656 |
| App [intro!]: "env \<turnstile> s : T \<Rightarrow> U \<Longrightarrow> env \<turnstile> t : T \<Longrightarrow> env \<turnstile> (s \<degree> t) : U" |
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
657 |
|
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
658 |
primrec |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
659 |
lift :: "[dB, nat] => dB" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
660 |
where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
661 |
"lift (Var i) k = (if i < k then Var i else Var (i + 1))" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
662 |
| "lift (s \<degree> t) k = lift s k \<degree> lift t k" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
663 |
| "lift (Abs T s) k = Abs T (lift s (k + 1))" |
32669
462b1dd67a58
added context free grammar example; removed dead code; adapted to work without quick and dirty mode; fixed typo
bulwahn
parents:
32668
diff
changeset
|
664 |
|
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
665 |
primrec |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
666 |
subst :: "[dB, dB, nat] => dB" ("_[_'/_]" [300, 0, 0] 300) |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
667 |
where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
668 |
subst_Var: "(Var i)[s/k] = |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
669 |
(if k < i then Var (i - 1) else if i = k then s else Var i)" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
670 |
| subst_App: "(t \<degree> u)[s/k] = t[s/k] \<degree> u[s/k]" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
671 |
| subst_Abs: "(Abs T t)[s/k] = Abs T (t[lift s 0 / k+1])" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
672 |
|
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
673 |
inductive beta :: "[dB, dB] => bool" (infixl "\<rightarrow>\<^sub>\<beta>" 50) |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
674 |
where |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
675 |
beta [simp, intro!]: "Abs T s \<degree> t \<rightarrow>\<^sub>\<beta> s[t/0]" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
676 |
| appL [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> s \<degree> u \<rightarrow>\<^sub>\<beta> t \<degree> u" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
677 |
| appR [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> u \<degree> s \<rightarrow>\<^sub>\<beta> u \<degree> t" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
678 |
| abs [simp, intro!]: "s \<rightarrow>\<^sub>\<beta> t ==> Abs T s \<rightarrow>\<^sub>\<beta> Abs T t" |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32670
diff
changeset
|
679 |
|
30374
7311a1546d85
added predicate compiler, as formally checked prototype, not as user package
haftmann
parents:
diff
changeset
|
680 |
end |