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