author | paulson |
Tue, 29 Mar 2005 12:30:48 +0200 | |
changeset 15635 | 8408a06590a6 |
parent 14981 | e73f8140af78 |
child 17311 | 5b1d47d920ce |
permissions | -rw-r--r-- |
13208 | 1 |
(* Title: HOL/Prolog/Type.thy |
2 |
ID: $Id$ |
|
3 |
Author: David von Oheimb (based on a lecture on Lambda Prolog by Nadathur) |
|
4 |
||
5 |
type inference |
|
6 |
*) |
|
9015 | 7 |
|
8 |
Type = Func + |
|
9 |
||
10 |
types ty |
|
11 |
||
12338
de0f4a63baa5
renamed class "term" to "type" (actually "HOL.type");
wenzelm
parents:
9015
diff
changeset
|
12 |
arities ty :: type |
9015 | 13 |
|
14 |
consts bool :: ty |
|
15 |
nat :: ty |
|
16 |
"->" :: ty => ty => ty (infixr 20) |
|
17 |
typeof :: [tm, ty] => bool |
|
18 |
anyterm :: tm |
|
19 |
||
20 |
rules common_typeof " |
|
21 |
typeof (app M N) B :- typeof M (A -> B) & typeof N A.. |
|
22 |
||
23 |
typeof (cond C L R) A :- typeof C bool & typeof L A & typeof R A.. |
|
24 |
typeof (fix F) A :- (!x. typeof x A => typeof (F x) A).. |
|
25 |
||
26 |
typeof true bool.. |
|
27 |
typeof false bool.. |
|
28 |
typeof (M and N) bool :- typeof M bool & typeof N bool.. |
|
29 |
||
30 |
typeof (M eq N) bool :- typeof M T & typeof N T .. |
|
31 |
||
32 |
typeof Z nat.. |
|
33 |
typeof (S N) nat :- typeof N nat.. |
|
34 |
typeof (M + N) nat :- typeof M nat & typeof N nat.. |
|
35 |
typeof (M - N) nat :- typeof M nat & typeof N nat.. |
|
36 |
typeof (M * N) nat :- typeof M nat & typeof N nat" |
|
37 |
||
38 |
rules good_typeof " |
|
39 |
typeof (abs Bo) (A -> B) :- (!x. typeof x A => typeof (Bo x) B)" |
|
40 |
||
41 |
rules bad1_typeof " |
|
42 |
typeof (abs Bo) (A -> B) :- (typeof varterm A => typeof (Bo varterm) B)" |
|
43 |
||
44 |
rules bad2_typeof " |
|
45 |
typeof (abs Bo) (A -> B) :- (typeof anyterm A => typeof (Bo anyterm) B)" |
|
46 |
||
47 |
end |