| author | wenzelm | 
| Sat, 20 Aug 2011 20:24:12 +0200 | |
| changeset 44335 | 156be0e43336 | 
| parent 44022 | 2d633b795d4a | 
| child 45170 | 7dd207fe7b6e | 
| 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 | |
| 40760 | 12 | lemma "Suc 0 \<noteq> Suc 1" by eval | 
| 13 | lemma "[] = ([] :: int list)" by eval | |
| 25099 | 14 | lemma "[()] = [()]" by eval | 
| 40760 | 15 | lemma "fst ([] :: nat list, Suc 0) = []" by eval | 
| 25099 | 16 | |
| 24292 | 17 | text {* SML evaluation oracle *}
 | 
| 18 | ||
| 19 | lemma "True \<or> False" by evaluation | |
| 40760 | 20 | lemma "Suc 0 \<noteq> Suc 1" by evaluation | 
| 21 | lemma "[] = ([] :: int list)" by evaluation | |
| 24292 | 22 | lemma "[()] = [()]" by evaluation | 
| 40760 | 23 | lemma "fst ([] :: nat list, Suc 0) = []" by evaluation | 
| 24292 | 24 | |
| 25099 | 25 | text {* normalization *}
 | 
| 23268 | 26 | |
| 25099 | 27 | lemma "True \<or> False" by normalization | 
| 40760 | 28 | lemma "Suc 0 \<noteq> Suc 1" by normalization | 
| 29 | lemma "[] = ([] :: int list)" by normalization | |
| 25099 | 30 | lemma "[()] = [()]" by normalization | 
| 40760 | 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 [nbe] "(Suc 2 + 1) * 4" | |
| 24835 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 38 | |
| 24587 | 39 | value "(Suc 2 + Suc 0) * Suc 3" | 
| 28227 | 40 | value [code] "(Suc 2 + Suc 0) * Suc 3" | 
| 41 | value [nbe] "(Suc 2 + Suc 0) * Suc 3" | |
| 24835 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 42 | |
| 24587 | 43 | value "nat 100" | 
| 28227 | 44 | value [code] "nat 100" | 
| 45 | value [nbe] "nat 100" | |
| 24835 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 46 | |
| 40760 | 47 | value "(10::int) \<le> 12" | 
| 48 | value [code] "(10::int) \<le> 12" | |
| 49 | value [nbe] "(10::int) \<le> 12" | |
| 24835 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 50 | |
| 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 51 | value "max (2::int) 4" | 
| 28227 | 52 | value [code] "max (2::int) 4" | 
| 53 | value [nbe] "max (2::int) 4" | |
| 24835 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 54 | |
| 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 55 | value "of_int 2 / of_int 4 * (1::rat)" | 
| 28227 | 56 | value [code] "of_int 2 / of_int 4 * (1::rat)" | 
| 57 | value [nbe] "of_int 2 / of_int 4 * (1::rat)" | |
| 24835 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 58 | |
| 40760 | 59 | value "[] :: nat list" | 
| 60 | value [code] "[] :: nat list" | |
| 61 | value [nbe] "[] :: nat list" | |
| 24835 
8c26128f8997
clarified relationship of code generator conversions and evaluations
 haftmann parents: 
24659diff
changeset | 62 | |
| 24587 | 63 | value "[(nat 100, ())]" | 
| 28227 | 64 | value [code] "[(nat 100, ())]" | 
| 65 | value [nbe] "[(nat 100, ())]" | |
| 24659 | 66 | |
| 23268 | 67 | text {* a fancy datatype *}
 | 
| 68 | ||
| 40757 | 69 | datatype ('a, 'b) foo =
 | 
| 70 | Foo "'a\<Colon>order" 'b | |
| 71 |   | Bla "('a, 'b) bar"
 | |
| 72 | | Dummy nat | |
| 73 | and ('a, 'b) bar =
 | |
| 74 | Bar 'a 'b | |
| 75 |   | Blubb "('a, 'b) foo"
 | |
| 23268 | 76 | |
| 40757 | 77 | value "Bla (Bar (4::nat) [Suc 0])" | 
| 78 | value [code] "Bla (Bar (4::nat) [Suc 0])" | |
| 79 | value [nbe] "Bla (Bar (4::nat) [Suc 0])" | |
| 23268 | 80 | |
| 81 | end |