src/HOL/Prolog/Func.thy
author webertj
Mon Mar 07 19:30:53 2005 +0100 (2005-03-07)
changeset 15584 3478bb4f93ff
parent 14981 e73f8140af78
child 17311 5b1d47d920ce
permissions -rw-r--r--
refute_params: default value itself=1 added (for type classes)
oheimb@13208
     1
(*  Title:    HOL/Prolog/Func.thy
oheimb@13208
     2
    ID:       $Id$
oheimb@13208
     3
    Author:   David von Oheimb (based on a lecture on Lambda Prolog by Nadathur)
oheimb@13208
     4
oheimb@13208
     5
untyped functional language, with call by value semantics 
oheimb@13208
     6
*)
oheimb@9015
     7
oheimb@9015
     8
Func = HOHH +
oheimb@9015
     9
oheimb@9015
    10
types tm
oheimb@9015
    11
wenzelm@12338
    12
arities tm :: type
oheimb@9015
    13
oheimb@9015
    14
consts	abs	:: (tm => tm) => tm
oheimb@9015
    15
	app	:: tm => tm => tm
oheimb@9015
    16
oheimb@9015
    17
	cond	:: tm => tm => tm => tm
oheimb@9015
    18
	fix	:: (tm => tm) => tm
oheimb@9015
    19
oheimb@9015
    20
	true,
oheimb@9015
    21
	false	:: tm
oheimb@9015
    22
	"and"	:: tm => tm => tm	(infixr 999)
oheimb@9015
    23
	"eq"	:: tm => tm => tm	(infixr 999)
oheimb@9015
    24
oheimb@9015
    25
	"0"	:: tm			("Z")
oheimb@9015
    26
	S	:: tm => tm
oheimb@9015
    27
(*
oheimb@9015
    28
	"++", "--",
oheimb@9015
    29
	"**"	:: tm => tm => tm	(infixr 999)
oheimb@9015
    30
*)
oheimb@9015
    31
	eval	:: [tm, tm] => bool
oheimb@9015
    32
oheimb@9015
    33
arities tm :: plus
oheimb@9015
    34
arities tm :: minus
oheimb@9015
    35
arities tm :: times
oheimb@9015
    36
oheimb@9015
    37
rules	eval "
oheimb@9015
    38
oheimb@9015
    39
eval (abs RR) (abs RR)..
oheimb@9015
    40
eval (app F X) V :- eval F (abs R) & eval X U & eval (R U) V..
oheimb@9015
    41
oheimb@9015
    42
eval (cond P L1 R1) D1 :- eval P true  & eval L1 D1..
oheimb@9015
    43
eval (cond P L2 R2) D2 :- eval P false & eval R2 D2..
oheimb@9015
    44
eval (fix G) W   :- eval (G (fix G)) W..
oheimb@9015
    45
oheimb@9015
    46
eval true  true ..
oheimb@9015
    47
eval false false..
oheimb@9015
    48
eval (P and Q) true  :- eval P true  & eval Q true ..
oheimb@9015
    49
eval (P and Q) false :- eval P false | eval Q false..
oheimb@9015
    50
eval (A1 eq B1) true  :- eval A1 C1 & eval B1 C1.. 
oheimb@9015
    51
eval (A2 eq B2) false :- True..
oheimb@9015
    52
oheimb@9015
    53
eval Z Z..
oheimb@9015
    54
eval (S N) (S M) :- eval N M..
oheimb@9015
    55
eval ( Z    + M) K     :- eval      M  K..
oheimb@9015
    56
eval ((S N) + M) (S K) :- eval (N + M) K..
oheimb@9015
    57
eval (N     - Z) K     :- eval  N      K..
oheimb@9015
    58
eval ((S N) - (S M)) K :- eval (N- M)  K..
oheimb@9015
    59
eval ( Z    * M) Z..
oheimb@9015
    60
eval ((S N) * M) K :- eval (N * M) L & eval (L + M) K"
oheimb@9015
    61
oheimb@9015
    62
end