equal
deleted
inserted
replaced
9 *) |
9 *) |
10 |
10 |
11 signature ENVIR = |
11 signature ENVIR = |
12 sig |
12 sig |
13 datatype env = Envir of {asol: term Vartab.table, iTs: typ Vartab.table, maxidx: int} |
13 datatype env = Envir of {asol: term Vartab.table, iTs: typ Vartab.table, maxidx: int} |
|
14 val type_env: env -> typ Vartab.table |
14 exception SAME |
15 exception SAME |
15 val genvars: string -> env * typ list -> env * term list |
16 val genvars: string -> env * typ list -> env * term list |
16 val genvar: string -> env * typ -> env * term |
17 val genvar: string -> env * typ -> env * term |
17 val lookup: env * indexname -> term option |
18 val lookup: env * indexname -> term option |
18 val update: (indexname * term) * env -> env |
19 val update: (indexname * term) * env -> env |
21 val above: int * env -> bool |
22 val above: int * env -> bool |
22 val vupdate: (indexname * term) * env -> env |
23 val vupdate: (indexname * term) * env -> env |
23 val alist_of: env -> (indexname * term) list |
24 val alist_of: env -> (indexname * term) list |
24 val norm_term: env -> term -> term |
25 val norm_term: env -> term -> term |
25 val norm_term_same: env -> term -> term |
26 val norm_term_same: env -> term -> term |
26 val norm_type: env -> typ -> typ |
27 val norm_type: typ Vartab.table -> typ -> typ |
27 val norm_type_same: env -> typ -> typ |
28 val norm_type_same: typ Vartab.table -> typ -> typ |
28 val norm_types_same: env -> typ list -> typ list |
29 val norm_types_same: typ Vartab.table -> typ list -> typ list |
29 val beta_norm: term -> term |
30 val beta_norm: term -> term |
30 val head_norm: env -> term -> term |
31 val head_norm: env -> term -> term |
31 val fastype: env -> typ list -> term -> typ |
32 val fastype: env -> typ list -> term -> typ |
32 end; |
33 end; |
33 |
34 |
40 datatype env = Envir of |
41 datatype env = Envir of |
41 {maxidx: int, (*maximum index of vars*) |
42 {maxidx: int, (*maximum index of vars*) |
42 asol: term Vartab.table, (*table of assignments to Vars*) |
43 asol: term Vartab.table, (*table of assignments to Vars*) |
43 iTs: typ Vartab.table} (*table of assignments to TVars*) |
44 iTs: typ Vartab.table} (*table of assignments to TVars*) |
44 |
45 |
|
46 fun type_env (Envir {iTs, ...}) = iTs; |
45 |
47 |
46 (*Generate a list of distinct variables. |
48 (*Generate a list of distinct variables. |
47 Increments index to make them distinct from ALL present variables. *) |
49 Increments index to make them distinct from ALL present variables. *) |
48 fun genvars name (Envir{maxidx, asol, iTs}, Ts) : env * term list = |
50 fun genvars name (Envir{maxidx, asol, iTs}, Ts) : env * term list = |
49 let fun genvs (_, [] : typ list) : term list = [] |
51 let fun genvs (_, [] : typ list) : term list = [] |
153 val norm_term = gen_norm_term false; |
155 val norm_term = gen_norm_term false; |
154 val norm_term_same = gen_norm_term true; |
156 val norm_term_same = gen_norm_term true; |
155 |
157 |
156 val beta_norm = norm_term (empty 0); |
158 val beta_norm = norm_term (empty 0); |
157 |
159 |
158 fun norm_type (Envir {iTs, ...}) = normTh iTs; |
160 fun norm_type iTs = normTh iTs; |
159 fun norm_type_same (Envir {iTs, ...}) = |
161 fun norm_type_same iTs = |
160 if Vartab.is_empty iTs then raise SAME else normT iTs; |
162 if Vartab.is_empty iTs then raise SAME else normT iTs; |
161 |
163 |
162 fun norm_types_same (Envir {iTs, ...}) = |
164 fun norm_types_same iTs = |
163 if Vartab.is_empty iTs then raise SAME else normTs iTs; |
165 if Vartab.is_empty iTs then raise SAME else normTs iTs; |
164 |
166 |
165 |
167 |
166 (*Put a term into head normal form for unification.*) |
168 (*Put a term into head normal form for unification.*) |
167 |
169 |