src/HOL/Prolog/Type.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
(* type inference *)
oheimb@9015
     2
oheimb@9015
     3
Type = Func +
oheimb@9015
     4
oheimb@9015
     5
types ty
oheimb@9015
     6
oheimb@9015
     7
arities ty :: term
oheimb@9015
     8
oheimb@9015
     9
consts  bool	:: ty
oheimb@9015
    10
	nat	:: ty
oheimb@9015
    11
	"->"	:: ty => ty => ty	(infixr 20)
oheimb@9015
    12
	typeof	:: [tm, ty] => bool
oheimb@9015
    13
        anyterm :: tm
oheimb@9015
    14
oheimb@9015
    15
rules	common_typeof	"
oheimb@9015
    16
typeof (app M N) B       :- typeof M (A -> B) & typeof N A..
oheimb@9015
    17
oheimb@9015
    18
typeof (cond C L R) A :- typeof C bool & typeof L A & typeof R A..
oheimb@9015
    19
typeof (fix F)   A       :- (!x. typeof x A => typeof (F  x) A)..
oheimb@9015
    20
oheimb@9015
    21
typeof true  bool..
oheimb@9015
    22
typeof false bool..
oheimb@9015
    23
typeof (M and N) bool :- typeof M bool & typeof N bool..
oheimb@9015
    24
oheimb@9015
    25
typeof (M eq  N) bool :- typeof M T    & typeof N T   ..
oheimb@9015
    26
oheimb@9015
    27
typeof  Z    nat..
oheimb@9015
    28
typeof (S N) nat :- typeof N nat..
oheimb@9015
    29
typeof (M + N) nat :- typeof M nat & typeof N nat..
oheimb@9015
    30
typeof (M - N) nat :- typeof M nat & typeof N nat..
oheimb@9015
    31
typeof (M * N) nat :- typeof M nat & typeof N nat"
oheimb@9015
    32
oheimb@9015
    33
rules	good_typeof	"
oheimb@9015
    34
typeof (abs Bo) (A -> B) :- (!x. typeof x A => typeof (Bo x) B)"
oheimb@9015
    35
oheimb@9015
    36
rules	bad1_typeof	"
oheimb@9015
    37
typeof (abs Bo) (A -> B) :- (typeof varterm A => typeof (Bo varterm) B)"
oheimb@9015
    38
oheimb@9015
    39
rules	bad2_typeof	"
oheimb@9015
    40
typeof (abs Bo) (A -> B) :- (typeof anyterm A => typeof (Bo anyterm) B)"
oheimb@9015
    41
oheimb@9015
    42
end