src/HOL/Prolog/Func.thy
author berghofe
Thu, 10 Oct 2002 14:21:49 +0200
changeset 13638 2b234b079245
parent 13208 965f95a3abd9
child 14981 e73f8140af78
permissions -rw-r--r--
Added choice_eq.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13208
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     1
(*  Title:    HOL/Prolog/Func.thy
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     2
    ID:       $Id$
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     3
    Author:   David von Oheimb (based on a lecture on Lambda Prolog by Nadathur)
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     4
    License:  GPL (GNU GENERAL PUBLIC LICENSE)
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     5
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     6
untyped functional language, with call by value semantics 
965f95a3abd9 added the usual file headers
oheimb
parents: 12338
diff changeset
     7
*)
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
     8
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
     9
Func = HOHH +
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    10
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    11
types tm
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    12
12338
de0f4a63baa5 renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents: 9015
diff changeset
    13
arities tm :: type
9015
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    14
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    15
consts	abs	:: (tm => tm) => tm
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    16
	app	:: tm => tm => tm
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    17
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    18
	cond	:: tm => tm => tm => tm
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    19
	fix	:: (tm => tm) => tm
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    20
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    21
	true,
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    22
	false	:: tm
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    23
	"and"	:: tm => tm => tm	(infixr 999)
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    24
	"eq"	:: tm => tm => tm	(infixr 999)
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    25
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    26
	"0"	:: tm			("Z")
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    27
	S	:: tm => tm
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    28
(*
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    29
	"++", "--",
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    30
	"**"	:: tm => tm => tm	(infixr 999)
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    31
*)
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    32
	eval	:: [tm, tm] => bool
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    33
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    34
arities tm :: plus
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    35
arities tm :: minus
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    36
arities tm :: times
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    37
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    38
rules	eval "
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    39
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    40
eval (abs RR) (abs RR)..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    41
eval (app F X) V :- eval F (abs R) & eval X U & eval (R U) V..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    42
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    43
eval (cond P L1 R1) D1 :- eval P true  & eval L1 D1..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    44
eval (cond P L2 R2) D2 :- eval P false & eval R2 D2..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    45
eval (fix G) W   :- eval (G (fix G)) W..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    46
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    47
eval true  true ..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    48
eval false false..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    49
eval (P and Q) true  :- eval P true  & eval Q true ..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    50
eval (P and Q) false :- eval P false | eval Q false..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    51
eval (A1 eq B1) true  :- eval A1 C1 & eval B1 C1.. 
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    52
eval (A2 eq B2) false :- True..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    53
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    54
eval Z Z..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    55
eval (S N) (S M) :- eval N M..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    56
eval ( Z    + M) K     :- eval      M  K..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    57
eval ((S N) + M) (S K) :- eval (N + M) K..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    58
eval (N     - Z) K     :- eval  N      K..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    59
eval ((S N) - (S M)) K :- eval (N- M)  K..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    60
eval ( Z    * M) Z..
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    61
eval ((S N) * M) K :- eval (N * M) L & eval (L + M) K"
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    62
8006e9009621 added HOL/Prolog
oheimb
parents:
diff changeset
    63
end