author | wenzelm |
Wed, 28 Dec 2022 12:30:18 +0100 | |
changeset 76798 | 69d8d16c5612 |
parent 66453 | cc19f7ca2ed6 |
permissions | -rw-r--r-- |
38074
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
1 |
theory Code_Prolog_Examples |
66453
cc19f7ca2ed6
session-qualified theory imports: isabelle imports -U -i -d '~~/src/Benchmarks' -a;
wenzelm
parents:
63167
diff
changeset
|
2 |
imports "HOL-Library.Code_Prolog" |
38074
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
3 |
begin |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
4 |
|
63167 | 5 |
section \<open>Example append\<close> |
38074
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
6 |
|
38792
970508a5119f
added support for yet another prolog system (yap); generate has only one option ensure_groundness; added one example of yap invocation in example theory
bulwahn
parents:
38791
diff
changeset
|
7 |
|
38074
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
8 |
inductive append |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
9 |
where |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
10 |
"append [] ys ys" |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
11 |
| "append xs ys zs ==> append (x # xs) ys (x # zs)" |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
12 |
|
63167 | 13 |
setup \<open>Code_Prolog.map_code_options (K |
38963 | 14 |
{ensure_groundness = false, |
39800 | 15 |
limit_globally = NONE, |
38963 | 16 |
limited_types = [], |
17 |
limited_predicates = [], |
|
18 |
replacing = [], |
|
63167 | 19 |
manual_reorder = []})\<close> |
38792
970508a5119f
added support for yet another prolog system (yap); generate has only one option ensure_groundness; added one example of yap invocation in example theory
bulwahn
parents:
38791
diff
changeset
|
20 |
|
55447 | 21 |
values_prolog "{(x, y, z). append x y z}" |
38792
970508a5119f
added support for yet another prolog system (yap); generate has only one option ensure_groundness; added one example of yap invocation in example theory
bulwahn
parents:
38791
diff
changeset
|
22 |
|
55447 | 23 |
values_prolog 4 "{(z, x, y). append x y ((1::nat) # (2 # (3 # z)))}" |
39466
f3c5da707f30
adding values to show and ensure that values works with complex terms and restores numerals on natural numbers
bulwahn
parents:
39463
diff
changeset
|
24 |
|
55447 | 25 |
values_prolog 3 "{(x, y, z). append x y z}" |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
26 |
|
63167 | 27 |
setup \<open>Code_Prolog.map_code_options (K |
38949 | 28 |
{ensure_groundness = false, |
39800 | 29 |
limit_globally = NONE, |
38963 | 30 |
limited_types = [], |
31 |
limited_predicates = [], |
|
32 |
replacing = [], |
|
63167 | 33 |
manual_reorder = []})\<close> |
38792
970508a5119f
added support for yet another prolog system (yap); generate has only one option ensure_groundness; added one example of yap invocation in example theory
bulwahn
parents:
38791
diff
changeset
|
34 |
|
55447 | 35 |
values_prolog "{(x, y, z). append x y z}" |
38792
970508a5119f
added support for yet another prolog system (yap); generate has only one option ensure_groundness; added one example of yap invocation in example theory
bulwahn
parents:
38791
diff
changeset
|
36 |
|
63167 | 37 |
setup \<open>Code_Prolog.map_code_options (K |
38949 | 38 |
{ensure_groundness = false, |
39800 | 39 |
limit_globally = NONE, |
38963 | 40 |
limited_types = [], |
41 |
limited_predicates = [], |
|
42 |
replacing = [], |
|
63167 | 43 |
manual_reorder = []})\<close> |
38792
970508a5119f
added support for yet another prolog system (yap); generate has only one option ensure_groundness; added one example of yap invocation in example theory
bulwahn
parents:
38791
diff
changeset
|
44 |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
45 |
|
63167 | 46 |
section \<open>Example queens\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
47 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
48 |
inductive nodiag :: "int => int => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
49 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
50 |
"nodiag B D []" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
51 |
| "D \<noteq> N - B ==> D \<noteq> B - N ==> Da = D + 1 ==> nodiag B Da L ==> nodiag B D (N # L)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
52 |
|
63167 | 53 |
text \<open> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
54 |
qdelete(A, [A|L], L). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
55 |
qdelete(X, [A|Z], [A|R]) :- |
41457 | 56 |
qdelete(X, Z, R). |
63167 | 57 |
\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
58 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
59 |
inductive qdelete :: "int => int list => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
60 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
61 |
"qdelete A (A # L) L" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
62 |
| "qdelete X Z R ==> qdelete X (A # Z) (A # R)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
63 |
|
63167 | 64 |
text \<open> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
65 |
qperm([], []). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
66 |
qperm([X|Y], K) :- |
41457 | 67 |
qdelete(U, [X|Y], Z), |
68 |
K = [U|V], |
|
69 |
qperm(Z, V). |
|
63167 | 70 |
\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
71 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
72 |
inductive qperm :: "int list => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
73 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
74 |
"qperm [] []" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
75 |
| "qdelete U (X # Y) Z ==> qperm Z V ==> qperm (X # Y) (U # V)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
76 |
|
63167 | 77 |
text \<open> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
78 |
safe([]). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
79 |
safe([N|L]) :- |
41457 | 80 |
nodiag(N, 1, L), |
81 |
safe(L). |
|
63167 | 82 |
\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
83 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
84 |
inductive safe :: "int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
85 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
86 |
"safe []" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
87 |
| "nodiag N 1 L ==> safe L ==> safe (N # L)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
88 |
|
63167 | 89 |
text \<open> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
90 |
queen(Data, Out) :- |
41457 | 91 |
qperm(Data, Out), |
92 |
safe(Out) |
|
63167 | 93 |
\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
94 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
95 |
inductive queen :: "int list => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
96 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
97 |
"qperm Data Out ==> safe Out ==> queen Data Out" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
98 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
99 |
inductive queen_9 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
100 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
101 |
"queen [1,2,3,4,5,6,7,8,9] ys ==> queen_9 ys" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
102 |
|
55447 | 103 |
values_prolog 10 "{ys. queen_9 ys}" |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
104 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
105 |
|
63167 | 106 |
section \<open>Example symbolic derivation\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
107 |
|
40271 | 108 |
hide_const Pow |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
109 |
|
58310 | 110 |
datatype expr = Log expr | Mult expr expr | Div expr expr | x | Num int | Plus expr expr |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
111 |
| Minus expr expr | Uminus expr | Pow expr int | Exp expr |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
112 |
|
63167 | 113 |
text \<open> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
114 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
115 |
d(U + V, X, DU + DV) :- |
41457 | 116 |
cut, |
117 |
d(U, X, DU), |
|
118 |
d(V, X, DV). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
119 |
d(U - V, X, DU - DV) :- |
41457 | 120 |
cut, |
121 |
d(U, X, DU), |
|
122 |
d(V, X, DV). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
123 |
d(U * V, X, DU * V + U * DV) :- |
41457 | 124 |
cut, |
125 |
d(U, X, DU), |
|
126 |
d(V, X, DV). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
127 |
d(U / V, X, (DU * V - U * DV) / ^(V, 2)) :- |
41457 | 128 |
cut, |
129 |
d(U, X, DU), |
|
130 |
d(V, X, DV). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
131 |
d(^(U, N), X, DU * num(N) * ^(U, N1)) :- |
41457 | 132 |
cut, |
133 |
N1 is N - 1, |
|
134 |
d(U, X, DU). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
135 |
d(-U, X, -DU) :- |
41457 | 136 |
cut, |
137 |
d(U, X, DU). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
138 |
d(exp(U), X, exp(U) * DU) :- |
41457 | 139 |
cut, |
140 |
d(U, X, DU). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
141 |
d(log(U), X, DU / U) :- |
41457 | 142 |
cut, |
143 |
d(U, X, DU). |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
144 |
d(x, X, num(1)) :- |
41457 | 145 |
cut. |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
146 |
d(num(_), _, num(0)). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
147 |
|
63167 | 148 |
\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
149 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
150 |
inductive d :: "expr => expr => expr => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
151 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
152 |
"d U X DU ==> d V X DV ==> d (Plus U V) X (Plus DU DV)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
153 |
| "d U X DU ==> d V X DV ==> d (Minus U V) X (Minus DU DV)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
154 |
| "d U X DU ==> d V X DV ==> d (Mult U V) X (Plus (Mult DU V) (Mult U DV))" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
155 |
| "d U X DU ==> d V X DV ==> d (Div U V) X (Div (Minus (Mult DU V) (Mult U DV)) (Pow V 2))" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
156 |
| "d U X DU ==> N1 = N - 1 ==> d (Pow U N) X (Mult DU (Mult (Num N) (Pow U N1)))" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
157 |
| "d U X DU ==> d (Uminus U) X (Uminus DU)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
158 |
| "d U X DU ==> d (Exp U) X (Mult (Exp U) DU)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
159 |
| "d U X DU ==> d (Log U) X (Div DU U)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
160 |
| "d x X (Num 1)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
161 |
| "d (Num n) X (Num 0)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
162 |
|
63167 | 163 |
text \<open> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
164 |
ops8(E) :- |
41457 | 165 |
d((x + num(1)) * ((^(x, 2) + num(2)) * (^(x, 3) + num(3))), x, E). |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
166 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
167 |
divide10(E) :- |
41457 | 168 |
d(((((((((x / x) / x) / x) / x) / x) / x) / x) / x) / x, x, E). |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
169 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
170 |
log10(E) :- |
41457 | 171 |
d(log(log(log(log(log(log(log(log(log(log(x)))))))))), x, E). |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
172 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
173 |
times10(E) :- |
41457 | 174 |
d(((((((((x * x) * x) * x) * x) * x) * x) * x) * x) * x, x, E) |
63167 | 175 |
\<close> |
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
176 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
177 |
inductive ops8 :: "expr => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
178 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
179 |
"d (Mult (Plus x (Num 1)) (Mult (Plus (Pow x 2) (Num 2)) (Plus (Pow x 3) (Num 3)))) x e ==> ops8 e" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
180 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
181 |
inductive divide10 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
182 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
183 |
"d (Div (Div (Div (Div (Div (Div (Div (Div (Div x x) x) x) x) x) x) x) x) x) x e ==> divide10 e" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
184 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
185 |
inductive log10 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
186 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
187 |
"d (Log (Log (Log (Log (Log (Log (Log (Log (Log (Log x)))))))))) x e ==> log10 e" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
188 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
189 |
inductive times10 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
190 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
191 |
"d (Mult (Mult (Mult (Mult (Mult (Mult (Mult (Mult (Mult x x) x) x) x) x) x) x) x) x) x e ==> times10 e" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
192 |
|
55447 | 193 |
values_prolog "{e. ops8 e}" |
194 |
values_prolog "{e. divide10 e}" |
|
195 |
values_prolog "{e. log10 e}" |
|
196 |
values_prolog "{e. times10 e}" |
|
38075 | 197 |
|
63167 | 198 |
section \<open>Example negation\<close> |
38727
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
199 |
|
58310 | 200 |
datatype abc = A | B | C |
38727
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
201 |
|
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
202 |
inductive notB :: "abc => bool" |
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
203 |
where |
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
204 |
"y \<noteq> B \<Longrightarrow> notB y" |
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
205 |
|
63167 | 206 |
setup \<open>Code_Prolog.map_code_options (K |
38963 | 207 |
{ensure_groundness = true, |
39800 | 208 |
limit_globally = NONE, |
38963 | 209 |
limited_types = [], |
210 |
limited_predicates = [], |
|
211 |
replacing = [], |
|
63167 | 212 |
manual_reorder = []})\<close> |
38727
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
213 |
|
55447 | 214 |
values_prolog 2 "{y. notB y}" |
38727
c7f5f0b7dc7f
adding very basic transformation to ensure groundness before negations
bulwahn
parents:
38117
diff
changeset
|
215 |
|
38728
182b180e9804
improving ensure_groundness in prolog generation; added further example
bulwahn
parents:
38727
diff
changeset
|
216 |
inductive notAB :: "abc * abc \<Rightarrow> bool" |
182b180e9804
improving ensure_groundness in prolog generation; added further example
bulwahn
parents:
38727
diff
changeset
|
217 |
where |
182b180e9804
improving ensure_groundness in prolog generation; added further example
bulwahn
parents:
38727
diff
changeset
|
218 |
"y \<noteq> A \<Longrightarrow> z \<noteq> B \<Longrightarrow> notAB (y, z)" |
182b180e9804
improving ensure_groundness in prolog generation; added further example
bulwahn
parents:
38727
diff
changeset
|
219 |
|
55447 | 220 |
values_prolog 5 "{y. notAB y}" |
38728
182b180e9804
improving ensure_groundness in prolog generation; added further example
bulwahn
parents:
38727
diff
changeset
|
221 |
|
63167 | 222 |
section \<open>Example prolog conform variable names\<close> |
38735 | 223 |
|
224 |
inductive equals :: "abc => abc => bool" |
|
225 |
where |
|
226 |
"equals y' y'" |
|
38791 | 227 |
|
55447 | 228 |
values_prolog 1 "{(y, z). equals y z}" |
38735 | 229 |
|
38074
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
230 |
end |