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