aboutsummaryrefslogtreecommitdiffhomepage
path: root/kernel/typeops.ml
diff options
context:
space:
mode:
authorGravatar Matthieu Sozeau <mattam@mattam.org>2013-10-30 19:28:55 +0100
committerGravatar Matthieu Sozeau <mattam@mattam.org>2014-05-06 09:58:54 +0200
commit1c1accf7186438228be9c426db9071aa95a7e992 (patch)
tree67fae89d05072db6249fdf59325d3691a09dbea6 /kernel/typeops.ml
parent001ff72b2c17fb7b2fcaefa2555c115f0d909a03 (diff)
Properly reinstate old-style polymorphism in the kernel and pretyping/retyping.
TODO fix interface on knowing_parameters to avoid useless array allocations.
Diffstat (limited to 'kernel/typeops.ml')
-rw-r--r--kernel/typeops.ml34
1 files changed, 24 insertions, 10 deletions
diff --git a/kernel/typeops.ml b/kernel/typeops.ml
index 09e2fb1d5..9428ace38 100644
--- a/kernel/typeops.ml
+++ b/kernel/typeops.ml
@@ -314,19 +314,21 @@ let judge_of_cast env cj k tj =
the App case of execute; from this constraints, the expected
dynamic constraints of the form u<=v are enforced *)
-(* let judge_of_inductive_knowing_parameters env ind jl = *)
-(* let c = mkInd ind in *)
-(* let (mib,mip) = lookup_mind_specif env ind in *)
-(* check_args env c mib.mind_hyps; *)
-(* let paramstyp = Array.map (fun j -> j.uj_type) jl in *)
-(* let t = in *)
-(* make_judge c t *)
+let judge_of_inductive_knowing_parameters env (ind,u as indu) args =
+ let c = mkIndU indu in
+ let (mib,mip) as spec = lookup_mind_specif env ind in
+ check_hyps_inclusion env c mib.mind_hyps;
+ let t,cst = Inductive.constrained_type_of_inductive_knowing_parameters
+ env (spec,u) args
+ in
+ check_constraints cst env;
+ make_judge c t
let judge_of_inductive env (ind,u as indu) =
let c = mkIndU indu in
- let (mib,mip) = lookup_mind_specif env ind in
+ let (mib,mip) as spec = lookup_mind_specif env ind in
check_hyps_inclusion env c mib.mind_hyps;
- let t,cst = Inductive.constrained_type_of_inductive env ((mib,mip),u) in
+ let t,cst = Inductive.constrained_type_of_inductive env (spec,u) in
check_constraints cst env;
(make_judge c t)
@@ -424,7 +426,19 @@ let rec execute env cstr =
(* Lambda calculus operators *)
| App (f,args) ->
let jl = execute_array env args in
- let j = execute env f in
+ let j =
+ match kind_of_term f with
+ | Ind ind ->
+ (* Sort-polymorphism of inductive types *)
+ let args = Array.map (fun j -> lazy j.uj_type) jl in
+ judge_of_inductive_knowing_parameters env ind args
+ | Const cst ->
+ (* Sort-polymorphism of constant *)
+ judge_of_constant_knowing_parameters env cst jl
+ | _ ->
+ (* No sort-polymorphism *)
+ execute env f
+ in
judge_of_apply env j jl
| Lambda (name,c1,c2) ->