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