src/HOL/Prolog/Func.thy
author kleing
Mon Jun 21 10:25:57 2004 +0200 (2004-06-21)
changeset 14981 e73f8140af78
parent 13208 965f95a3abd9
child 17311 5b1d47d920ce
permissions -rw-r--r--
Merged in license change from Isabelle2004
     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 untyped functional language, with call by value semantics 
     6 *)
     7 
     8 Func = HOHH +
     9 
    10 types tm
    11 
    12 arities tm :: type
    13 
    14 consts	abs	:: (tm => tm) => tm
    15 	app	:: tm => tm => tm
    16 
    17 	cond	:: tm => tm => tm => tm
    18 	fix	:: (tm => tm) => tm
    19 
    20 	true,
    21 	false	:: tm
    22 	"and"	:: tm => tm => tm	(infixr 999)
    23 	"eq"	:: tm => tm => tm	(infixr 999)
    24 
    25 	"0"	:: tm			("Z")
    26 	S	:: tm => tm
    27 (*
    28 	"++", "--",
    29 	"**"	:: tm => tm => tm	(infixr 999)
    30 *)
    31 	eval	:: [tm, tm] => bool
    32 
    33 arities tm :: plus
    34 arities tm :: minus
    35 arities tm :: times
    36 
    37 rules	eval "
    38 
    39 eval (abs RR) (abs RR)..
    40 eval (app F X) V :- eval F (abs R) & eval X U & eval (R U) V..
    41 
    42 eval (cond P L1 R1) D1 :- eval P true  & eval L1 D1..
    43 eval (cond P L2 R2) D2 :- eval P false & eval R2 D2..
    44 eval (fix G) W   :- eval (G (fix G)) W..
    45 
    46 eval true  true ..
    47 eval false false..
    48 eval (P and Q) true  :- eval P true  & eval Q true ..
    49 eval (P and Q) false :- eval P false | eval Q false..
    50 eval (A1 eq B1) true  :- eval A1 C1 & eval B1 C1.. 
    51 eval (A2 eq B2) false :- True..
    52 
    53 eval Z Z..
    54 eval (S N) (S M) :- eval N M..
    55 eval ( Z    + M) K     :- eval      M  K..
    56 eval ((S N) + M) (S K) :- eval (N + M) K..
    57 eval (N     - Z) K     :- eval  N      K..
    58 eval ((S N) - (S M)) K :- eval (N- M)  K..
    59 eval ( Z    * M) Z..
    60 eval ((S N) * M) K :- eval (N * M) L & eval (L + M) K"
    61 
    62 end