src/HOL/ex/Eval_Examples.thy
author haftmann
Fri Oct 10 19:55:32 2014 +0200 (2014-10-10)
changeset 58646 cd63a4b12a33
parent 58310 91ea607a34d8
child 58889 5b7a9633cfa8
permissions -rw-r--r--
specialized specification: avoid trivial instances
haftmann@30021
     1
(* Author: Florian Haftmann, TU Muenchen *)
wenzelm@23268
     2
wenzelm@23268
     3
header {* Small examples for evaluation mechanisms *}
wenzelm@23268
     4
wenzelm@23268
     5
theory Eval_Examples
haftmann@32067
     6
imports Complex_Main
wenzelm@23268
     7
begin
wenzelm@23268
     8
haftmann@25099
     9
text {* evaluation oracle *}
haftmann@25099
    10
haftmann@25099
    11
lemma "True \<or> False" by eval
haftmann@40760
    12
lemma "Suc 0 \<noteq> Suc 1" by eval
haftmann@40760
    13
lemma "[] = ([] :: int list)" by eval
haftmann@25099
    14
lemma "[()] = [()]" by eval
haftmann@40760
    15
lemma "fst ([] :: nat list, Suc 0) = []" by eval
haftmann@25099
    16
haftmann@25099
    17
text {* normalization *}
wenzelm@23268
    18
haftmann@25099
    19
lemma "True \<or> False" by normalization
haftmann@40760
    20
lemma "Suc 0 \<noteq> Suc 1" by normalization
haftmann@40760
    21
lemma "[] = ([] :: int list)" by normalization
haftmann@25099
    22
lemma "[()] = [()]" by normalization
haftmann@40760
    23
lemma "fst ([] :: nat list, Suc 0) = []" by normalization
wenzelm@23268
    24
wenzelm@23268
    25
text {* term evaluation *}
wenzelm@23268
    26
haftmann@24587
    27
value "(Suc 2 + 1) * 4"
haftmann@24835
    28
haftmann@24587
    29
value "(Suc 2 + Suc 0) * Suc 3"
haftmann@24835
    30
haftmann@24587
    31
value "nat 100"
haftmann@24835
    32
haftmann@40760
    33
value "(10::int) \<le> 12"
haftmann@24835
    34
haftmann@24835
    35
value "max (2::int) 4"
haftmann@24835
    36
haftmann@24835
    37
value "of_int 2 / of_int 4 * (1::rat)"
haftmann@24835
    38
haftmann@40760
    39
value "[] :: nat list"
haftmann@24835
    40
haftmann@24587
    41
value "[(nat 100, ())]"
haftmann@24659
    42
wenzelm@23268
    43
text {* a fancy datatype *}
wenzelm@23268
    44
blanchet@58310
    45
datatype ('a, 'b) foo =
haftmann@40757
    46
    Foo "'a\<Colon>order" 'b
haftmann@40757
    47
  | Bla "('a, 'b) bar"
haftmann@40757
    48
  | Dummy nat
haftmann@40757
    49
and ('a, 'b) bar =
haftmann@40757
    50
    Bar 'a 'b
haftmann@40757
    51
  | Blubb "('a, 'b) foo"
wenzelm@23268
    52
haftmann@40757
    53
value "Bla (Bar (4::nat) [Suc 0])"
wenzelm@23268
    54
wenzelm@23268
    55
end