src/HOL/Prolog/Func.thy
author oheimb
Fri Jun 02 12:44:04 2000 +0200 (2000-06-02)
changeset 9015 8006e9009621
child 12338 de0f4a63baa5
permissions -rw-r--r--
added HOL/Prolog
oheimb@9015
     1
(* untyped functional language, with call by value semantics *)
oheimb@9015
     2
oheimb@9015
     3
Func = HOHH +
oheimb@9015
     4
oheimb@9015
     5
types tm
oheimb@9015
     6
oheimb@9015
     7
arities tm :: term
oheimb@9015
     8
oheimb@9015
     9
consts	abs	:: (tm => tm) => tm
oheimb@9015
    10
	app	:: tm => tm => tm
oheimb@9015
    11
oheimb@9015
    12
	cond	:: tm => tm => tm => tm
oheimb@9015
    13
	fix	:: (tm => tm) => tm
oheimb@9015
    14
oheimb@9015
    15
	true,
oheimb@9015
    16
	false	:: tm
oheimb@9015
    17
	"and"	:: tm => tm => tm	(infixr 999)
oheimb@9015
    18
	"eq"	:: tm => tm => tm	(infixr 999)
oheimb@9015
    19
oheimb@9015
    20
	"0"	:: tm			("Z")
oheimb@9015
    21
	S	:: tm => tm
oheimb@9015
    22
(*
oheimb@9015
    23
	"++", "--",
oheimb@9015
    24
	"**"	:: tm => tm => tm	(infixr 999)
oheimb@9015
    25
*)
oheimb@9015
    26
	eval	:: [tm, tm] => bool
oheimb@9015
    27
oheimb@9015
    28
arities tm :: plus
oheimb@9015
    29
arities tm :: minus
oheimb@9015
    30
arities tm :: times
oheimb@9015
    31
oheimb@9015
    32
rules	eval "
oheimb@9015
    33
oheimb@9015
    34
eval (abs RR) (abs RR)..
oheimb@9015
    35
eval (app F X) V :- eval F (abs R) & eval X U & eval (R U) V..
oheimb@9015
    36
oheimb@9015
    37
eval (cond P L1 R1) D1 :- eval P true  & eval L1 D1..
oheimb@9015
    38
eval (cond P L2 R2) D2 :- eval P false & eval R2 D2..
oheimb@9015
    39
eval (fix G) W   :- eval (G (fix G)) W..
oheimb@9015
    40
oheimb@9015
    41
eval true  true ..
oheimb@9015
    42
eval false false..
oheimb@9015
    43
eval (P and Q) true  :- eval P true  & eval Q true ..
oheimb@9015
    44
eval (P and Q) false :- eval P false | eval Q false..
oheimb@9015
    45
eval (A1 eq B1) true  :- eval A1 C1 & eval B1 C1.. 
oheimb@9015
    46
eval (A2 eq B2) false :- True..
oheimb@9015
    47
oheimb@9015
    48
eval Z Z..
oheimb@9015
    49
eval (S N) (S M) :- eval N M..
oheimb@9015
    50
eval ( Z    + M) K     :- eval      M  K..
oheimb@9015
    51
eval ((S N) + M) (S K) :- eval (N + M) K..
oheimb@9015
    52
eval (N     - Z) K     :- eval  N      K..
oheimb@9015
    53
eval ((S N) - (S M)) K :- eval (N- M)  K..
oheimb@9015
    54
eval ( Z    * M) Z..
oheimb@9015
    55
eval ((S N) * M) K :- eval (N * M) L & eval (L + M) K"
oheimb@9015
    56
oheimb@9015
    57
end