src/HOL/Prolog/Func.thy
author wenzelm
Wed Sep 07 21:07:09 2005 +0200 (2005-09-07)
changeset 17311 5b1d47d920ce
parent 14981 e73f8140af78
child 20713 823967ef47f1
permissions -rw-r--r--
converted to Isar theory format;
     1 (*  Title:    HOL/Prolog/Func.thy
     2     ID:       $Id$
     3     Author:   David von Oheimb (based on a lecture on Lambda Prolog by Nadathur)
     4 *)
     5 
     6 header {* Untyped functional language, with call by value semantics *}
     7 
     8 theory Func
     9 imports HOHH
    10 begin
    11 
    12 typedecl tm
    13 
    14 consts
    15   abs     :: "(tm => tm) => tm"
    16   app     :: "tm => tm => tm"
    17 
    18   cond    :: "tm => tm => tm => tm"
    19   "fix"   :: "(tm => tm) => tm"
    20 
    21   true    :: tm
    22   false   :: tm
    23   "and"   :: "tm => tm => tm"       (infixr 999)
    24   "eq"    :: "tm => tm => tm"       (infixr 999)
    25 
    26   "0"     :: tm                   ("Z")
    27   S       :: "tm => tm"
    28 (*
    29         "++", "--",
    30         "**"    :: tm => tm => tm       (infixr 999)
    31 *)
    32         eval    :: "[tm, tm] => bool"
    33 
    34 instance tm :: plus ..
    35 instance tm :: minus ..
    36 instance tm :: times ..
    37 
    38 axioms   eval: "
    39 
    40 eval (abs RR) (abs RR)..
    41 eval (app F X) V :- eval F (abs R) & eval X U & eval (R U) V..
    42 
    43 eval (cond P L1 R1) D1 :- eval P true  & eval L1 D1..
    44 eval (cond P L2 R2) D2 :- eval P false & eval R2 D2..
    45 eval (fix G) W   :- eval (G (fix G)) W..
    46 
    47 eval true  true ..
    48 eval false false..
    49 eval (P and Q) true  :- eval P true  & eval Q true ..
    50 eval (P and Q) false :- eval P false | eval Q false..
    51 eval (A1 eq B1) true  :- eval A1 C1 & eval B1 C1..
    52 eval (A2 eq B2) false :- True..
    53 
    54 eval Z Z..
    55 eval (S N) (S M) :- eval N M..
    56 eval ( Z    + M) K     :- eval      M  K..
    57 eval ((S N) + M) (S K) :- eval (N + M) K..
    58 eval (N     - Z) K     :- eval  N      K..
    59 eval ((S N) - (S M)) K :- eval (N- M)  K..
    60 eval ( Z    * M) Z..
    61 eval ((S N) * M) K :- eval (N * M) L & eval (L + M) K"
    62 
    63 ML {* use_legacy_bindings (the_context ()) *}
    64 
    65 end