aboutsummaryrefslogtreecommitdiff
path: root/toplevel
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2016-11-26 02:12:40 +0100
committerPierre-Marie Pédrot2017-02-14 17:30:43 +0100
commitc8c8ccdaaffefdbd3d78c844552a08bcb7b4f915 (patch)
treef57eaac2d0c3cee82b172556eca53f16e0f0a900 /toplevel
parent01849481fbabc3a3fa6c483e703996b01e37fca5 (diff)
Evar-normalizing functions now act on EConstrs.
Diffstat (limited to 'toplevel')
-rw-r--r--toplevel/auto_ind_decl.ml4
-rw-r--r--toplevel/classes.ml4
-rw-r--r--toplevel/command.ml71
-rw-r--r--toplevel/himsg.ml56
-rw-r--r--toplevel/obligations.ml4
-rw-r--r--toplevel/vernacentries.ml8
6 files changed, 78 insertions, 69 deletions
diff --git a/toplevel/auto_ind_decl.ml b/toplevel/auto_ind_decl.ml
index 5e686c41e1..14071d869d 100644
--- a/toplevel/auto_ind_decl.ml
+++ b/toplevel/auto_ind_decl.ml
@@ -658,6 +658,7 @@ let make_bl_scheme mode mind =
let bl_goal, eff = compute_bl_goal ind lnamesparrec nparrec in
let ctx = Evd.make_evar_universe_context (Global.env ()) None in
let side_eff = side_effect_of_mode mode in
+ let bl_goal = EConstr.of_constr bl_goal in
let (ans, _, ctx) = Pfedit.build_by_tactic ~side_eff (Global.env()) ctx bl_goal
(compute_bl_tact mode (!bl_scheme_kind_aux()) (ind, Univ.Instance.empty) lnamesparrec nparrec)
in
@@ -783,6 +784,7 @@ let make_lb_scheme mode mind =
let lb_goal, eff = compute_lb_goal ind lnamesparrec nparrec in
let ctx = Evd.make_evar_universe_context (Global.env ()) None in
let side_eff = side_effect_of_mode mode in
+ let lb_goal = EConstr.of_constr lb_goal in
let (ans, _, ctx) = Pfedit.build_by_tactic ~side_eff (Global.env()) ctx lb_goal
(compute_lb_tact mode (!lb_scheme_kind_aux()) ind lnamesparrec nparrec)
in
@@ -956,7 +958,7 @@ let make_eq_decidability mode mind =
context_chop (nparams-nparrec) mib.mind_params_ctxt in
let side_eff = side_effect_of_mode mode in
let (ans, _, ctx) = Pfedit.build_by_tactic ~side_eff (Global.env()) ctx
- (compute_dec_goal (ind,u) lnamesparrec nparrec)
+ (EConstr.of_constr (compute_dec_goal (ind,u) lnamesparrec nparrec))
(compute_dec_tact ind lnamesparrec nparrec)
in
([|ans|], ctx), Safe_typing.empty_private_constants
diff --git a/toplevel/classes.ml b/toplevel/classes.ml
index 5087aa0c8c..7a5d0ed81f 100644
--- a/toplevel/classes.ml
+++ b/toplevel/classes.ml
@@ -181,7 +181,7 @@ let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) p
let env' = push_rel_context ctx env in
evars := Evarutil.nf_evar_map !evars;
evars := resolve_typeclasses ~filter:Typeclasses.all_evars ~fail:true env !evars;
- let subst = List.map (Evarutil.nf_evar !evars) subst in
+ let subst = List.map (fun c -> EConstr.Unsafe.to_constr (Evarutil.nf_evar !evars (EConstr.of_constr c))) subst in
if abstract then
begin
let subst = List.fold_left2
@@ -327,7 +327,7 @@ let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) p
the refinement manually.*)
let gls = List.rev (Evd.future_goals evm) in
let evm = Evd.reset_future_goals evm in
- Lemmas.start_proof id kind evm termtype
+ Lemmas.start_proof id kind evm (EConstr.of_constr termtype)
(Lemmas.mk_hook
(fun _ -> instance_hook k pri global imps ?hook));
(* spiwack: I don't know what to do with the status here. *)
diff --git a/toplevel/command.ml b/toplevel/command.ml
index 7e3828131b..44fc4eb1a2 100644
--- a/toplevel/command.ml
+++ b/toplevel/command.ml
@@ -306,7 +306,8 @@ let do_assumptions_unbound_univs (_, poly, _ as kind) nl l =
(env,empty_internalization_env) l
in
let evd = solve_remaining_evars all_and_fail_flags env !evdref (Evd.empty,!evdref) in
- let l = List.map (on_pi2 (nf_evar evd)) l in
+ let nf_evar c = EConstr.Unsafe.to_constr (nf_evar evd (EConstr.of_constr c)) in
+ let l = List.map (on_pi2 nf_evar) l in
snd (List.fold_left (fun (subst,status) ((is_coe,idl),t,(ctx,imps)) ->
let t = replace_vars subst t in
let (refs,status') = declare_assumptions idl is_coe kind (t,ctx) [] imps false nl in
@@ -465,7 +466,7 @@ let sign_level env evd sign =
| LocalDef _ -> lev, push_rel d env
| LocalAssum _ ->
let s = destSort (Reduction.whd_all env
- (nf_evar evd (EConstr.Unsafe.to_constr (Retyping.get_type_of env evd (EConstr.of_constr (RelDecl.get_type d))))))
+ (EConstr.Unsafe.to_constr (nf_evar evd (Retyping.get_type_of env evd (EConstr.of_constr (RelDecl.get_type d))))))
in
let u = univ_of_sort s in
(Univ.sup u lev, push_rel d env))
@@ -905,8 +906,9 @@ let fix_sub_ref = make_ref fixsub_module "Fix_sub"
let measure_on_R_ref = make_ref fixsub_module "MR"
let well_founded = init_constant ["Init"; "Wf"] "well_founded"
let mkSubset name typ prop =
- mkApp (Universes.constr_of_global (delayed_force build_sigma).typ,
- [| typ; mkLambda (name, typ, prop) |])
+ let open EConstr in
+ EConstr.Unsafe.to_constr (mkApp (EConstr.of_constr (Universes.constr_of_global (delayed_force build_sigma).typ),
+ [| typ; mkLambda (name, typ, prop) |]))
let sigT = Lazy.from_fun build_sigma_type
let make_qref s = Qualid (Loc.ghost, qualid_of_string s)
@@ -943,9 +945,11 @@ let rec telescope = function
ty, (LocalDef (n, b, t) :: subst), lift 1 term
let nf_evar_context sigma ctx =
- List.map (map_constr (Evarutil.nf_evar sigma)) ctx
+ List.map (map_constr (fun c -> EConstr.Unsafe.to_constr (Evarutil.nf_evar sigma (EConstr.of_constr c)))) ctx
let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
+ let open EConstr in
+ let open Vars in
Coqlib.check_required_library ["Coq";"Program";"Wf"];
let env = Global.env() in
let ctx = Evd.make_evar_universe_context env pl in
@@ -954,11 +958,12 @@ let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
let len = List.length binders_rel in
let top_env = push_rel_context binders_rel env in
let top_arity = interp_type_evars top_env evdref arityc in
- let top_arity = EConstr.Unsafe.to_constr top_arity in
- let full_arity = Term.it_mkProd_or_LetIn top_arity binders_rel in
+ let full_arity = it_mkProd_or_LetIn top_arity binders_rel in
let argtyp, letbinders, make = telescope binders_rel in
+ let make = EConstr.of_constr make in
let argname = Id.of_string "recarg" in
let arg = LocalAssum (Name argname, argtyp) in
+ let argtyp = EConstr.of_constr argtyp in
let binders = letbinders @ [arg] in
let binders_env = push_rel_context binders_rel env in
let rel, _ = interp_constr_evars_impls env evdref r in
@@ -977,22 +982,21 @@ let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
| _, _ -> error ()
with e when CErrors.noncritical e -> error ()
in
- let rel = EConstr.Unsafe.to_constr rel in
let measure = interp_casted_constr_evars binders_env evdref measure relargty in
- let measure = EConstr.Unsafe.to_constr measure in
let wf_rel, wf_rel_fun, measure_fn =
let measure_body, measure =
it_mkLambda_or_LetIn measure letbinders,
it_mkLambda_or_LetIn measure binders
in
- let comb = Universes.constr_of_global (delayed_force measure_on_R_ref) in
+ let comb = EConstr.of_constr (Universes.constr_of_global (delayed_force measure_on_R_ref)) in
+ let relargty = EConstr.of_constr relargty in
let wf_rel = mkApp (comb, [| argtyp; relargty; rel; measure |]) in
let wf_rel_fun x y =
mkApp (rel, [| subst1 x measure_body;
subst1 y measure_body |])
in wf_rel, wf_rel_fun, measure
in
- let wf_proof = mkApp (delayed_force well_founded, [| argtyp ; wf_rel |]) in
+ let wf_proof = mkApp (EConstr.of_constr (delayed_force well_founded), [| argtyp ; wf_rel |]) in
let argid' = Id.of_string (Id.to_string argname ^ "'") in
let wfarg len = LocalAssum (Name argid',
mkSubset (Name argid') argtyp
@@ -1000,7 +1004,7 @@ let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
in
let intern_bl = wfarg 1 :: [arg] in
let _intern_env = push_rel_context intern_bl env in
- let proj = (*FIXME*)Universes.constr_of_global (delayed_force build_sigma).Coqlib.proj1 in
+ let proj = (*FIXME*)EConstr.of_constr (Universes.constr_of_global (delayed_force build_sigma).Coqlib.proj1) in
let wfargpred = mkLambda (Name argid', argtyp, wf_rel_fun (mkRel 1) (mkRel 3)) in
let projection = (* in wfarg :: arg :: before *)
mkApp (proj, [| argtyp ; wfargpred ; mkRel 1 |])
@@ -1009,17 +1013,21 @@ let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
let intern_arity = substl [projection] top_arity_let in
(* substitute the projection of wfarg for something,
now intern_arity is in wfarg :: arg *)
- let intern_fun_arity_prod = Term.it_mkProd_or_LetIn intern_arity [wfarg 1] in
+ let intern_fun_arity_prod = it_mkProd_or_LetIn intern_arity [wfarg 1] in
+ let intern_fun_arity_prod = EConstr.Unsafe.to_constr intern_fun_arity_prod in
let intern_fun_binder = LocalAssum (Name (add_suffix recname "'"), intern_fun_arity_prod) in
let curry_fun =
let wfpred = mkLambda (Name argid', argtyp, wf_rel_fun (mkRel 1) (mkRel (2 * len + 4))) in
- let intro = (*FIXME*)Universes.constr_of_global (delayed_force build_sigma).Coqlib.intro in
+ let intro = (*FIXME*)EConstr.of_constr (Universes.constr_of_global (delayed_force build_sigma).Coqlib.intro) in
let arg = mkApp (intro, [| argtyp; wfpred; lift 1 make; mkRel 1 |]) in
let app = mkApp (mkRel (2 * len + 2 (* recproof + orig binders + current binders *)), [| arg |]) in
let rcurry = mkApp (rel, [| measure; lift len measure |]) in
+ let rcurry = EConstr.Unsafe.to_constr rcurry in
let lam = LocalAssum (Name (Id.of_string "recproof"), rcurry) in
let body = it_mkLambda_or_LetIn app (lam :: binders_rel) in
- let ty = Term.it_mkProd_or_LetIn (lift 1 top_arity) (lam :: binders_rel) in
+ let ty = it_mkProd_or_LetIn (lift 1 top_arity) (lam :: binders_rel) in
+ let body = EConstr.Unsafe.to_constr body in
+ let ty = EConstr.Unsafe.to_constr ty in
LocalDef (Name recname, body, ty)
in
let fun_bl = intern_fun_binder :: [arg] in
@@ -1028,26 +1036,24 @@ let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
let ctx = LocalAssum (Name recname, get_type curry_fun) :: binders_rel in
let (r, l, impls, scopes) =
Constrintern.compute_internalization_data env
- Constrintern.Recursive full_arity impls
+ Constrintern.Recursive (EConstr.Unsafe.to_constr full_arity) impls
in
let newimpls = Id.Map.singleton recname
(r, l, impls @ [(Some (Id.of_string "recproof", Impargs.Manual, (true, false)))],
scopes @ [None]) in
interp_casted_constr_evars (push_rel_context ctx env) evdref
- ~impls:newimpls body (lift 1 top_arity)
+ ~impls:newimpls body (EConstr.Unsafe.to_constr (lift 1 top_arity))
in
- let intern_body = EConstr.Unsafe.to_constr intern_body in
let intern_body_lam = it_mkLambda_or_LetIn intern_body (curry_fun :: lift_lets @ fun_bl) in
let prop = mkLambda (Name argname, argtyp, top_arity_let) in
let def =
- mkApp (Universes.constr_of_global (delayed_force fix_sub_ref),
+ mkApp (EConstr.of_constr (Universes.constr_of_global (delayed_force fix_sub_ref)),
[| argtyp ; wf_rel ;
- EConstr.Unsafe.to_constr (Evarutil.e_new_evar env evdref
- ~src:(Loc.ghost, Evar_kinds.QuestionMark (Evar_kinds.Define false)) (EConstr.of_constr wf_proof));
+ Evarutil.e_new_evar env evdref
+ ~src:(Loc.ghost, Evar_kinds.QuestionMark (Evar_kinds.Define false)) wf_proof;
prop |])
in
- let def = Typing.e_solve_evars env evdref (EConstr.of_constr def) in
- let def = EConstr.Unsafe.to_constr def in
+ let def = Typing.e_solve_evars env evdref def in
let _ = evdref := Evarutil.nf_evar_map !evdref in
let def = mkApp (def, [|intern_body_lam|]) in
let binders_rel = nf_evar_context !evdref binders_rel in
@@ -1057,21 +1063,22 @@ let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
if List.length binders_rel > 1 then
let name = add_suffix recname "_func" in
let hook l gr _ =
- let body = it_mkLambda_or_LetIn (mkApp (Universes.constr_of_global gr, [|make|])) binders_rel in
- let ty = Term.it_mkProd_or_LetIn top_arity binders_rel in
+ let body = it_mkLambda_or_LetIn (mkApp (EConstr.of_constr (Universes.constr_of_global gr), [|make|])) binders_rel in
+ let ty = it_mkProd_or_LetIn top_arity binders_rel in
+ let ty = EConstr.Unsafe.to_constr ty in
let pl, univs = Evd.universe_context ?names:pl !evdref in
(*FIXME poly? *)
- let ce = definition_entry ~poly ~types:ty ~univs (Evarutil.nf_evar !evdref body) in
+ let ce = definition_entry ~poly ~types:ty ~univs (EConstr.Unsafe.to_constr (Evarutil.nf_evar !evdref body)) in
(** FIXME: include locality *)
let c = Declare.declare_constant recname (DefinitionEntry ce, IsDefinition Definition) in
let gr = ConstRef c in
if Impargs.is_implicit_args () || not (List.is_empty impls) then
Impargs.declare_manual_implicits false gr [impls]
in
- let typ = Term.it_mkProd_or_LetIn top_arity binders in
+ let typ = it_mkProd_or_LetIn top_arity binders in
hook, name, typ
else
- let typ = Term.it_mkProd_or_LetIn top_arity binders_rel in
+ let typ = it_mkProd_or_LetIn top_arity binders_rel in
let hook l gr _ =
if Impargs.is_implicit_args () || not (List.is_empty impls) then
Impargs.declare_manual_implicits false gr [impls]
@@ -1080,6 +1087,8 @@ let build_wellfounded (recname,pl,n,bl,arityc,body) poly r measure notation =
let hook = Lemmas.mk_hook hook in
let fullcoqc = Evarutil.nf_evar !evdref def in
let fullctyp = Evarutil.nf_evar !evdref typ in
+ let fullcoqc = EConstr.Unsafe.to_constr fullcoqc in
+ let fullctyp = EConstr.Unsafe.to_constr fullctyp in
Obligations.check_evars env !evdref;
let evars, _, evars_def, evars_typ =
Obligations.eterm_obligations env recname !evdref 0 fullcoqc fullctyp
@@ -1110,7 +1119,7 @@ let interp_recursive isfix fixl notations =
let fixctximpenvs, fixctximps = List.split fiximppairs in
let fixccls,fixcclimps = List.split (List.map3 (interp_fix_ccl evdref) fixctximpenvs fixctxs fixl) in
let fixtypes = List.map2 build_fix_type fixctxs fixccls in
- let fixtypes = List.map (nf_evar !evdref) fixtypes in
+ let fixtypes = List.map (fun c -> EConstr.Unsafe.to_constr (nf_evar !evdref (EConstr.of_constr c))) fixtypes in
let fiximps = List.map3
(fun ctximps cclimps (_,ctx) -> ctximps@(Impargs.lift_implicits (List.length ctx) cclimps))
fixctximps fixcclimps fixctxs in
@@ -1285,9 +1294,9 @@ let do_program_recursive local p fixkind fixl ntns =
let collect_evars id def typ imps =
(* Generalize by the recursive prototypes *)
let def =
- nf_evar evd (EConstr.Unsafe.to_constr (Termops.it_mkNamedLambda_or_LetIn (EConstr.of_constr def) rec_sign))
+ EConstr.Unsafe.to_constr (nf_evar evd (Termops.it_mkNamedLambda_or_LetIn (EConstr.of_constr def) rec_sign))
and typ =
- nf_evar evd (EConstr.Unsafe.to_constr (Termops.it_mkNamedProd_or_LetIn (EConstr.of_constr typ) rec_sign))
+ EConstr.Unsafe.to_constr (nf_evar evd (Termops.it_mkNamedProd_or_LetIn (EConstr.of_constr typ) rec_sign))
in
let evm = collect_evars_of_term evd def typ in
let evars, _, def, typ =
diff --git a/toplevel/himsg.ml b/toplevel/himsg.ml
index 3c2fe46b3b..851b879033 100644
--- a/toplevel/himsg.ml
+++ b/toplevel/himsg.ml
@@ -86,16 +86,18 @@ let rec contract3' env a b c = function
let to_unsafe_judgment j = on_judgment EConstr.Unsafe.to_constr j
let j_nf_betaiotaevar sigma j =
- { uj_val = Evarutil.nf_evar sigma (EConstr.Unsafe.to_constr j.uj_val);
- uj_type = EConstr.Unsafe.to_constr (Reductionops.nf_betaiota sigma j.uj_type) }
+ { uj_val = Evarutil.nf_evar sigma j.uj_val;
+ uj_type = Reductionops.nf_betaiota sigma j.uj_type }
let jv_nf_betaiotaevar sigma jl =
- Array.map (fun j -> on_judgment EConstr.of_constr (j_nf_betaiotaevar sigma j)) jl
+ Array.map (fun j -> j_nf_betaiotaevar sigma j) jl
(** Printers *)
let pr_lconstr c = quote (pr_lconstr c)
let pr_lconstr_env e s c = quote (pr_lconstr_env e s c)
+let pr_leconstr c = quote (pr_leconstr c)
+let pr_leconstr_env e s c = quote (pr_leconstr_env e s c)
let pr_ljudge_env e s c = let v,t = pr_ljudge_env e s c in (quote v,quote t)
(** A canonisation procedure for constr such that comparing there
@@ -152,7 +154,8 @@ let explicit_flags =
[print_implicits; print_coercions; print_no_symbol]; (** Then more! *)
[print_universes; print_implicits; print_coercions; print_no_symbol] (** and more! *) ]
-let pr_explicit env sigma t1 t2 = pr_explicit_aux env sigma t1 t2 explicit_flags
+let pr_explicit env sigma t1 t2 =
+ pr_explicit_aux env sigma (EConstr.to_constr sigma t1) (EConstr.to_constr sigma t2) explicit_flags
let pr_db env i =
try
@@ -263,9 +266,7 @@ let explain_number_branches env sigma cj expn =
str "expects " ++ int expn ++ str " branches."
let explain_ill_formed_branch env sigma c ci actty expty =
- let actty = EConstr.Unsafe.to_constr actty in
- let expty = EConstr.Unsafe.to_constr expty in
- let simp t = Reduction.nf_betaiota env (Evarutil.nf_evar sigma t) in
+ let simp t = Reductionops.nf_betaiota sigma (Evarutil.nf_evar sigma t) in
let env = make_all_name_different env in
let pc = pr_leconstr_env env sigma c in
let pa, pe = pr_explicit env sigma (simp actty) (simp expty) in
@@ -302,13 +303,11 @@ let explain_unification_error env sigma p1 p2 = function
| NotSameArgSize | NotSameHead | NoCanonicalStructure ->
(* Error speaks from itself *) []
| ConversionFailed (env,t1,t2) ->
- let t1 = EConstr.to_constr sigma t1 in
- let t2 = EConstr.to_constr sigma t2 in
- if Term.eq_constr t1 p1 && Term.eq_constr t2 p2 then [] else
+ if EConstr.eq_constr sigma t1 p1 && EConstr.eq_constr sigma t2 p2 then [] else
let env = make_all_name_different env in
let t1 = Evarutil.nf_evar sigma t1 in
let t2 = Evarutil.nf_evar sigma t2 in
- if not (Term.eq_constr t1 p1) || not (Term.eq_constr t2 p2) then
+ if not (EConstr.eq_constr sigma t1 p1) || not (EConstr.eq_constr sigma t2 p2) then
let t1, t2 = pr_explicit env sigma t1 t2 in
[str "cannot unify " ++ t1 ++ strbrk " and " ++ t2]
else []
@@ -317,8 +316,6 @@ let explain_unification_error env sigma p1 p2 = function
strbrk " refers to a metavariable - please report your example" ++
strbrk "at " ++ str Coq_config.wwwbugtracker ++ str "."]
| InstanceNotSameType (evk,env,t,u) ->
- let t = EConstr.to_constr sigma t in
- let u = EConstr.to_constr sigma u in
let t, u = pr_explicit env sigma t u in
[str "unable to find a well-typed instantiation for " ++
quote (pr_existential_key sigma evk) ++
@@ -331,11 +328,13 @@ let explain_unification_error env sigma p1 p2 = function
else
[str "universe inconsistency"]
| CannotSolveConstraint ((pb,env,t,u),e) ->
+ let t = EConstr.of_constr t in
+ let u = EConstr.of_constr u in
let t = Evarutil.nf_evar sigma t in
let u = Evarutil.nf_evar sigma u in
let env = make_all_name_different env in
- (strbrk "cannot satisfy constraint " ++ pr_lconstr_env env sigma t ++
- str " == " ++ pr_lconstr_env env sigma u)
+ (strbrk "cannot satisfy constraint " ++ pr_leconstr_env env sigma t ++
+ str " == " ++ pr_leconstr_env env sigma u)
:: aux t u e
| ProblemBeyondCapabilities ->
[]
@@ -349,10 +348,9 @@ let explain_actual_type env sigma j t reason =
let env = make_all_name_different env in
let j = j_nf_betaiotaevar sigma j in
let t = Reductionops.nf_betaiota sigma t in
- let t = EConstr.Unsafe.to_constr t in
(** Actually print *)
let pe = pr_ne_context_of (str "In environment") env sigma in
- let pc = pr_lconstr_env env sigma (Environ.j_val j) in
+ let pc = pr_leconstr_env env sigma (Environ.j_val j) in
let (pt, pct) = pr_explicit env sigma t (Environ.j_type j) in
let ppreason = explain_unification_error env sigma j.uj_type t reason in
pe ++
@@ -363,11 +361,9 @@ let explain_actual_type env sigma j t reason =
ppreason ++ str ".")
let explain_cant_apply_bad_type env sigma (n,exptyp,actualtyp) rator randl =
- let exptyp = EConstr.Unsafe.to_constr exptyp in
let randl = jv_nf_betaiotaevar sigma randl in
let exptyp = Evarutil.nf_evar sigma exptyp in
let actualtyp = Reductionops.nf_betaiota sigma actualtyp in
- let actualtyp = EConstr.Unsafe.to_constr actualtyp in
let rator = Evarutil.j_nf_evar sigma rator in
let env = make_all_name_different env in
let actualtyp, exptyp = pr_explicit env sigma actualtyp exptyp in
@@ -520,11 +516,9 @@ let explain_ill_formed_rec_body env sigma err names i fixenv vdefj =
let explain_ill_typed_rec_body env sigma i names vdefj vargs =
let vdefj = Evarutil.jv_nf_evar sigma vdefj in
- let vargs = Array.map EConstr.Unsafe.to_constr vargs in
- let vdefj = Array.map to_unsafe_judgment vdefj in
let vargs = Array.map (Evarutil.nf_evar sigma) vargs in
let env = make_all_name_different env in
- let pvd = pr_lconstr_env env sigma vdefj.(i).uj_val in
+ let pvd = pr_leconstr_env env sigma vdefj.(i).uj_val in
let pvdt, pv = pr_explicit env sigma vdefj.(i).uj_type vargs.(i) in
str "The " ++
(match vdefj with [|_|] -> mt () | _ -> pr_nth (i+1) ++ spc ()) ++
@@ -584,13 +578,13 @@ let rec explain_evar_kind env sigma evk ty = function
| Evar_kinds.SubEvar evk' ->
let evi = Evd.find sigma evk' in
let pc = match evi.evar_body with
- | Evar_defined c -> pr_lconstr_env env sigma (Evarutil.nf_evar sigma c)
+ | Evar_defined c -> pr_leconstr_env env sigma (Evarutil.nf_evar sigma (EConstr.of_constr c))
| Evar_empty -> assert false in
- let ty' = Evarutil.nf_evar sigma evi.evar_concl in
+ let ty' = Evarutil.nf_evar sigma (EConstr.of_constr evi.evar_concl) in
pr_existential_key sigma evk ++ str " of type " ++ ty ++
str " in the partial instance " ++ pc ++
str " found for " ++ explain_evar_kind env sigma evk'
- (pr_lconstr_env env sigma ty') (snd evi.evar_source)
+ (pr_leconstr_env env sigma ty') (snd evi.evar_source)
let explain_typeclass_resolution env sigma evi k =
match Typeclasses.class_of_constr sigma (EConstr.of_constr evi.evar_concl) with
@@ -655,7 +649,7 @@ let explain_cannot_unify_local env sigma m n subn =
let explain_refiner_cannot_generalize env sigma ty =
str "Cannot find a well-typed generalisation of the goal with type: " ++
- pr_lconstr_env env sigma ty ++ str "."
+ pr_leconstr_env env sigma ty ++ str "."
let explain_no_occurrence_found env sigma c id =
let c = EConstr.to_constr sigma c in
@@ -666,8 +660,8 @@ let explain_no_occurrence_found env sigma c id =
| None -> str"the current goal") ++ str "."
let explain_cannot_unify_binding_type env sigma m n =
- let pm = pr_lconstr_env env sigma m in
- let pn = pr_lconstr_env env sigma n in
+ let pm = pr_leconstr_env env sigma m in
+ let pn = pr_leconstr_env env sigma n in
str "This binding has type" ++ brk(1,1) ++ pm ++ spc () ++
str "which should be unifiable with" ++ brk(1,1) ++ pn ++ str "."
@@ -760,8 +754,6 @@ let explain_cannot_unify_occurrences env sigma nested ((cl2,pos2),t2) ((cl1,pos1
let ppreason = match e with
| None -> mt()
| Some (c1,c2,e) ->
- let c1 = EConstr.to_constr sigma c1 in
- let c2 = EConstr.to_constr sigma c2 in
explain_unification_error env sigma c1 c2 (Some e)
in
str "Found incompatible occurrences of the pattern" ++ str ":" ++
@@ -841,12 +833,16 @@ let explain_pretype_error env sigma err =
let actual = EConstr.Unsafe.to_constr actual in
let expect = EConstr.Unsafe.to_constr expect in
let env, actual, expect = contract2 env actual expect in
+ let actual = EConstr.of_constr actual in
+ let expect = EConstr.of_constr expect in
explain_unexpected_type env sigma actual expect
| NotProduct c -> explain_not_product env sigma c
| CannotUnify (m,n,e) ->
let m = EConstr.Unsafe.to_constr m in
let n = EConstr.Unsafe.to_constr n in
let env, m, n = contract2 env m n in
+ let m = EConstr.of_constr m in
+ let n = EConstr.of_constr n in
explain_cannot_unify env sigma m n e
| CannotUnifyLocal (m,n,sn) -> explain_cannot_unify_local env sigma m n sn
| CannotGeneralize ty -> explain_refiner_cannot_generalize env sigma ty
diff --git a/toplevel/obligations.ml b/toplevel/obligations.ml
index 6da2f82ab0..f4a786a73c 100644
--- a/toplevel/obligations.ml
+++ b/toplevel/obligations.ml
@@ -818,7 +818,7 @@ let rec string_of_list sep f = function
let solve_by_tac name evi t poly ctx =
let id = name in
- let concl = evi.evar_concl in
+ let concl = EConstr.of_constr evi.evar_concl in
(* spiwack: the status is dropped. *)
let (entry,_,ctx') = Pfedit.build_constant_by_tactic
id ~goal_kind:(goal_kind poly) ctx evi.evar_hyps concl (Tacticals.New.tclCOMPLETE t) in
@@ -936,7 +936,7 @@ let rec solve_obligation prg num tac =
Proof_global.make_terminator
(obligation_terminator prg.prg_name num guard hook auto) in
let hook ctx = Lemmas.mk_hook (obligation_hook prg obl num auto ctx) in
- let () = Lemmas.start_proof_univs ~sign:prg.prg_sign obl.obl_name kind evd obl.obl_type ~terminator hook in
+ let () = Lemmas.start_proof_univs ~sign:prg.prg_sign obl.obl_name kind evd (EConstr.of_constr obl.obl_type) ~terminator hook in
let _ = Pfedit.by !default_tactic in
Option.iter (fun tac -> Pfedit.set_end_tac tac) tac
diff --git a/toplevel/vernacentries.ml b/toplevel/vernacentries.ml
index 4376f51dc0..cf3da7e02e 100644
--- a/toplevel/vernacentries.ml
+++ b/toplevel/vernacentries.ml
@@ -59,7 +59,7 @@ let show_proof () =
(* spiwack: this would probably be cooler with a bit of polishing. *)
let p = Proof_global.give_me_the_proof () in
let pprf = Proof.partial_proof p in
- Feedback.msg_notice (Pp.prlist_with_sep Pp.fnl Printer.pr_constr pprf)
+ Feedback.msg_notice (Pp.prlist_with_sep Pp.fnl Printer.pr_econstr pprf)
let show_node () =
(* spiwack: I'm have little clue what this function used to do. I deactivated it,
@@ -459,7 +459,8 @@ let start_proof_and_print k l hook =
let env = Evd.evar_filtered_env evi in
try
let concl = Evarutil.nf_evars_universes sigma evi.Evd.evar_concl in
- if Evarutil.has_undefined_evars sigma (EConstr.of_constr concl) then raise Exit;
+ let concl = EConstr.of_constr concl in
+ if Evarutil.has_undefined_evars sigma concl then raise Exit;
let c, _, ctx =
Pfedit.build_by_tactic env (Evd.evar_universe_context sigma)
concl (Tacticals.New.tclCOMPLETE tac)
@@ -877,6 +878,7 @@ let vernac_set_used_variables e =
let env = Global.env () in
let tys =
List.map snd (Proof.initial_goals (Proof_global.give_me_the_proof ())) in
+ let tys = List.map EConstr.Unsafe.to_constr tys in
let l = Proof_using.process_expr env e tys in
let vars = Environ.named_context env in
List.iter (fun id ->
@@ -1901,7 +1903,7 @@ let vernac_check_guard () =
try
let { Evd.it=gl ; sigma=sigma } = Proof.V82.top_goal pts in
Inductiveops.control_only_guard (Goal.V82.env sigma gl)
- pfterm;
+ (EConstr.Unsafe.to_constr pfterm);
(str "The condition holds up to here")
with UserError(_,s) ->
(str ("Condition violated: ") ++s)