author | bulwahn |
Sun, 01 Aug 2010 10:15:43 +0200 | |
changeset 38117 | 5ae05823cfd9 |
parent 38116 | 823b1e8bc090 |
child 38727 | c7f5f0b7dc7f |
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 |
38117 | 2 |
imports 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 |
|
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
5 |
section {* Example append *} |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
6 |
|
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
7 |
inductive append |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
8 |
where |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
9 |
"append [] ys ys" |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
10 |
| "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
|
11 |
|
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
12 |
code_pred append . |
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
13 |
|
38116
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
14 |
values 3 "{(x, y, z). append x y z}" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
15 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
16 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
17 |
section {* Example queens *} |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
18 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
19 |
inductive nodiag :: "int => int => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
20 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
21 |
"nodiag B D []" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
22 |
| "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
|
23 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
24 |
text {* |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
25 |
qdelete(A, [A|L], L). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
26 |
qdelete(X, [A|Z], [A|R]) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
27 |
qdelete(X, Z, R). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
28 |
*} |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
29 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
30 |
inductive qdelete :: "int => int list => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
31 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
32 |
"qdelete A (A # L) L" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
33 |
| "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
|
34 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
35 |
text {* |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
36 |
qperm([], []). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
37 |
qperm([X|Y], K) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
38 |
qdelete(U, [X|Y], Z), |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
39 |
K = [U|V], |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
40 |
qperm(Z, V). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
41 |
*} |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
42 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
43 |
inductive qperm :: "int list => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
44 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
45 |
"qperm [] []" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
46 |
| "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
|
47 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
48 |
text {* |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
49 |
safe([]). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
50 |
safe([N|L]) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
51 |
nodiag(N, 1, L), |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
52 |
safe(L). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
53 |
*} |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
54 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
55 |
inductive safe :: "int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
56 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
57 |
"safe []" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
58 |
| "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
|
59 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
60 |
text {* |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
61 |
queen(Data, Out) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
62 |
qperm(Data, Out), |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
63 |
safe(Out) |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
64 |
*} |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
65 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
66 |
inductive queen :: "int list => int list => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
67 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
68 |
"qperm Data Out ==> safe Out ==> queen Data Out" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
69 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
70 |
inductive queen_9 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
71 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
72 |
"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
|
73 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
74 |
code_pred queen_9 . |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
75 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
76 |
values 150 "{ys. queen_9 ys}" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
77 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
78 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
79 |
section {* Example symbolic derivation *} |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
80 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
81 |
hide_const Plus Pow |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
82 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
83 |
datatype expr = Log expr | Mult expr expr | Div expr expr | x | Num int | Plus expr expr |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
84 |
| 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
|
85 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
86 |
text {* |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
87 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
88 |
d(U + V, X, DU + DV) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
89 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
90 |
d(U, X, DU), |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
91 |
d(V, X, DV). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
92 |
d(U - V, X, DU - DV) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
93 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
94 |
d(U, X, DU), |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
95 |
d(V, X, DV). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
96 |
d(U * V, X, DU * V + U * DV) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
97 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
98 |
d(U, X, DU), |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
99 |
d(V, X, DV). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
100 |
d(U / V, X, (DU * V - U * DV) / ^(V, 2)) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
101 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
102 |
d(U, X, DU), |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
103 |
d(V, X, DV). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
104 |
d(^(U, N), X, DU * num(N) * ^(U, N1)) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
105 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
106 |
N1 is N - 1, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
107 |
d(U, X, DU). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
108 |
d(-U, X, -DU) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
109 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
110 |
d(U, X, DU). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
111 |
d(exp(U), X, exp(U) * DU) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
112 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
113 |
d(U, X, DU). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
114 |
d(log(U), X, DU / U) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
115 |
cut, |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
116 |
d(U, X, DU). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
117 |
d(x, X, num(1)) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
118 |
cut. |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
119 |
d(num(_), _, num(0)). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
120 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
121 |
*} |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
122 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
123 |
inductive d :: "expr => expr => expr => bool" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
124 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
125 |
"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
|
126 |
| "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
|
127 |
| "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
|
128 |
| "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
|
129 |
| "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
|
130 |
| "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
|
131 |
| "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
|
132 |
| "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
|
133 |
| "d x X (Num 1)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
134 |
| "d (Num n) X (Num 0)" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
135 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
136 |
text {* |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
137 |
ops8(E) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
138 |
d((x + num(1)) * ((^(x, 2) + num(2)) * (^(x, 3) + num(3))), x, E). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
139 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
140 |
divide10(E) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
141 |
d(((((((((x / x) / x) / x) / x) / x) / x) / x) / x) / x, x, E). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
142 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
143 |
log10(E) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
144 |
d(log(log(log(log(log(log(log(log(log(log(x)))))))))), x, E). |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
145 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
146 |
times10(E) :- |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
147 |
d(((((((((x * x) * x) * x) * x) * x) * x) * x) * x) * x, x, E) |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
148 |
*} |
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 ops8 :: "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 (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
|
153 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
154 |
inductive divide10 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
155 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
156 |
"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
|
157 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
158 |
inductive log10 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
159 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
160 |
"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
|
161 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
162 |
inductive times10 |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
163 |
where |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
164 |
"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
|
165 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
166 |
code_pred ops8 . |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
167 |
code_pred divide10 . |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
168 |
code_pred log10 . |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
169 |
code_pred times10 . |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
170 |
|
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
171 |
values "{e. ops8 e}" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
172 |
values "{e. divide10 e}" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
173 |
values "{e. log10 e}" |
823b1e8bc090
adding queens and symbolic derivation example for prolog code generation
bulwahn
parents:
38080
diff
changeset
|
174 |
values "{e. times10 e}" |
38075 | 175 |
|
38074
31174744b9a2
adding example file for prolog code generation; adding prolog code generation example to IsaMakefile
bulwahn
parents:
diff
changeset
|
176 |
end |