| author | wenzelm | 
| Thu, 27 Mar 2008 16:24:10 +0100 | |
| changeset 26437 | 5906619c8c6b | 
| parent 26020 | ffe1a032d24b | 
| child 28227 | 77221ee0f7b9 | 
| permissions | -rw-r--r-- | 
| 23268 | 1  | 
(* ID: $Id$  | 
2  | 
Author: Florian Haftmann, TU Muenchen  | 
|
3  | 
*)  | 
|
4  | 
||
5  | 
header {* Small examples for evaluation mechanisms *}
 | 
|
6  | 
||
7  | 
theory Eval_Examples  | 
|
| 24659 | 8  | 
imports Eval "~~/src/HOL/Real/Rational"  | 
| 23268 | 9  | 
begin  | 
10  | 
||
| 25099 | 11  | 
text {* evaluation oracle *}
 | 
12  | 
||
13  | 
lemma "True \<or> False" by eval  | 
|
14  | 
lemma "\<not> (Suc 0 = Suc 1)" by eval  | 
|
15  | 
lemma "[] = ([]\<Colon> int list)" by eval  | 
|
16  | 
lemma "[()] = [()]" by eval  | 
|
17  | 
lemma "fst ([]::nat list, Suc 0) = []" by eval  | 
|
18  | 
||
| 24292 | 19  | 
text {* SML evaluation oracle *}
 | 
20  | 
||
21  | 
lemma "True \<or> False" by evaluation  | 
|
22  | 
lemma "\<not> (Suc 0 = Suc 1)" by evaluation  | 
|
23  | 
lemma "[] = ([]\<Colon> int list)" by evaluation  | 
|
24  | 
lemma "[()] = [()]" by evaluation  | 
|
25  | 
lemma "fst ([]::nat list, Suc 0) = []" by evaluation  | 
|
26  | 
||
| 25099 | 27  | 
text {* normalization *}
 | 
| 23268 | 28  | 
|
| 25099 | 29  | 
lemma "True \<or> False" by normalization  | 
30  | 
lemma "\<not> (Suc 0 = Suc 1)" by normalization  | 
|
31  | 
lemma "[] = ([]\<Colon> int list)" by normalization  | 
|
32  | 
lemma "[()] = [()]" by normalization  | 
|
33  | 
lemma "fst ([]::nat list, Suc 0) = []" by normalization  | 
|
| 23268 | 34  | 
|
35  | 
text {* term evaluation *}
 | 
|
36  | 
||
| 24587 | 37  | 
value "(Suc 2 + 1) * 4"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
38  | 
value (code) "(Suc 2 + 1) * 4"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
39  | 
value (SML) "(Suc 2 + 1) * 4"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
40  | 
value ("normal_form") "(Suc 2 + 1) * 4"
 | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
41  | 
|
| 24587 | 42  | 
value "(Suc 2 + Suc 0) * Suc 3"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
43  | 
value (code) "(Suc 2 + Suc 0) * Suc 3"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
44  | 
value (SML) "(Suc 2 + Suc 0) * Suc 3"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
45  | 
value ("normal_form") "(Suc 2 + Suc 0) * Suc 3"
 | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
46  | 
|
| 24587 | 47  | 
value "nat 100"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
48  | 
value (code) "nat 100"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
49  | 
value (SML) "nat 100"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
50  | 
value ("normal_form") "nat 100"
 | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
51  | 
|
| 24587 | 52  | 
value "(10\<Colon>int) \<le> 12"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
53  | 
value (code) "(10\<Colon>int) \<le> 12"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
54  | 
value (SML) "(10\<Colon>int) \<le> 12"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
55  | 
value ("normal_form") "(10\<Colon>int) \<le> 12"
 | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
56  | 
|
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
57  | 
value "max (2::int) 4"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
58  | 
value (code) "max (2::int) 4"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
59  | 
value (SML) "max (2::int) 4"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
60  | 
value ("normal_form") "max (2::int) 4"
 | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
61  | 
|
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
62  | 
value "of_int 2 / of_int 4 * (1::rat)"  | 
| 26020 | 63  | 
value (code) "of_int 2 / of_int 4 * (1::rat)"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
64  | 
value (SML) "of_int 2 / of_int 4 * (1::rat)"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
65  | 
value ("normal_form") "of_int 2 / of_int 4 * (1::rat)"
 | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
66  | 
|
| 24587 | 67  | 
value "[]::nat list"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
68  | 
value (code) "[]::nat list"  | 
| 25099 | 69  | 
value (SML) "[]::nat list"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
70  | 
value ("normal_form") "[]::nat list"
 | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
71  | 
|
| 24587 | 72  | 
value "[(nat 100, ())]"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
73  | 
value (code) "[(nat 100, ())]"  | 
| 25099 | 74  | 
value (SML) "[(nat 100, ())]"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
75  | 
value ("normal_form") "[(nat 100, ())]"
 | 
| 24659 | 76  | 
|
| 23268 | 77  | 
|
78  | 
text {* a fancy datatype *}
 | 
|
79  | 
||
80  | 
datatype ('a, 'b) bair =
 | 
|
81  | 
Bair "'a\<Colon>order" 'b  | 
|
82  | 
  | Shift "('a, 'b) cair"
 | 
|
83  | 
| Dummy unit  | 
|
84  | 
and ('a, 'b) cair =
 | 
|
85  | 
Cair 'a 'b  | 
|
86  | 
||
| 24587 | 87  | 
value "Shift (Cair (4::nat) [Suc 0])"  | 
| 
24835
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
88  | 
value (code) "Shift (Cair (4::nat) [Suc 0])"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
89  | 
value (SML) "Shift (Cair (4::nat) [Suc 0])"  | 
| 
 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 
haftmann 
parents: 
24659 
diff
changeset
 | 
90  | 
value ("normal_form") "Shift (Cair (4::nat) [Suc 0])"
 | 
| 23268 | 91  | 
|
92  | 
end  |