src/HOL/ex/Eval_Examples.thy
author wenzelm
Mon Aug 31 21:28:08 2015 +0200 (2015-08-31)
changeset 61070 b72a990adfe2
parent 58889 5b7a9633cfa8
child 61076 bdc1e2f0a86a
permissions -rw-r--r--
prefer symbols;
     1 (* Author: Florian Haftmann, TU Muenchen *)
     2 
     3 section {* Small examples for evaluation mechanisms *}
     4 
     5 theory Eval_Examples
     6 imports Complex_Main
     7 begin
     8 
     9 text {* evaluation oracle *}
    10 
    11 lemma "True \<or> False" by eval
    12 lemma "Suc 0 \<noteq> Suc 1" by eval
    13 lemma "[] = ([] :: int list)" by eval
    14 lemma "[()] = [()]" by eval
    15 lemma "fst ([] :: nat list, Suc 0) = []" by eval
    16 
    17 text {* normalization *}
    18 
    19 lemma "True \<or> False" by normalization
    20 lemma "Suc 0 \<noteq> Suc 1" by normalization
    21 lemma "[] = ([] :: int list)" by normalization
    22 lemma "[()] = [()]" by normalization
    23 lemma "fst ([] :: nat list, Suc 0) = []" by normalization
    24 
    25 text {* term evaluation *}
    26 
    27 value "(Suc 2 + 1) * 4"
    28 
    29 value "(Suc 2 + Suc 0) * Suc 3"
    30 
    31 value "nat 100"
    32 
    33 value "(10::int) \<le> 12"
    34 
    35 value "max (2::int) 4"
    36 
    37 value "of_int 2 / of_int 4 * (1::rat)"
    38 
    39 value "[] :: nat list"
    40 
    41 value "[(nat 100, ())]"
    42 
    43 text {* a fancy datatype *}
    44 
    45 datatype ('a, 'b) foo =
    46     Foo "'a\<Colon>order" 'b
    47   | Bla "('a, 'b) bar"
    48   | Dummy nat
    49 and ('a, 'b) bar =
    50     Bar 'a 'b
    51   | Blubb "('a, 'b) foo"
    52 
    53 value "Bla (Bar (4::nat) [Suc 0])"
    54 
    55 end