aboutsummaryrefslogtreecommitdiff
path: root/pretyping
diff options
context:
space:
mode:
authorEmilio Jesus Gallego Arias2019-11-21 15:38:39 +0100
committerEmilio Jesus Gallego Arias2019-11-21 15:38:39 +0100
commitd016f69818b30b75d186fb14f440b93b0518fc66 (patch)
tree32cd948273f79a2c01ad27b4ed0244ea60d7e2f9 /pretyping
parentb680b06b31c27751a7d551d95839aea38f7fbea1 (diff)
[coq] Untabify the whole ML codebase.
We also remove trailing whitespace. Script used: ```bash for i in `find . -name '*.ml' -or -name '*.mli' -or -name '*.mlg'`; do expand -i "$i" | sponge "$i"; sed -e's/[[:space:]]*$//' -i.bak "$i"; done ```
Diffstat (limited to 'pretyping')
-rw-r--r--pretyping/arguments_renaming.ml8
-rw-r--r--pretyping/cases.ml598
-rw-r--r--pretyping/cases.mli2
-rw-r--r--pretyping/cbv.ml28
-rw-r--r--pretyping/classops.ml14
-rw-r--r--pretyping/coercion.ml390
-rw-r--r--pretyping/coercion.mli2
-rw-r--r--pretyping/constr_matching.ml92
-rw-r--r--pretyping/detyping.ml236
-rw-r--r--pretyping/detyping.mli8
-rw-r--r--pretyping/evarconv.ml404
-rw-r--r--pretyping/evarconv.mli4
-rw-r--r--pretyping/evardefine.ml16
-rw-r--r--pretyping/evarsolve.ml124
-rw-r--r--pretyping/evarsolve.mli4
-rw-r--r--pretyping/find_subterm.ml6
-rw-r--r--pretyping/find_subterm.mli2
-rw-r--r--pretyping/glob_ops.ml6
-rw-r--r--pretyping/indrec.ml310
-rw-r--r--pretyping/inductiveops.mli2
-rw-r--r--pretyping/locusops.ml14
-rw-r--r--pretyping/nativenorm.ml76
-rw-r--r--pretyping/patternops.ml122
-rw-r--r--pretyping/pretyping.ml160
-rw-r--r--pretyping/program.ml2
-rw-r--r--pretyping/recordops.ml2
-rw-r--r--pretyping/recordops.mli4
-rw-r--r--pretyping/reductionops.ml370
-rw-r--r--pretyping/retyping.ml32
-rw-r--r--pretyping/tacred.ml434
-rw-r--r--pretyping/tacred.mli2
-rw-r--r--pretyping/typeclasses.ml86
-rw-r--r--pretyping/typeclasses.mli10
-rw-r--r--pretyping/typing.ml2
-rw-r--r--pretyping/unification.ml860
-rw-r--r--pretyping/unification.mli2
-rw-r--r--pretyping/vnorm.ml28
37 files changed, 2231 insertions, 2231 deletions
diff --git a/pretyping/arguments_renaming.ml b/pretyping/arguments_renaming.ml
index a86d237164..36f35a67c3 100644
--- a/pretyping/arguments_renaming.ml
+++ b/pretyping/arguments_renaming.ml
@@ -38,14 +38,14 @@ let classify_rename_args = function
| ReqLocal, _ -> Dispose
| ReqGlobal _, _ as o -> Substitute o
-let subst_rename_args (subst, (_, (r, names as orig))) =
+let subst_rename_args (subst, (_, (r, names as orig))) =
ReqLocal,
- let r' = fst (subst_global subst r) in
+ let r' = fst (subst_global subst r) in
if r==r' then orig else (r', names)
let discharge_rename_args = function
| _, (ReqGlobal (c, names), _ as req) when not (isVarRef c && Lib.is_in_section c) ->
- (try
+ (try
let vars = Lib.variable_section_segment_of_reference c in
let var_names = List.map (NamedDecl.get_id %> Name.mk_name) vars in
let names' = var_names @ names in
@@ -66,7 +66,7 @@ let inRenameArgs = declare_object { (default_object "RENAME-ARGUMENTS" ) with
let rename_arguments local r names =
let req = if local then ReqLocal else ReqGlobal (r, names) in
- Lib.add_anonymous_leaf (inRenameArgs (req, (r, names)))
+ Lib.add_anonymous_leaf (inRenameArgs (req, (r, names)))
let arguments_names r = GlobRef.Map.find r !name_table
diff --git a/pretyping/cases.ml b/pretyping/cases.ml
index a562204b54..aa6ec1c941 100644
--- a/pretyping/cases.ml
+++ b/pretyping/cases.ml
@@ -77,8 +77,8 @@ let list_try_compile f l =
| h::t ->
try f h
with UserError _ | TypeError _ | PretypeError _ | PatternMatchingError _ as e ->
- let e = CErrors.push e in
- aux (e::errors) t in
+ let e = CErrors.push e in
+ aux (e::errors) t in
aux [] l
let force_name =
@@ -183,7 +183,7 @@ and build_glob_pattern args = function
| Top -> args
| MakeConstructor (pci, rh) ->
glob_pattern_of_partial_history
- [DAst.make @@ PatCstr (pci, args, Anonymous)] rh
+ [DAst.make @@ PatCstr (pci, args, Anonymous)] rh
let complete_history = glob_pattern_of_partial_history []
@@ -292,15 +292,15 @@ let inductive_template env sigma tmloc ind =
let (sigma, _, evarl, _) =
List.fold_right
(fun decl (sigma, subst, evarl, n) ->
- match decl with
+ match decl with
| LocalAssum (na,ty) ->
let ty = EConstr.of_constr ty in
- let ty' = substl subst ty in
+ let ty' = substl subst ty in
let sigma, e =
Evarutil.new_evar env ~src:(hole_source n) ~typeclass_candidate:false sigma ty'
in
(sigma, e::subst,e::evarl,n+1)
- | LocalDef (na,b,ty) ->
+ | LocalDef (na,b,ty) ->
let b = EConstr.of_constr b in
(sigma, substl subst b::subst,evarl,n+1))
arsign (sigma, [], [], 1) in
@@ -431,11 +431,11 @@ let adjust_tomatch_to_pattern ~program_mode sigma pb ((current,typ),deps,dep) =
let sigma, indt = inductive_template !!(pb.env) sigma None ind in
let sigma, current =
if List.is_empty deps && isEvar sigma typ then
- (* Don't insert coercions if dependent; only solve evars *)
+ (* Don't insert coercions if dependent; only solve evars *)
match Evarconv.unify_leq_delay !!(pb.env) sigma indt typ with
| exception Evarconv.UnableToUnify _ -> sigma, current
| sigma -> sigma, current
- else
+ else
let sigma, j = Coercion.inh_conv_coerce_to ?loc ~program_mode true !!(pb.env) sigma (make_judge current typ) indt in
sigma, j.uj_val
in
@@ -464,9 +464,9 @@ let current_pattern eqn =
let remove_current_pattern eqn =
match eqn.patterns with
| pat::pats ->
- { eqn with
- patterns = pats;
- alias_stack = alias_of_pat pat :: eqn.alias_stack }
+ { eqn with
+ patterns = pats;
+ alias_stack = alias_of_pat pat :: eqn.alias_stack }
| [] -> anomaly (Pp.str "Empty list of patterns.")
let push_current_pattern ~program_mode sigma (cur,ty) eqn =
@@ -475,9 +475,9 @@ let push_current_pattern ~program_mode sigma (cur,ty) eqn =
| pat::pats ->
let r = Sorts.Relevant in (* TODO relevance *)
let _,rhs_env = push_rel ~hypnaming sigma (LocalDef (make_annot (alias_of_pat pat) r,cur,ty)) eqn.rhs.rhs_env in
- { eqn with
+ { eqn with
rhs = { eqn.rhs with rhs_env = rhs_env };
- patterns = pats }
+ patterns = pats }
| [] -> anomaly (Pp.str "Empty list of patterns.")
(* spiwack: like [push_current_pattern] but does not introduce an
@@ -515,22 +515,22 @@ let check_and_adjust_constructor env ind cstrs pat = match DAst.get pat with
(* Check it is constructor of the right type *)
let ind' = inductive_of_constructor cstr in
if eq_ind ind' ind then
- (* Check the constructor has the right number of args *)
- let ci = cstrs.(i-1) in
- let nb_args_constr = ci.cs_nargs in
- if Int.equal (List.length args) nb_args_constr then pat
- else
- try
- let args' = adjust_local_defs ?loc (args, List.rev ci.cs_args)
- in DAst.make ?loc @@ PatCstr (cstr, args', alias)
- with NotAdjustable ->
- error_wrong_numarg_constructor ?loc env cstr nb_args_constr
+ (* Check the constructor has the right number of args *)
+ let ci = cstrs.(i-1) in
+ let nb_args_constr = ci.cs_nargs in
+ if Int.equal (List.length args) nb_args_constr then pat
+ else
+ try
+ let args' = adjust_local_defs ?loc (args, List.rev ci.cs_args)
+ in DAst.make ?loc @@ PatCstr (cstr, args', alias)
+ with NotAdjustable ->
+ error_wrong_numarg_constructor ?loc env cstr nb_args_constr
else
- (* Try to insert a coercion *)
- try
- Coercion.inh_pattern_coerce_to ?loc env pat ind' ind
- with Not_found ->
- error_bad_constructor ?loc env cstr ind
+ (* Try to insert a coercion *)
+ try
+ Coercion.inh_pattern_coerce_to ?loc env pat ind' ind
+ with Not_found ->
+ error_bad_constructor ?loc env cstr ind
let check_all_variables env sigma typ mat =
List.iter
@@ -540,7 +540,7 @@ let check_all_variables env sigma typ mat =
| PatVar id -> ()
| PatCstr (cstr_sp,_,_) ->
let loc = pat.CAst.loc in
- error_bad_pattern ?loc env sigma cstr_sp typ)
+ error_bad_pattern ?loc env sigma cstr_sp typ)
mat
let check_unused_pattern env eqn =
@@ -553,7 +553,7 @@ let extract_rhs pb =
match pb.mat with
| [] -> user_err ~hdr:"build_leaf" (msg_may_need_inversion())
| eqn::_ ->
- set_used_pattern eqn;
+ set_used_pattern eqn;
eqn.rhs
(**********************************************************************)
@@ -762,14 +762,14 @@ let get_names avoid env sigma sign eqns =
let names3,_ =
List.fold_left2
(fun (l,avoid) d na ->
- let na =
- merge_name
+ let na =
+ merge_name
(fun decl ->
let na = get_name decl in
let t = get_type decl in
Name (next_name_away (named_hd env sigma t na) avoid))
- d na
- in
+ d na
+ in
(na::l,Id.Set.add (Name.get_id na) avoid))
([],allvars) (List.rev sign) names2 in
names3,aliasname
@@ -1012,9 +1012,9 @@ let add_assert_false_case pb tomatch =
in
[ { patterns = pats;
rhs = { rhs_env = pb.env;
- rhs_vars = Id.Set.empty;
- avoid_ids = Id.Set.empty;
- it = None };
+ rhs_vars = Id.Set.empty;
+ avoid_ids = Id.Set.empty;
+ it = None };
alias_stack = Anonymous::aliasnames;
eqn_loc = None;
used = ref false } ]
@@ -1226,20 +1226,20 @@ let group_equations pb ind current cstrs mat =
let _ =
List.fold_right (* To be sure it's from bottom to top *)
(fun eqn () ->
- let rest = remove_current_pattern eqn in
- let pat = current_pattern eqn in
+ let rest = remove_current_pattern eqn in
+ let pat = current_pattern eqn in
match DAst.get (check_and_adjust_constructor !!(pb.env) ind cstrs pat) with
- | PatVar name ->
- (* This is a default clause that we expand *)
- for i=1 to Array.length cstrs do
- let args = make_anonymous_patvars cstrs.(i-1).cs_nargs in
- brs.(i-1) <- (args, name, rest) :: brs.(i-1)
- done;
- if !only_default == None then only_default := Some true
- | PatCstr (((_,i)),args,name) ->
- (* This is a regular clause *)
- only_default := Some false;
- brs.(i-1) <- (args, name, rest) :: brs.(i-1)) mat () in
+ | PatVar name ->
+ (* This is a default clause that we expand *)
+ for i=1 to Array.length cstrs do
+ let args = make_anonymous_patvars cstrs.(i-1).cs_nargs in
+ brs.(i-1) <- (args, name, rest) :: brs.(i-1)
+ done;
+ if !only_default == None then only_default := Some true
+ | PatCstr (((_,i)),args,name) ->
+ (* This is a regular clause *)
+ only_default := Some false;
+ brs.(i-1) <- (args, name, rest) :: brs.(i-1)) mat () in
(brs,Option.default false !only_default)
(************************************************************************)
@@ -1254,7 +1254,7 @@ let rec generalize_problem names sigma pb = function
begin match d with
| LocalDef ({binder_name=Anonymous},_,_) -> pb', deps
| _ ->
- (* for better rendering *)
+ (* for better rendering *)
let d = RelDecl.map_type (fun c -> whd_betaiota sigma c) d in
let tomatch = lift_tomatch_stack 1 pb'.tomatch in
let tomatch = relocate_index_tomatch sigma (i+1) 1 tomatch in
@@ -1342,12 +1342,12 @@ let build_branch ~program_mode initial current realargs deps (realnames,curname)
List.map2
(fun (tm, (tmtyp,_), decl) deps ->
let na = RelDecl.get_name decl in
- let na = match curname, na with
- | Name _, Anonymous -> curname
- | Name _, Name _ -> na
- | Anonymous, _ ->
- if List.is_empty deps && pred_is_not_dep then Anonymous else force_name na in
- ((tm,tmtyp),deps,na))
+ let na = match curname, na with
+ | Name _, Anonymous -> curname
+ | Name _, Name _ -> na
+ | Anonymous, _ ->
+ if List.is_empty deps && pred_is_not_dep then Anonymous else force_name na in
+ ((tm,tmtyp),deps,na))
typs' (List.rev dep_sign) in
(* Do the specialization for the predicate *)
@@ -1417,24 +1417,24 @@ let compile ~program_mode sigma pb =
check_all_variables !!(pb.env) sigma typ pb.mat;
compile_all_variables initial tomatch sigma pb
| IsInd (_,(IndType(indf,realargs) as indt),names) ->
- let mind,_ = dest_ind_family indf in
+ let mind,_ = dest_ind_family indf in
let mind = Tacred.check_privacy !!(pb.env) mind in
let cstrs = get_constructors !!(pb.env) indf in
let arsign, _ = get_arity !!(pb.env) indf in
- let eqns,onlydflt = group_equations pb (fst mind) current cstrs pb.mat in
+ let eqns,onlydflt = group_equations pb (fst mind) current cstrs pb.mat in
let no_cstr = Int.equal (Array.length cstrs) 0 in
- if (not no_cstr || not (List.is_empty pb.mat)) && onlydflt then
+ if (not no_cstr || not (List.is_empty pb.mat)) && onlydflt then
compile_all_variables initial tomatch sigma pb
- else
- (* We generalize over terms depending on current term to match *)
+ else
+ (* We generalize over terms depending on current term to match *)
let pb,deps = generalize_problem (names,dep) sigma pb deps in
- (* We compile branches *)
+ (* We compile branches *)
let fold_br sigma eqn cstr =
compile_branch initial current realargs (names,dep) deps sigma pb arsign eqn cstr
in
let sigma, brvals = Array.fold_left2_map fold_br sigma eqns cstrs in
- (* We build the (elementary) case analysis *)
+ (* We build the (elementary) case analysis *)
let depstocheck = current::binding_vars_of_inductive sigma typ in
let brvals,tomatch,pred,inst =
postprocess_dependencies sigma depstocheck
@@ -1597,8 +1597,8 @@ let matx_of_eqns env eqns =
let rhs =
{ rhs_env = env;
rhs_vars = free_glob_vars initial_rhs;
- avoid_ids = avoid;
- it = Some initial_rhs } in
+ avoid_ids = avoid;
+ it = Some initial_rhs } in
{ patterns = initial_lpat;
alias_stack = [];
eqn_loc = loc;
@@ -1707,8 +1707,8 @@ let abstract_tycon ?loc env sigma subst tycon extenv t =
let ty = get_type_of !!env sigma t in
let sigma, ty = refresh_universes (Some false) !!env sigma ty in
let inst =
- List.map_i
- (fun i _ ->
+ List.map_i
+ (fun i _ ->
try list_assoc_in_triple i subst0 with Not_found -> mkRel i)
1 (rel_context !!env) in
let sigma, ev' = Evarutil.new_evar ~src ~typeclass_candidate:false !!env sigma ty in
@@ -1726,7 +1726,7 @@ let abstract_tycon ?loc env sigma subst tycon extenv t =
map_constr_with_full_binders sigma (push_binder sigma) aux x t
| (_, _, u) :: _ -> (* u is in extenv *)
let vl = List.map pi1 good in
- let ty =
+ let ty =
let ty = get_type_of !!env sigma t in
let sigma, res = refresh_universes (Some false) !!env !evdref ty in
evdref := sigma; res
@@ -1736,8 +1736,8 @@ let abstract_tycon ?loc env sigma subst tycon extenv t =
let sigma = !evdref in
let depvl = free_rels sigma ty in
let inst =
- List.map_i
- (fun i _ -> if Int.List.mem i vl then u else mkRel i) 1
+ List.map_i
+ (fun i _ -> if Int.List.mem i vl then u else mkRel i) 1
(rel_context !!extenv) in
let map a = match EConstr.kind sigma a with
| Rel n -> not (noccurn sigma n u) || Int.Set.mem n depvl
@@ -1759,7 +1759,7 @@ let abstract_tycon ?loc env sigma subst tycon extenv t =
let build_tycon ?loc env tycon_env s subst tycon extenv sigma t =
let sigma, t, tt = match t with
| None ->
- (* This is the situation we are building a return predicate and
+ (* This is the situation we are building a return predicate and
we are in an impossible branch *)
let n = Context.Rel.length (rel_context !!env) in
let n' = Context.Rel.length (rel_context !!tycon_env) in
@@ -1795,26 +1795,26 @@ let build_inversion_problem ~program_mode loc env sigma tms t =
match EConstr.kind sigma (whd_all !!env sigma t) with
| Construct (cstr,u) -> DAst.make (PatCstr (cstr,[],Anonymous)), acc
| App (f,v) when isConstruct sigma f ->
- let cstr,u = destConstruct sigma f in
+ let cstr,u = destConstruct sigma f in
let n = constructor_nrealargs !!env cstr in
- let l = List.lastn n (Array.to_list v) in
- let l,acc = List.fold_right_map reveal_pattern l acc in
- DAst.make (PatCstr (cstr,l,Anonymous)), acc
+ let l = List.lastn n (Array.to_list v) in
+ let l,acc = List.fold_right_map reveal_pattern l acc in
+ DAst.make (PatCstr (cstr,l,Anonymous)), acc
| _ -> make_patvar t acc in
let rec aux n env acc_sign tms acc =
match tms with
| [] -> [], acc_sign, acc
| (t, IsInd (_,IndType(indf,realargs),_)) :: tms ->
- let patl,acc = List.fold_right_map reveal_pattern realargs acc in
- let pat,acc = make_patvar t acc in
- let indf' = lift_inductive_family n indf in
+ let patl,acc = List.fold_right_map reveal_pattern realargs acc in
+ let pat,acc = make_patvar t acc in
+ let indf' = lift_inductive_family n indf in
let sign = make_arity_signature !!env sigma true indf' in
let patl = pat :: List.rev patl in
let patl,sign = recover_and_adjust_alias_names acc patl sign in
- let p = List.length patl in
+ let p = List.length patl in
let _,env' = push_rel_context ~hypnaming:KeepUserNameAndRenameExistingButSectionNames sigma sign env in
- let patl',acc_sign,acc = aux (n+p) env' (sign@acc_sign) tms acc in
- List.rev_append patl patl',acc_sign,acc
+ let patl',acc_sign,acc = aux (n+p) env' (sign@acc_sign) tms acc in
+ List.rev_append patl patl',acc_sign,acc
| (t, NotInd (bo,typ)) :: tms ->
let pat,acc = make_patvar t acc in
let d = LocalAssum (annotR (alias_of_pat pat),typ) in
@@ -1861,10 +1861,10 @@ let build_inversion_problem ~program_mode loc env sigma tms t =
used = ref false;
rhs = { rhs_env = pb_env;
(* we assume all vars are used; in practice we discard dependent
- vars so that the field rhs_vars is normally not used *)
+ vars so that the field rhs_vars is normally not used *)
rhs_vars = List.fold_left (fun accu (id, _) -> Id.Set.add id accu) Id.Set.empty subst;
avoid_ids = avoid;
- it = Some (lift n t) } } in
+ it = Some (lift n t) } } in
(* [catch_all] is a catch-all default clause of the auxiliary
pattern-matching, if needed: it will catch the clauses
of the original pattern-matching problem Xi whose type
@@ -1881,8 +1881,8 @@ let build_inversion_problem ~program_mode loc env sigma tms t =
used = ref false;
rhs = { rhs_env = pb_env;
rhs_vars = Id.Set.empty;
- avoid_ids = avoid0;
- it = None } } ] in
+ avoid_ids = avoid0;
+ it = None } } ] in
(* [pb] is the auxiliary pattern-matching serving as skeleton for the
return type of the original problem Xi *)
let s' = Retyping.get_sort_of !!env sigma t in
@@ -1917,7 +1917,7 @@ let extract_arity_signature ?(dolift=true) env0 tomatchl tmsign =
let get_one_sign n tm (na,t) =
match tm with
| NotInd (bo,typ) ->
- (match t with
+ (match t with
| None ->
let r = Sorts.Relevant in (* TODO relevance *)
let sign = match bo with
@@ -1928,19 +1928,19 @@ let extract_arity_signature ?(dolift=true) env0 tomatchl tmsign =
(str"Unexpected type annotation for a term of non inductive type."))
| IsInd (term,IndType(indf,realargs),_) ->
let indf' = if dolift then lift_inductive_family n indf else indf in
- let ((ind,u),_) = dest_ind_family indf' in
+ let ((ind,u),_) = dest_ind_family indf' in
let nrealargs_ctxt = inductive_nrealdecls env0 ind in
let arsign, inds = get_arity env0 indf' in
- let arsign = List.map (fun d -> map_rel_decl EConstr.of_constr d) arsign in
+ let arsign = List.map (fun d -> map_rel_decl EConstr.of_constr d) arsign in
let realnal =
- match t with
+ match t with
| Some {CAst.loc;v=(ind',realnal)} ->
- if not (eq_ind ind ind') then
- user_err ?loc (str "Wrong inductive type.");
- if not (Int.equal nrealargs_ctxt (List.length realnal)) then
- anomaly (Pp.str "Ill-formed 'in' clause in cases.");
+ if not (eq_ind ind ind') then
+ user_err ?loc (str "Wrong inductive type.");
+ if not (Int.equal nrealargs_ctxt (List.length realnal)) then
+ anomaly (Pp.str "Ill-formed 'in' clause in cases.");
List.rev realnal
- | None ->
+ | None ->
List.make nrealargs_ctxt Anonymous in
let r = Sorts.relevance_of_sort_family inds in
let t = EConstr.of_constr (build_dependent_inductive env0 indf') in
@@ -1948,7 +1948,7 @@ let extract_arity_signature ?(dolift=true) env0 tomatchl tmsign =
let rec buildrec n = function
| [],[] -> []
| (_,tm)::ltm, (_,x)::tmsign ->
- let l = get_one_sign n tm x in
+ let l = get_one_sign n tm x in
l :: buildrec (n + List.length l) (ltm,tmsign)
| _ -> assert false
in List.rev (buildrec 0 (tomatchl,tmsign))
@@ -1978,41 +1978,41 @@ let prepare_predicate_from_arsign_tycon ~program_mode env sigma loc tomatchs ars
let (rel_subst,var_subst), len =
List.fold_right2 (fun (tm, tmtype) sign (subst, len) ->
let signlen = List.length sign in
- match EConstr.kind sigma tm with
+ match EConstr.kind sigma tm with
| Rel _ | Var _ when Int.equal signlen 1 && dependent_rel_or_var sigma tm c
(* The term to match is not of a dependent type itself *) ->
(add_subst sigma tm len subst, len - signlen)
| Rel _ | Var _ when signlen > 1 (* The term is of a dependent type,
- maybe some variable in its type appears in the tycon. *) ->
- (match tmtype with
- NotInd _ -> (subst, len - signlen)
- | IsInd (_, IndType(indf,realargs),_) ->
- let subst, len =
- List.fold_left
- (fun (subst, len) arg ->
- match EConstr.kind sigma arg with
+ maybe some variable in its type appears in the tycon. *) ->
+ (match tmtype with
+ NotInd _ -> (subst, len - signlen)
+ | IsInd (_, IndType(indf,realargs),_) ->
+ let subst, len =
+ List.fold_left
+ (fun (subst, len) arg ->
+ match EConstr.kind sigma arg with
| Rel _ | Var _ when dependent_rel_or_var sigma arg c ->
(add_subst sigma arg len subst, pred len)
- | _ -> (subst, pred len))
- (subst, len) realargs
- in
- let subst =
+ | _ -> (subst, pred len))
+ (subst, len) realargs
+ in
+ let subst =
if dependent_rel_or_var sigma tm c && List.for_all (fun c -> isRel sigma c || isVar sigma c) realargs
then add_subst sigma tm len subst else subst
- in (subst, pred len))
- | _ -> (subst, len - signlen))
+ in (subst, pred len))
+ | _ -> (subst, len - signlen))
(List.rev tomatchs) arsign (([],[]), nar)
in
let rec predicate lift c =
match EConstr.kind sigma c with
| Rel n when n > lift ->
- (try
- (* Make the predicate dependent on the matched variable *)
+ (try
+ (* Make the predicate dependent on the matched variable *)
let idx = Int.List.assoc (n - lift) rel_subst in
- mkRel (idx + lift)
- with Not_found ->
+ mkRel (idx + lift)
+ with Not_found ->
(* A variable that is not matched, lift over the arsign *)
- mkRel (n + nar))
+ mkRel (n + nar))
| Var id ->
(try
(* Make the predicate dependent on the matched variable *)
@@ -2022,7 +2022,7 @@ let prepare_predicate_from_arsign_tycon ~program_mode env sigma loc tomatchs ars
(* A variable that is not matched *)
c)
| _ ->
- EConstr.map_with_binders sigma succ predicate lift c
+ EConstr.map_with_binders sigma succ predicate lift c
in
assert (len == 0);
let p = predicate 0 c in
@@ -2146,52 +2146,52 @@ let constr_of_pat env sigma arsign pat avoid =
let loc = pat.CAst.loc in
match DAst.get pat with
| PatVar name ->
- let name, avoid = match name with
- Name n -> name, avoid
- | Anonymous ->
- let previd, id = prime avoid (Name (Id.of_string "wildcard")) in
- Name id, Id.Set.add id avoid
+ let name, avoid = match name with
+ Name n -> name, avoid
+ | Anonymous ->
+ let previd, id = prime avoid (Name (Id.of_string "wildcard")) in
+ Name id, Id.Set.add id avoid
in
let r = Sorts.Relevant in (* TODO relevance *)
(sigma, (DAst.make ?loc @@ PatVar name), [LocalAssum (make_annot name r, ty)] @ realargs, mkRel 1, ty,
(List.map (fun x -> mkRel 1) realargs), 1, avoid)
| PatCstr (((_, i) as cstr),args,alias) ->
- let cind = inductive_of_constructor cstr in
- let IndType (indf, _) =
+ let cind = inductive_of_constructor cstr in
+ let IndType (indf, _) =
try find_rectype env sigma (lift (-(List.length realargs)) ty)
with Not_found -> error_case_not_inductive env sigma
{uj_val = ty; uj_type = Typing.unsafe_type_of env sigma ty}
- in
- let (ind,u), params = dest_ind_family indf in
- let params = List.map EConstr.of_constr params in
- if not (eq_ind ind cind) then error_bad_constructor ?loc env cstr ind;
- let cstrs = get_constructors env indf in
- let ci = cstrs.(i-1) in
- let nb_args_constr = ci.cs_nargs in
- assert (Int.equal nb_args_constr (List.length args));
+ in
+ let (ind,u), params = dest_ind_family indf in
+ let params = List.map EConstr.of_constr params in
+ if not (eq_ind ind cind) then error_bad_constructor ?loc env cstr ind;
+ let cstrs = get_constructors env indf in
+ let ci = cstrs.(i-1) in
+ let nb_args_constr = ci.cs_nargs in
+ assert (Int.equal nb_args_constr (List.length args));
let sigma, patargs, args, sign, env, n, m, avoid =
- List.fold_right2
+ List.fold_right2
(fun decl ua (sigma, patargs, args, sign, env, n, m, avoid) ->
let t = EConstr.of_constr (RelDecl.get_type decl) in
let sigma, pat', sign', arg', typ', argtypargs, n', avoid =
- let liftt = liftn (List.length sign) (succ (List.length args)) t in
+ let liftt = liftn (List.length sign) (succ (List.length args)) t in
typ env sigma (substl args liftt, []) ua avoid
- in
- let args' = arg' :: List.map (lift n') args in
+ in
+ let args' = arg' :: List.map (lift n') args in
let env' = EConstr.push_rel_context sign' env in
(sigma, pat' :: patargs, args', sign' @ sign, env', n' + n, succ m, avoid))
ci.cs_args (List.rev args) (sigma, [], [], [], env, 0, 0, avoid)
- in
- let args = List.rev args in
- let patargs = List.rev patargs in
- let pat' = DAst.make ?loc @@ PatCstr (cstr, patargs, alias) in
- let cstr = mkConstructU (on_snd EInstance.make ci.cs_cstr) in
- let app = applist (cstr, List.map (lift (List.length sign)) params) in
- let app = applist (app, args) in
+ in
+ let args = List.rev args in
+ let patargs = List.rev patargs in
+ let pat' = DAst.make ?loc @@ PatCstr (cstr, patargs, alias) in
+ let cstr = mkConstructU (on_snd EInstance.make ci.cs_cstr) in
+ let app = applist (cstr, List.map (lift (List.length sign)) params) in
+ let app = applist (app, args) in
let apptype = Retyping.get_type_of env sigma app in
let IndType (indf, realargs) = find_rectype env sigma apptype in
- match alias with
- Anonymous ->
+ match alias with
+ Anonymous ->
sigma, pat', sign, app, apptype, realargs, n, avoid
| Name id ->
let _, inds = get_arity env indf in
@@ -2199,19 +2199,19 @@ let constr_of_pat env sigma arsign pat avoid =
let sign = LocalAssum (make_annot alias r, lift m ty) :: sign in
let avoid = Id.Set.add id avoid in
let sigma, sign, i, avoid =
- try
+ try
let env = EConstr.push_rel_context sign env in
let sigma = unify_leq_delay (EConstr.push_rel_context sign env) sigma
(lift (succ m) ty) (lift 1 apptype) in
let sigma, eq_t = mk_eq sigma (lift (succ m) ty)
- (mkRel 1) (* alias *)
- (lift 1 app) (* aliased term *)
- in
+ (mkRel 1) (* alias *)
+ (lift 1 app) (* aliased term *)
+ in
let neq = eq_id avoid id in
(* if we ever allow using a SProp-typed coq_eq_ind this relevance will be wrong *)
sigma, LocalDef (nameR neq, mkRel 0, eq_t) :: sign, 2, Id.Set.add neq avoid
with Evarconv.UnableToUnify _ -> sigma, sign, 1, avoid
- in
+ in
(* Mark the equality as a hole *)
sigma, pat', sign, lift i app, lift i apptype, realargs, n + i, avoid
in
@@ -2233,23 +2233,23 @@ match EConstr.kind sigma t with
let rels_of_patsign sigma =
List.map (fun decl ->
- match decl with
+ match decl with
| LocalDef (na,t',t) when is_topvar sigma t' -> LocalAssum (na,t)
- | _ -> decl)
+ | _ -> decl)
let vars_of_ctx sigma ctx =
let _, y =
List.fold_right (fun decl (prev, vars) ->
match decl with
| LocalDef (na,t',t) when is_topvar sigma t' ->
- prev,
- (DAst.make @@ GApp (
- (DAst.make @@ GRef (delayed_force coq_eq_refl_ref, None)),
+ prev,
+ (DAst.make @@ GApp (
+ (DAst.make @@ GRef (delayed_force coq_eq_refl_ref, None)),
[hole na.binder_name; DAst.make @@ GVar prev])) :: vars
- | _ ->
- match RelDecl.get_name decl with
- Anonymous -> invalid_arg "vars_of_ctx"
- | Name n -> n, (DAst.make @@ GVar n) :: vars)
+ | _ ->
+ match RelDecl.get_name decl with
+ Anonymous -> invalid_arg "vars_of_ctx"
+ | Name n -> n, (DAst.make @@ GVar n) :: vars)
ctx (Id.of_string "vars_of_ctx_error", [])
in List.rev y
@@ -2258,13 +2258,13 @@ let rec is_included x y =
| PatVar _, _ -> true
| _, PatVar _ -> true
| PatCstr ((_, i), args, alias), PatCstr ((_, i'), args', alias') ->
- if Int.equal i i' then List.for_all2 is_included args args'
- else false
+ if Int.equal i i' then List.for_all2 is_included args args'
+ else false
let lift_rel_context n l =
map_rel_context_with_binders (liftn n) l
-(* liftsign is the current pattern's complete signature length.
+(* liftsign is the current pattern's complete signature length.
Hence pats is already typed in its
full signature. However prevpatterns are in the original one signature per pattern form.
*)
@@ -2273,38 +2273,38 @@ let build_ineqs sigma prevpatterns pats liftsign =
List.fold_left
(fun (sigma, c) eqnpats ->
let sigma, acc = List.fold_left2
- (* ppat is the pattern we are discriminating against, curpat is the current one. *)
+ (* ppat is the pattern we are discriminating against, curpat is the current one. *)
(fun (sigma, acc) (ppat_sign, ppat_c, (ppat_ty, ppat_tyargs), ppat)
- (curpat_sign, curpat_c, (curpat_ty, curpat_tyargs), curpat) ->
- match acc with
+ (curpat_sign, curpat_c, (curpat_ty, curpat_tyargs), curpat) ->
+ match acc with
None -> sigma, None
- | Some (sign, len, n, c) -> (* FixMe: do not work with ppat_args *)
- if is_included curpat ppat then
- (* Length of previous pattern's signature *)
- let lens = List.length ppat_sign in
- (* Accumulated length of previous pattern's signatures *)
- let len' = lens + len in
+ | Some (sign, len, n, c) -> (* FixMe: do not work with ppat_args *)
+ if is_included curpat ppat then
+ (* Length of previous pattern's signature *)
+ let lens = List.length ppat_sign in
+ (* Accumulated length of previous pattern's signatures *)
+ let len' = lens + len in
let sigma, c' =
papp sigma coq_eq_ind
[| lift (len' + liftsign) curpat_ty;
liftn (len + liftsign) (succ lens) ppat_c ;
lift len' curpat_c |]
in
- let acc =
- ((* Jump over previous prevpat signs *)
- lift_rel_context len ppat_sign @ sign,
- len',
- succ n, (* nth pattern *)
+ let acc =
+ ((* Jump over previous prevpat signs *)
+ lift_rel_context len ppat_sign @ sign,
+ len',
+ succ n, (* nth pattern *)
c' :: List.map (lift lens (* Jump over this prevpat signature *)) c)
in sigma, Some acc
else sigma, None)
(sigma, Some ([], 0, 0, [])) eqnpats pats
- in match acc with
+ in match acc with
None -> sigma, c
- | Some (sign, len, _, c') ->
+ | Some (sign, len, _, c') ->
let sigma, conj = mk_coq_and sigma c' in
let sigma, neg = mk_coq_not sigma conj in
- let conj = it_mkProd_or_LetIn neg (lift_rel_context liftsign sign) in
+ let conj = it_mkProd_or_LetIn neg (lift_rel_context liftsign sign) in
sigma, conj :: c)
(sigma, []) prevpatterns
in match diffs with [] -> sigma, None
@@ -2316,78 +2316,78 @@ let constrs_of_pats typing_fun env sigma eqns tomatchs sign neqs arity =
List.fold_left
(fun (sigma, branches, eqns, prevpatterns) eqn ->
let sigma, _, newpatterns, pats =
- List.fold_left2
+ List.fold_left2
(fun (sigma, idents, newpatterns, pats) pat arsign ->
let sigma, pat', cpat, idents = constr_of_pat !!env sigma arsign pat idents in
(sigma, idents, pat' :: newpatterns, cpat :: pats))
(sigma, Id.Set.empty, [], []) eqn.patterns sign
- in
- let newpatterns = List.rev newpatterns and opats = List.rev pats in
- let rhs_rels, pats, signlen =
- List.fold_left
- (fun (renv, pats, n) (sign,c, (s, args), p) ->
- (* Recombine signatures and terms of all of the row's patterns *)
- let sign' = lift_rel_context n sign in
- let len = List.length sign' in
- (sign' @ renv,
- (* lift to get outside of previous pattern's signatures. *)
- (sign', liftn n (succ len) c,
- (s, List.map (liftn n (succ len)) args), p) :: pats,
- len + n))
- ([], [], 0) opats in
- let pats, _ = List.fold_left
- (* lift to get outside of past patterns to get terms in the combined environment. *)
- (fun (pats, n) (sign, c, (s, args), p) ->
- let len = List.length sign in
+ in
+ let newpatterns = List.rev newpatterns and opats = List.rev pats in
+ let rhs_rels, pats, signlen =
+ List.fold_left
+ (fun (renv, pats, n) (sign,c, (s, args), p) ->
+ (* Recombine signatures and terms of all of the row's patterns *)
+ let sign' = lift_rel_context n sign in
+ let len = List.length sign' in
+ (sign' @ renv,
+ (* lift to get outside of previous pattern's signatures. *)
+ (sign', liftn n (succ len) c,
+ (s, List.map (liftn n (succ len)) args), p) :: pats,
+ len + n))
+ ([], [], 0) opats in
+ let pats, _ = List.fold_left
+ (* lift to get outside of past patterns to get terms in the combined environment. *)
+ (fun (pats, n) (sign, c, (s, args), p) ->
+ let len = List.length sign in
((rels_of_patsign sigma sign, lift n c,
- (s, List.map (lift n) args), p) :: pats, len + n))
- ([], 0) pats
- in
+ (s, List.map (lift n) args), p) :: pats, len + n))
+ ([], 0) pats
+ in
let sigma, ineqs = build_ineqs sigma prevpatterns pats signlen in
let rhs_rels' = rels_of_patsign sigma rhs_rels in
let _signenv,_ = push_rel_context ~hypnaming:ProgramNaming sigma rhs_rels' env in
- let arity =
- let args, nargs =
- List.fold_right (fun (sign, c, (_, args), _) (allargs,n) ->
- (args @ c :: allargs, List.length args + succ n))
- pats ([], 0)
- in
- let args = List.rev args in
- substl args (liftn signlen (succ nargs) arity)
- in
+ let arity =
+ let args, nargs =
+ List.fold_right (fun (sign, c, (_, args), _) (allargs,n) ->
+ (args @ c :: allargs, List.length args + succ n))
+ pats ([], 0)
+ in
+ let args = List.rev args in
+ substl args (liftn signlen (succ nargs) arity)
+ in
let r = Sorts.Relevant in (* TODO relevance *)
let rhs_rels', tycon =
- let neqs_rels, arity =
- match ineqs with
- | None -> [], arity
- | Some ineqs ->
+ let neqs_rels, arity =
+ match ineqs with
+ | None -> [], arity
+ | Some ineqs ->
[LocalAssum (make_annot Anonymous r, ineqs)], lift 1 arity
- in
+ in
let eqs_rels, arity = decompose_prod_n_assum sigma neqs arity in
- eqs_rels @ neqs_rels @ rhs_rels', arity
- in
+ eqs_rels @ neqs_rels @ rhs_rels', arity
+ in
let _,rhs_env = push_rel_context ~hypnaming:ProgramNaming sigma rhs_rels' env in
let sigma, j = typing_fun (mk_tycon tycon) rhs_env sigma eqn.rhs.it in
- let bbody = it_mkLambda_or_LetIn j.uj_val rhs_rels'
- and btype = it_mkProd_or_LetIn j.uj_type rhs_rels' in
+ let bbody = it_mkLambda_or_LetIn j.uj_val rhs_rels'
+ and btype = it_mkProd_or_LetIn j.uj_type rhs_rels' in
let sigma, _btype = Typing.type_of !!env sigma bbody in
- let branch_name = Id.of_string ("program_branch_" ^ (string_of_int !i)) in
+ let branch_name = Id.of_string ("program_branch_" ^ (string_of_int !i)) in
let branch_decl = LocalDef (make_annot (Name branch_name) r, lift !i bbody, lift !i btype) in
- let branch =
- let bref = DAst.make @@ GVar branch_name in
+ let branch =
+ let bref = DAst.make @@ GVar branch_name in
match vars_of_ctx sigma rhs_rels with
- [] -> bref
- | l -> DAst.make @@ GApp (bref, l)
- in
- let branch = match ineqs with
- Some _ -> DAst.make @@ GApp (branch, [ hole Anonymous ])
- | None -> branch
- in
- incr i;
- let rhs = { eqn.rhs with it = Some branch } in
+ [] -> bref
+ | l -> DAst.make @@ GApp (bref, l)
+ in
+ let branch = match ineqs with
+ Some _ -> DAst.make @@ GApp (branch, [ hole Anonymous ])
+ | None -> branch
+ in
+ incr i;
+ let rhs = { eqn.rhs with it = Some branch } in
(sigma, branch_decl :: branches,
- { eqn with patterns = newpatterns; rhs = rhs } :: eqns,
- opats :: prevpatterns))
+ { eqn with patterns = newpatterns; rhs = rhs } :: eqns,
+ opats :: prevpatterns))
(sigma, [], [], []) eqns
in
sigma, x, y
@@ -2404,8 +2404,8 @@ let constrs_of_pats typing_fun env sigma eqns tomatchs sign neqs arity =
let lift_ctx n ctx =
let ctx', _ =
- List.fold_right (fun (c, t) (ctx, n') ->
- (liftn n n' c, liftn_tomatch_type n n' t) :: ctx, succ n')
+ List.fold_right (fun (c, t) (ctx, n') ->
+ (liftn n n' c, liftn_tomatch_type n n' t) :: ctx, succ n')
ctx ([], 0)
in ctx'
@@ -2414,17 +2414,17 @@ let abstract_tomatch env sigma tomatchs tycon =
let prev, ctx, names, tycon =
List.fold_left
(fun (prev, ctx, names, tycon) (c, t) ->
- let lenctx = List.length ctx in
- match EConstr.kind sigma c with
- Rel n -> (lift lenctx c, lift_tomatch_type lenctx t) :: prev, ctx, names, tycon
- | _ ->
- let tycon = Option.map
- (fun t -> subst_term sigma (lift 1 c) (lift 1 t)) tycon in
+ let lenctx = List.length ctx in
+ match EConstr.kind sigma c with
+ Rel n -> (lift lenctx c, lift_tomatch_type lenctx t) :: prev, ctx, names, tycon
+ | _ ->
+ let tycon = Option.map
+ (fun t -> subst_term sigma (lift 1 c) (lift 1 t)) tycon in
let name = next_ident_away (Id.of_string "filtered_var") names in
let r = Sorts.Relevant in (* TODO relevance *)
- (mkRel 1, lift_tomatch_type (succ lenctx) t) :: lift_ctx 1 prev,
+ (mkRel 1, lift_tomatch_type (succ lenctx) t) :: lift_ctx 1 prev,
LocalDef (make_annot (Name name) r, lift lenctx c, lift lenctx $ type_of_tomatch t) :: ctx,
- Id.Set.add name names, tycon)
+ Id.Set.add name names, tycon)
([], [], Id.Set.empty, tycon) tomatchs
in List.rev prev, ctx, tycon
@@ -2436,26 +2436,26 @@ let build_dependent_signature env sigma avoid tomatchs arsign =
let sigma, eqs, neqs, refls, slift, arsign' =
List.fold_left2
(fun (sigma, eqs, neqs, refl_args, slift, arsigns) (tm, ty) arsign ->
- (* The accumulator:
- previous eqs,
- number of previous eqs,
- lift to get outside eqs and in the introduced variables ('as' and 'in'),
- new arity signatures
- *)
- match ty with
- | IsInd (ty, IndType (indf, args), _) when List.length args > 0 ->
- (* Build the arity signature following the names in matched terms
- as much as possible *)
- let argsign = List.tl arsign in (* arguments in inverse application order *)
- let app_decl = List.hd arsign in (* The matched argument *)
- let appn = RelDecl.get_name app_decl in
- let appt = RelDecl.get_type app_decl in
- let argsign = List.rev argsign in (* arguments in application order *)
+ (* The accumulator:
+ previous eqs,
+ number of previous eqs,
+ lift to get outside eqs and in the introduced variables ('as' and 'in'),
+ new arity signatures
+ *)
+ match ty with
+ | IsInd (ty, IndType (indf, args), _) when List.length args > 0 ->
+ (* Build the arity signature following the names in matched terms
+ as much as possible *)
+ let argsign = List.tl arsign in (* arguments in inverse application order *)
+ let app_decl = List.hd arsign in (* The matched argument *)
+ let appn = RelDecl.get_name app_decl in
+ let appt = RelDecl.get_type app_decl in
+ let argsign = List.rev argsign in (* arguments in application order *)
let sigma, env', nargeqs, argeqs, refl_args, slift, argsign' =
- List.fold_left2
+ List.fold_left2
(fun (sigma, env, nargeqs, argeqs, refl_args, slift, argsign') arg decl ->
- let name = RelDecl.get_name decl in
- let t = RelDecl.get_type decl in
+ let name = RelDecl.get_name decl in
+ let t = RelDecl.get_type decl in
let argt = Retyping.get_type_of env sigma arg in
let sigma, eq, refl_arg =
if Reductionops.is_conv env sigma argt t then
@@ -2466,7 +2466,7 @@ let build_dependent_signature env sigma avoid tomatchs arsign =
in
let sigma, refl = mk_eq_refl sigma argt arg in
sigma, eq, refl
- else
+ else
let sigma, eq =
mk_JMeq sigma (lift (nargeqs + slift) t)
(mkRel (nargeqs + slift))
@@ -2475,43 +2475,43 @@ let build_dependent_signature env sigma avoid tomatchs arsign =
in
let sigma, refl = mk_JMeq_refl sigma argt arg in
(sigma, eq, refl)
- in
- let previd, id =
- let name =
+ in
+ let previd, id =
+ let name =
match EConstr.kind sigma arg with
- Rel n -> RelDecl.get_name (lookup_rel n env)
- | _ -> name
- in
- make_prime avoid name
- in
+ Rel n -> RelDecl.get_name (lookup_rel n env)
+ | _ -> name
+ in
+ make_prime avoid name
+ in
(sigma, env, succ nargeqs,
(LocalAssum (make_annot (Name (eq_id avoid previd)) Sorts.Relevant, eq)) :: argeqs,
refl_arg :: refl_args,
- pred slift,
- RelDecl.set_name (Name id) decl :: argsign'))
+ pred slift,
+ RelDecl.set_name (Name id) decl :: argsign'))
(sigma, env, neqs, [], [], slift, []) args argsign
- in
+ in
let sigma, eq =
mk_JMeq sigma
(lift (nargeqs + slift) appt)
(mkRel (nargeqs + slift))
(lift (nargeqs + nar) ty)
(lift (nargeqs + nar) tm)
- in
+ in
let sigma, refl_eq = mk_JMeq_refl sigma ty tm in
- let previd, id = make_prime avoid appn in
+ let previd, id = make_prime avoid appn in
(sigma, (LocalAssum (make_annot (Name (eq_id avoid previd)) Sorts.Relevant, eq) :: argeqs) :: eqs,
succ nargeqs,
- refl_eq :: refl_args,
- pred slift,
- ((RelDecl.set_name (Name id) app_decl :: argsign') :: arsigns))
-
- | _ -> (* Non dependent inductive or not inductive, just use a regular equality *)
- let decl = match arsign with [x] -> x | _ -> assert(false) in
- let name = RelDecl.get_name decl in
- let previd, id = make_prime avoid name in
- let arsign' = RelDecl.set_name (Name id) decl in
- let tomatch_ty = type_of_tomatch ty in
+ refl_eq :: refl_args,
+ pred slift,
+ ((RelDecl.set_name (Name id) app_decl :: argsign') :: arsigns))
+
+ | _ -> (* Non dependent inductive or not inductive, just use a regular equality *)
+ let decl = match arsign with [x] -> x | _ -> assert(false) in
+ let name = RelDecl.get_name decl in
+ let previd, id = make_prime avoid name in
+ let arsign' = RelDecl.set_name (Name id) decl in
+ let tomatch_ty = type_of_tomatch ty in
let sigma, eq =
mk_eq sigma (lift nar tomatch_ty)
(mkRel slift) (lift nar tm)
@@ -2555,7 +2555,7 @@ let compile_program_cases ?loc style (typing_function, sigma) tycon env
(* The arity signature *)
let arsign = extract_arity_signature ~dolift:false !!env tomatchs tomatchl in
(* Build the dependent arity signature, the equalities which makes
- the first part of the predicate and their instantiations. *)
+ the first part of the predicate and their instantiations. *)
let avoid = Id.Set.empty in
build_dependent_signature !!env sigma avoid tomatchs arsign
@@ -2603,12 +2603,12 @@ let compile_program_cases ?loc style (typing_function, sigma) tycon env
let typs =
List.map (fun (c,d) -> (c,extract_inductive_data !!env sigma d,d)) typs in
-
+
let dep_sign =
find_dependencies_signature sigma
(List.make (List.length typs) true)
typs in
-
+
let typs' =
List.map3
(fun (tm,tmt) deps (na,realnames) ->
@@ -2616,9 +2616,9 @@ let compile_program_cases ?loc style (typing_function, sigma) tycon env
let tmt = set_tomatch_realnames realnames tmt in
((tm,tmt),deps,na))
tomatchs dep_sign nal in
-
+
let initial_pushed = List.map (fun x -> Pushed (true,x)) typs' in
-
+
let typing_function tycon env sigma = function
| Some t -> typing_function tycon env sigma t
| None -> use_unit_judge env sigma in
@@ -2672,8 +2672,8 @@ let compile_cases ?loc ~program_mode style (typing_fun, sigma) tycon env (predop
(* TODO relevance *)
let out_tmt na = function NotInd (None,t) -> LocalAssum (na,t)
- | NotInd (Some b,t) -> LocalDef (na,b,t)
- | IsInd (typ,_,_) -> LocalAssum (na,typ) in
+ | NotInd (Some b,t) -> LocalDef (na,b,t)
+ | IsInd (typ,_,_) -> LocalAssum (na,typ) in
let typs = List.map2 (fun (na,_) (tm,tmt) -> (tm,out_tmt (make_annot na Sorts.Relevant) tmt)) nal tomatchs in
let typs =
@@ -2701,13 +2701,13 @@ let compile_cases ?loc ~program_mode style (typing_fun, sigma) tycon env (predop
let pb =
{ env = env;
- pred = pred;
- tomatch = initial_pushed;
- history = start_history (List.length initial_pushed);
- mat = matx;
- caseloc = loc;
- casestyle = style;
- typing_function = typing_fun } in
+ pred = pred;
+ tomatch = initial_pushed;
+ history = start_history (List.length initial_pushed);
+ mat = matx;
+ caseloc = loc;
+ casestyle = style;
+ typing_function = typing_fun } in
let sigma, j = compile ~program_mode sigma pb in
diff --git a/pretyping/cases.mli b/pretyping/cases.mli
index 59cb1ca4ab..3db019d827 100644
--- a/pretyping/cases.mli
+++ b/pretyping/cases.mli
@@ -46,7 +46,7 @@ val compile_cases :
GlobEnv.t -> glob_constr option * tomatch_tuples * cases_clauses ->
evar_map * unsafe_judgment
-val constr_of_pat :
+val constr_of_pat :
Environ.env ->
Evd.evar_map ->
rel_context ->
diff --git a/pretyping/cbv.ml b/pretyping/cbv.ml
index c78f791a5a..2b7ccbbcad 100644
--- a/pretyping/cbv.ml
+++ b/pretyping/cbv.ml
@@ -384,7 +384,7 @@ and apply_env env t =
(* The main recursive functions
*
- * Go under applications and cases/projections (pushed in the stack),
+ * Go under applications and cases/projections (pushed in the stack),
* expand head constants or substitued de Bruijn, and try to a make a
* constructor, a lambda or a fixp appear in the head. If not, it is a value
* and is completely computed here. The head redexes are NOT reduced:
@@ -403,16 +403,16 @@ let rec norm_head info env t stack =
norm_head info env head (stack_app nargs stack)
| Case (ci,p,c,v) -> norm_head info env c (CASE(p,v,ci,env,stack))
| Cast (ct,_,_) -> norm_head info env ct stack
-
- | Proj (p, c) ->
+
+ | Proj (p, c) ->
let p' =
if red_set info.reds (fCONST (Projection.constant p))
&& red_set info.reds fBETA
then Projection.unfold p
else p
- in
+ in
norm_head info env c (PROJ (p', stack))
-
+
(* constants, axioms
* the first pattern is CRUCIAL, n=0 happens very often:
* when reducing closed terms, n is always 0 *)
@@ -437,10 +437,10 @@ let rec norm_head info env t stack =
(* New rule: for Cbv, Delta does not apply to locally bound variables
or red_set info.reds fDELTA
*)
- let env' = subs_cons ([|cbv_stack_term info TOP env b|],env) in
+ let env' = subs_cons ([|cbv_stack_term info TOP env b|],env) in
norm_head info env' c stack
else
- (CBN(t,env), stack) (* Should we consider a commutative cut ? *)
+ (CBN(t,env), stack) (* Should we consider a commutative cut ? *)
| Evar ev ->
(match Reductionops.safe_evar_value info.sigma ev with
@@ -517,7 +517,7 @@ and cbv_stack_value info env = function
(* constructor in a Case -> IOTA *)
| (CONSTR(((sp,n),u),[||]), APP(args,CASE(_,br,ci,env,stk)))
when red_set info.reds fMATCH ->
- let cargs =
+ let cargs =
Array.sub args ci.ci_npar (Array.length args - ci.ci_npar) in
cbv_stack_term info (stack_app cargs stk) env br.(n-1)
@@ -530,7 +530,7 @@ and cbv_stack_value info env = function
| (CONSTR(((sp,n),u),[||]), APP(args,PROJ(p,stk)))
when red_set info.reds fMATCH && Projection.unfolded p ->
let arg = args.(Projection.npars p + Projection.arg p) in
- cbv_stack_value info env (strip_appl arg stk)
+ cbv_stack_value info env (strip_appl arg stk)
(* may be reduced later by application *)
| (FIXP(fix,env,[||]), APP(appl,TOP)) -> FIXP(fix,env,appl)
@@ -601,7 +601,7 @@ let rec apply_stack info t = function
| CASE (ty,br,ci,env,st) ->
apply_stack info
(mkCase (ci, cbv_norm_term info env ty, t,
- Array.map (cbv_norm_term info env) br))
+ Array.map (cbv_norm_term info env) br))
st
| PROJ (p, st) ->
apply_stack info (mkProj (p, t)) st
@@ -630,15 +630,15 @@ and cbv_norm_value info = function (* reduction under binders *)
(mkFix (lij,
(names,
Array.map (cbv_norm_term info env) lty,
- Array.map (cbv_norm_term info
- (subs_liftn (Array.length lty) env)) bds)),
+ Array.map (cbv_norm_term info
+ (subs_liftn (Array.length lty) env)) bds)),
Array.map (cbv_norm_value info) args)
| COFIXP ((j,(names,lty,bds)),env,args) ->
mkApp
(mkCoFix (j,
(names,Array.map (cbv_norm_term info env) lty,
- Array.map (cbv_norm_term info
- (subs_liftn (Array.length lty) env)) bds)),
+ Array.map (cbv_norm_term info
+ (subs_liftn (Array.length lty) env)) bds)),
Array.map (cbv_norm_value info) args)
| CONSTR (c,args) ->
mkApp(mkConstructU c, Array.map (cbv_norm_value info) args)
diff --git a/pretyping/classops.ml b/pretyping/classops.ml
index 57dbfb2580..c12a236d8e 100644
--- a/pretyping/classops.ml
+++ b/pretyping/classops.ml
@@ -195,7 +195,7 @@ let subst_cl_typ subst ct = match ct with
pi1 (find_class_type Evd.empty (EConstr.of_constr t.Univ.univ_abstracted_value)))
| CL_IND i ->
let i' = subst_ind subst i in
- if i' == i then ct else CL_IND i'
+ if i' == i then ct else CL_IND i'
(*CSC: here we should change the datatype for coercions: it should be possible
to declare any term as a coercion *)
@@ -267,7 +267,7 @@ let lookup_path_between env sigma (s,t) =
let (s,(t,p)) =
apply_on_class_of env sigma s (fun i ->
apply_on_class_of env sigma t (fun j ->
- lookup_path_between_class (i,j))) in
+ lookup_path_between_class (i,j))) in
(s,t,p)
let lookup_path_to_fun_from env sigma s =
@@ -323,7 +323,7 @@ let warn_ambiguous_path =
let different_class_params env i =
let ci = class_info_from_index i in
if (snd ci).cl_param > 0 then true
- else
+ else
match fst ci with
| CL_IND i -> Environ.is_polymorphic env (GlobRef.IndRef i)
| CL_CONST c -> Environ.is_polymorphic env (GlobRef.ConstRef c)
@@ -351,16 +351,16 @@ let add_coercion_in_graph env sigma (ic,source,target) =
ClPairMap.iter
(fun (s,t) p ->
if not (Bijint.Index.equal s t) then begin
- if Bijint.Index.equal t source then begin
+ if Bijint.Index.equal t source then begin
try_add_new_path1 (s,target) (p@[ic]);
ClPairMap.iter
- (fun (u,v) q ->
+ (fun (u,v) q ->
if not (Bijint.Index.equal u v) && Bijint.Index.equal u target && not (List.equal coe_info_typ_equal p q) then
- try_add_new_path1 (s,v) (p@[ic]@q))
+ try_add_new_path1 (s,v) (p@[ic]@q))
old_inheritance_graph
end;
if Bijint.Index.equal s target then try_add_new_path1 (source,t) (ic::p)
- end)
+ end)
old_inheritance_graph
end;
match !ambig_paths with [] -> () | _ -> warn_ambiguous_path !ambig_paths
diff --git a/pretyping/coercion.ml b/pretyping/coercion.ml
index 3c71871968..e07fec6b43 100644
--- a/pretyping/coercion.ml
+++ b/pretyping/coercion.ml
@@ -115,18 +115,18 @@ let disc_subset sigma x =
| App (c, l) ->
(match EConstr.kind sigma c with
Ind (i,_) ->
- let len = Array.length l in
- let sigty = delayed_force sig_typ in
- if Int.equal len 2 && eq_ind i (Globnames.destIndRef sigty)
- then
- let (a, b) = pair_of_array l in
- Some (a, b)
- else None
+ let len = Array.length l in
+ let sigty = delayed_force sig_typ in
+ if Int.equal len 2 && eq_ind i (Globnames.destIndRef sigty)
+ then
+ let (a, b) = pair_of_array l in
+ Some (a, b)
+ else None
| _ -> None)
| _ -> None
exception NoSubtacCoercion
-
+
let hnf env evd c = whd_all env evd c
let hnf_nodelta env evd c = whd_betaiota evd c
@@ -142,12 +142,12 @@ let mu env evdref t =
let v' = hnf env !evdref v in
match disc_subset !evdref v' with
| Some (u, p) ->
- let f, ct = aux u in
- let p = hnf_nodelta env !evdref p in
- (Some (fun x ->
- app_opt env evdref
- f (papp evdref sig_proj1 [| u; p; x |])),
- ct)
+ let f, ct = aux u in
+ let p = hnf_nodelta env !evdref p in
+ (Some (fun x ->
+ app_opt env evdref
+ f (papp evdref sig_proj1 [| u; p; x |])),
+ ct)
| None -> (None, v)
in aux t
@@ -159,7 +159,7 @@ and coerce ?loc env evdref (x : EConstr.constr) (y : EConstr.constr)
let x = hnf env !evdref x and y = hnf env !evdref y in
try
evdref := Evarconv.unify_leq_delay env !evdref x y;
- None
+ None
with UnableToUnify _ -> coerce' env x y
and coerce' env x y : (EConstr.constr -> EConstr.constr) option =
let subco () = subset_coerce env evdref x y in
@@ -171,162 +171,162 @@ and coerce ?loc env evdref (x : EConstr.constr) (y : EConstr.constr)
let coerce_application typ typ' c c' l l' =
let len = Array.length l in
let rec aux tele typ typ' i co =
- if i < len then
- let hdx = l.(i) and hdy = l'.(i) in
+ if i < len then
+ let hdx = l.(i) and hdy = l'.(i) in
try evdref := unify_leq_delay env !evdref hdx hdy;
- let (n, eqT), restT = dest_prod typ in
- let (n', eqT'), restT' = dest_prod typ' in
+ let (n, eqT), restT = dest_prod typ in
+ let (n', eqT'), restT' = dest_prod typ' in
aux (hdx :: tele) (subst1 hdx restT) (subst1 hdy restT') (succ i) co
- with UnableToUnify _ ->
+ with UnableToUnify _ ->
let (n, eqT), restT = dest_prod typ in
- let (n', eqT'), restT' = dest_prod typ' in
+ let (n', eqT'), restT' = dest_prod typ' in
let () =
try evdref := unify_leq_delay env !evdref eqT eqT'
with UnableToUnify _ -> raise NoSubtacCoercion
in
- (* Disallow equalities on arities *)
- if Reductionops.is_arity env !evdref eqT then raise NoSubtacCoercion;
- let restargs = lift_args 1
- (List.rev (Array.to_list (Array.sub l (succ i) (len - (succ i)))))
- in
- let args = List.rev (restargs @ mkRel 1 :: List.map (lift 1) tele) in
+ (* Disallow equalities on arities *)
+ if Reductionops.is_arity env !evdref eqT then raise NoSubtacCoercion;
+ let restargs = lift_args 1
+ (List.rev (Array.to_list (Array.sub l (succ i) (len - (succ i)))))
+ in
+ let args = List.rev (restargs @ mkRel 1 :: List.map (lift 1) tele) in
let pred = mkLambda (n, eqT, applist (lift 1 c, args)) in
- let eq = papp evdref coq_eq_ind [| eqT; hdx; hdy |] in
+ let eq = papp evdref coq_eq_ind [| eqT; hdx; hdy |] in
let evar = make_existential ?loc n.binder_name env evdref eq in
- let eq_app x = papp evdref coq_eq_rect
- [| eqT; hdx; pred; x; hdy; evar|]
- in
- aux (hdy :: tele) (subst1 hdx restT)
- (subst1 hdy restT') (succ i) (fun x -> eq_app (co x))
- else Some (fun x ->
- let term = co x in
+ let eq_app x = papp evdref coq_eq_rect
+ [| eqT; hdx; pred; x; hdy; evar|]
+ in
+ aux (hdy :: tele) (subst1 hdx restT)
+ (subst1 hdy restT') (succ i) (fun x -> eq_app (co x))
+ else Some (fun x ->
+ let term = co x in
let sigma, term = Typing.solve_evars env !evdref term in
evdref := sigma; term)
in
- if isEvar !evdref c || isEvar !evdref c' || not (Program.is_program_generalized_coercion ()) then
- (* Second-order unification needed. *)
- raise NoSubtacCoercion;
- aux [] typ typ' 0 (fun x -> x)
+ if isEvar !evdref c || isEvar !evdref c' || not (Program.is_program_generalized_coercion ()) then
+ (* Second-order unification needed. *)
+ raise NoSubtacCoercion;
+ aux [] typ typ' 0 (fun x -> x)
in
match (EConstr.kind !evdref x, EConstr.kind !evdref y) with
| Sort s, Sort s' ->
(match ESorts.kind !evdref s, ESorts.kind !evdref s' with
| Prop, Prop | Set, Set -> None
| (Prop | Set), Type _ -> None
- | Type x, Type y when Univ.Universe.equal x y -> None (* false *)
- | _ -> subco ())
+ | Type x, Type y when Univ.Universe.equal x y -> None (* false *)
+ | _ -> subco ())
| Prod (name, a, b), Prod (name', a', b') ->
- let name' =
+ let name' =
{name' with
binder_name =
Name (Namegen.next_ident_away
Namegen.default_dependent_ident (Termops.vars_of_env env))}
in
let env' = push_rel (LocalAssum (name', a')) env in
- let c1 = coerce_unify env' (lift 1 a') (lift 1 a) in
- (* env, x : a' |- c1 : lift 1 a' > lift 1 a *)
- let coec1 = app_opt env' evdref c1 (mkRel 1) in
- (* env, x : a' |- c1[x] : lift 1 a *)
- let c2 = coerce_unify env' (subst1 coec1 (liftn 1 2 b)) b' in
- (* env, x : a' |- c2 : b[c1[x]/x]] > b' *)
- (match c1, c2 with
- | None, None -> None
- | _, _ ->
- Some
- (fun f ->
+ let c1 = coerce_unify env' (lift 1 a') (lift 1 a) in
+ (* env, x : a' |- c1 : lift 1 a' > lift 1 a *)
+ let coec1 = app_opt env' evdref c1 (mkRel 1) in
+ (* env, x : a' |- c1[x] : lift 1 a *)
+ let c2 = coerce_unify env' (subst1 coec1 (liftn 1 2 b)) b' in
+ (* env, x : a' |- c2 : b[c1[x]/x]] > b' *)
+ (match c1, c2 with
+ | None, None -> None
+ | _, _ ->
+ Some
+ (fun f ->
mkLambda (name', a',
- app_opt env' evdref c2
- (mkApp (lift 1 f, [| coec1 |])))))
+ app_opt env' evdref c2
+ (mkApp (lift 1 f, [| coec1 |])))))
| App (c, l), App (c', l') ->
- (match EConstr.kind !evdref c, EConstr.kind !evdref c' with
- Ind (i, u), Ind (i', u') -> (* Inductive types *)
- let len = Array.length l in
- let sigT = delayed_force sigT_typ in
- let prod = delayed_force prod_typ in
- (* Sigma types *)
- if Int.equal len (Array.length l') && Int.equal len 2 && eq_ind i i'
- && (eq_ind i (destIndRef sigT) || eq_ind i (destIndRef prod))
- then
- if eq_ind i (destIndRef sigT)
- then
- begin
- let (a, pb), (a', pb') =
- pair_of_array l, pair_of_array l'
- in
- let c1 = coerce_unify env a a' in
- let remove_head a c =
- match EConstr.kind !evdref c with
+ (match EConstr.kind !evdref c, EConstr.kind !evdref c' with
+ Ind (i, u), Ind (i', u') -> (* Inductive types *)
+ let len = Array.length l in
+ let sigT = delayed_force sigT_typ in
+ let prod = delayed_force prod_typ in
+ (* Sigma types *)
+ if Int.equal len (Array.length l') && Int.equal len 2 && eq_ind i i'
+ && (eq_ind i (destIndRef sigT) || eq_ind i (destIndRef prod))
+ then
+ if eq_ind i (destIndRef sigT)
+ then
+ begin
+ let (a, pb), (a', pb') =
+ pair_of_array l, pair_of_array l'
+ in
+ let c1 = coerce_unify env a a' in
+ let remove_head a c =
+ match EConstr.kind !evdref c with
| Lambda (n, t, t') -> c, t'
- | Evar (k, args) ->
- let (evs, t) = Evardefine.define_evar_as_lambda env !evdref (k,args) in
- evdref := evs;
+ | Evar (k, args) ->
+ let (evs, t) = Evardefine.define_evar_as_lambda env !evdref (k,args) in
+ evdref := evs;
let (n, dom, rng) = destLambda !evdref t in
- if isEvar !evdref dom then
- let (domk, args) = destEvar !evdref dom in
+ if isEvar !evdref dom then
+ let (domk, args) = destEvar !evdref dom in
evdref := define domk a !evdref;
- else ();
- t, rng
- | _ -> raise NoSubtacCoercion
- in
+ else ();
+ t, rng
+ | _ -> raise NoSubtacCoercion
+ in
let (pb, b), (pb', b') = remove_head a pb, remove_head a' pb' in
let ra = Retyping.relevance_of_type env !evdref a in
let env' = push_rel
(LocalAssum (make_annot (Name Namegen.default_dependent_ident) ra, a))
env
in
- let c2 = coerce_unify env' b b' in
- match c1, c2 with
- | None, None -> None
- | _, _ ->
- Some
- (fun x ->
- let x, y =
- app_opt env' evdref c1 (papp evdref sigT_proj1
- [| a; pb; x |]),
- app_opt env' evdref c2 (papp evdref sigT_proj2
- [| a; pb; x |])
- in
- papp evdref sigT_intro [| a'; pb'; x ; y |])
- end
- else
- begin
- let (a, b), (a', b') =
- pair_of_array l, pair_of_array l'
- in
- let c1 = coerce_unify env a a' in
- let c2 = coerce_unify env b b' in
- match c1, c2 with
- | None, None -> None
- | _, _ ->
- Some
- (fun x ->
- let x, y =
- app_opt env evdref c1 (papp evdref prod_proj1
- [| a; b; x |]),
- app_opt env evdref c2 (papp evdref prod_proj2
- [| a; b; x |])
- in
- papp evdref prod_intro [| a'; b'; x ; y |])
- end
- else
- if eq_ind i i' && Int.equal len (Array.length l') then
- let evm = !evdref in
- (try subco ()
- with NoSubtacCoercion ->
- let typ = Typing.unsafe_type_of env evm c in
- let typ' = Typing.unsafe_type_of env evm c' in
- coerce_application typ typ' c c' l l')
- else
- subco ()
- | x, y when EConstr.eq_constr !evdref c c' ->
- if Int.equal (Array.length l) (Array.length l') then
- let evm = !evdref in
- let lam_type = Typing.unsafe_type_of env evm c in
- let lam_type' = Typing.unsafe_type_of env evm c' in
- coerce_application lam_type lam_type' c c' l l'
- else subco ()
- | _ -> subco ())
+ let c2 = coerce_unify env' b b' in
+ match c1, c2 with
+ | None, None -> None
+ | _, _ ->
+ Some
+ (fun x ->
+ let x, y =
+ app_opt env' evdref c1 (papp evdref sigT_proj1
+ [| a; pb; x |]),
+ app_opt env' evdref c2 (papp evdref sigT_proj2
+ [| a; pb; x |])
+ in
+ papp evdref sigT_intro [| a'; pb'; x ; y |])
+ end
+ else
+ begin
+ let (a, b), (a', b') =
+ pair_of_array l, pair_of_array l'
+ in
+ let c1 = coerce_unify env a a' in
+ let c2 = coerce_unify env b b' in
+ match c1, c2 with
+ | None, None -> None
+ | _, _ ->
+ Some
+ (fun x ->
+ let x, y =
+ app_opt env evdref c1 (papp evdref prod_proj1
+ [| a; b; x |]),
+ app_opt env evdref c2 (papp evdref prod_proj2
+ [| a; b; x |])
+ in
+ papp evdref prod_intro [| a'; b'; x ; y |])
+ end
+ else
+ if eq_ind i i' && Int.equal len (Array.length l') then
+ let evm = !evdref in
+ (try subco ()
+ with NoSubtacCoercion ->
+ let typ = Typing.unsafe_type_of env evm c in
+ let typ' = Typing.unsafe_type_of env evm c' in
+ coerce_application typ typ' c c' l l')
+ else
+ subco ()
+ | x, y when EConstr.eq_constr !evdref c c' ->
+ if Int.equal (Array.length l) (Array.length l') then
+ let evm = !evdref in
+ let lam_type = Typing.unsafe_type_of env evm c in
+ let lam_type' = Typing.unsafe_type_of env evm c' in
+ coerce_application lam_type lam_type' c c' l l'
+ else subco ()
+ | _ -> subco ())
| _, _ -> subco ()
and subset_coerce env evdref x y =
@@ -334,20 +334,20 @@ and coerce ?loc env evdref (x : EConstr.constr) (y : EConstr.constr)
Some (u, p) ->
let c = coerce_unify env u y in
let f x =
- app_opt env evdref c (papp evdref sig_proj1 [| u; p; x |])
+ app_opt env evdref c (papp evdref sig_proj1 [| u; p; x |])
in Some f
| None ->
- match disc_subset !evdref y with
- Some (u, p) ->
- let c = coerce_unify env x u in
- Some
- (fun x ->
- let cx = app_opt env evdref c x in
- let evar = make_existential ?loc Anonymous env evdref (mkApp (p, [| cx |]))
- in
- (papp evdref sig_intro [| u; p; cx; evar |]))
- | None ->
- raise NoSubtacCoercion
+ match disc_subset !evdref y with
+ Some (u, p) ->
+ let c = coerce_unify env x u in
+ Some
+ (fun x ->
+ let cx = app_opt env evdref c x in
+ let evar = make_existential ?loc Anonymous env evdref (mkApp (p, [| cx |]))
+ in
+ (papp evdref sig_intro [| u; p; cx; evar |]))
+ | None ->
+ raise NoSubtacCoercion
in coerce_unify env x y
let app_coercion env evdref coercion v =
@@ -371,7 +371,7 @@ let saturate_evd env evd =
(* Apply coercion path from p to hj; raise NoCoercion if not applicable *)
let apply_coercion env sigma p hj typ_cl =
try
- let j,t,evd =
+ let j,t,evd =
List.fold_left
(fun (ja,typ_cl,sigma) i ->
let isid = i.coe_is_identity in
@@ -379,15 +379,15 @@ let apply_coercion env sigma p hj typ_cl =
let sigma, c = new_global sigma i.coe_value in
let typ = Retyping.get_type_of env sigma c in
let fv = make_judge c typ in
- let argl = (class_args_of env sigma typ_cl)@[ja.uj_val] in
- let sigma, jres =
- apply_coercion_args env sigma true isproj argl fv
- in
- (if isid then
- { uj_val = ja.uj_val; uj_type = jres.uj_type }
- else
- jres),
- jres.uj_type,sigma)
+ let argl = (class_args_of env sigma typ_cl)@[ja.uj_val] in
+ let sigma, jres =
+ apply_coercion_args env sigma true isproj argl fv
+ in
+ (if isid then
+ { uj_val = ja.uj_val; uj_type = jres.uj_type }
+ else
+ jres),
+ jres.uj_type,sigma)
(hj,typ_cl,sigma) p
in evd, j
with NoCoercion as e -> raise e
@@ -399,11 +399,11 @@ let inh_app_fun_core ~program_mode env evd j =
| Prod _ -> (evd,j)
| Evar ev ->
let (evd',t) = Evardefine.define_evar_as_product env evd ev in
- (evd',{ uj_val = j.uj_val; uj_type = t })
+ (evd',{ uj_val = j.uj_val; uj_type = t })
| _ ->
- try let t,p =
- lookup_path_to_fun_from env evd j.uj_type in
- apply_coercion env evd p j t
+ try let t,p =
+ lookup_path_to_fun_from env evd j.uj_type in
+ apply_coercion env evd p j t
with Not_found | NoCoercion ->
if program_mode then
try
@@ -444,10 +444,10 @@ let inh_coerce_to_sort ?loc env evd j =
match EConstr.kind evd typ with
| Sort s -> (evd,{ utj_val = j.uj_val; utj_type = ESorts.kind evd s })
| Evar ev ->
- let (evd',s) = Evardefine.define_evar_as_sort env evd ev in
- (evd',{ utj_val = j.uj_val; utj_type = s })
+ let (evd',s) = Evardefine.define_evar_as_sort env evd ev in
+ (evd',{ utj_val = j.uj_val; utj_type = s })
| _ ->
- inh_tosort_force ?loc env evd j
+ inh_tosort_force ?loc env evd j
let inh_coerce_to_base ?loc ~program_mode env evd j =
if program_mode then
@@ -455,7 +455,7 @@ let inh_coerce_to_base ?loc ~program_mode env evd j =
let ct, typ' = mu env evdref j.uj_type in
let res =
{ uj_val = (app_coercion env evdref ct j.uj_val);
- uj_type = typ' }
+ uj_type = typ' }
in !evdref, res
else (evd, j)
@@ -473,14 +473,14 @@ let inh_coerce_to_fail flags env evd rigidonly v t c1 =
else
let evd, v', t' =
try
- let t2,t1,p = lookup_path_between env evd (t,c1) in
- match v with
- | Some v ->
- let evd,j =
- apply_coercion env evd p
- {uj_val = v; uj_type = t} t2 in
- evd, Some j.uj_val, j.uj_type
- | None -> evd, None, t
+ let t2,t1,p = lookup_path_between env evd (t,c1) in
+ match v with
+ | Some v ->
+ let evd,j =
+ apply_coercion env evd p
+ {uj_val = v; uj_type = t} t2 in
+ evd, Some j.uj_val, j.uj_type
+ | None -> evd, None, t
with Not_found -> raise NoCoercion
in
try (unify_leq_delay ~flags env evd t' c1, v')
@@ -501,24 +501,24 @@ let rec inh_conv_coerce_to_fail ?loc env evd ?(flags=default_flags_of env) rigid
| Prod (name,t1,t2), Prod (_,u1,u2) ->
(* Conversion did not work, we may succeed with a coercion. *)
(* We eta-expand (hence possibly modifying the original term!) *)
- (* and look for a coercion c:u1->t1 s.t. fun x:u1 => v' (c x)) *)
- (* has type forall (x:u1), u2 (with v' recursively obtained) *)
+ (* and look for a coercion c:u1->t1 s.t. fun x:u1 => v' (c x)) *)
+ (* has type forall (x:u1), u2 (with v' recursively obtained) *)
(* Note: we retype the term because template polymorphism may have *)
(* weakened its type *)
let name = map_annot (function
- | Anonymous -> Name Namegen.default_dependent_ident
+ | Anonymous -> Name Namegen.default_dependent_ident
| na -> na) name in
- let open Context.Rel.Declaration in
+ let open Context.Rel.Declaration in
let env1 = push_rel (LocalAssum (name,u1)) env in
- let (evd', v1) =
- inh_conv_coerce_to_fail ?loc env1 evd rigidonly
+ let (evd', v1) =
+ inh_conv_coerce_to_fail ?loc env1 evd rigidonly
(Some (mkRel 1)) (lift 1 u1) (lift 1 t1) in
let v1 = Option.get v1 in
- let v2 = Option.map (fun v -> beta_applist evd' (lift 1 v,[v1])) v in
- let t2 = match v2 with
- | None -> subst_term evd' v1 t2
- | Some v2 -> Retyping.get_type_of env1 evd' v2 in
- let (evd'',v2') = inh_conv_coerce_to_fail ?loc env1 evd' rigidonly v2 t2 u2 in
+ let v2 = Option.map (fun v -> beta_applist evd' (lift 1 v,[v1])) v in
+ let t2 = match v2 with
+ | None -> subst_term evd' v1 t2
+ | Some v2 -> Retyping.get_type_of env1 evd' v2 in
+ let (evd'',v2') = inh_conv_coerce_to_fail ?loc env1 evd' rigidonly v2 t2 u2 in
(evd'', Option.map (fun v2' -> mkLambda (name, u1, v2')) v2')
| _ -> raise (NoCoercionNoUnifier (best_failed_evd,e))
@@ -530,20 +530,20 @@ let inh_conv_coerce_to_gen ?loc ~program_mode resolve_tc rigidonly flags env evd
with NoCoercionNoUnifier (best_failed_evd,e) ->
try
if program_mode then
- coerce_itf ?loc env evd (Some cj.uj_val) cj.uj_type t
- else raise NoSubtacCoercion
+ coerce_itf ?loc env evd (Some cj.uj_val) cj.uj_type t
+ else raise NoSubtacCoercion
with
| NoSubtacCoercion when not resolve_tc || not (get_use_typeclasses_for_conversion ()) ->
- error_actual_type ?loc env best_failed_evd cj t e
+ error_actual_type ?loc env best_failed_evd cj t e
| NoSubtacCoercion ->
- let evd' = saturate_evd env evd in
- try
- if evd' == evd then
- error_actual_type ?loc env best_failed_evd cj t e
- else
- inh_conv_coerce_to_fail ?loc env evd' rigidonly (Some cj.uj_val) cj.uj_type t
- with NoCoercionNoUnifier (_evd,_error) ->
- error_actual_type ?loc env best_failed_evd cj t e
+ let evd' = saturate_evd env evd in
+ try
+ if evd' == evd then
+ error_actual_type ?loc env best_failed_evd cj t e
+ else
+ inh_conv_coerce_to_fail ?loc env evd' rigidonly (Some cj.uj_val) cj.uj_type t
+ with NoCoercionNoUnifier (_evd,_error) ->
+ error_actual_type ?loc env best_failed_evd cj t e
in
let val' = match val' with Some v -> v | None -> assert(false) in
(evd',{ uj_val = val'; uj_type = t })
@@ -558,4 +558,4 @@ let inh_conv_coerces_to ?loc env evd ?(flags=default_flags_of env) t t' =
fst (inh_conv_coerce_to_fail ?loc env evd ~flags true None t t')
with NoCoercion ->
evd (* Maybe not enough information to unify *)
-
+
diff --git a/pretyping/coercion.mli b/pretyping/coercion.mli
index 0dc8208786..3b24bcec8b 100644
--- a/pretyping/coercion.mli
+++ b/pretyping/coercion.mli
@@ -40,7 +40,7 @@ val inh_coerce_to_base : ?loc:Loc.t -> program_mode:bool ->
val inh_coerce_to_prod : ?loc:Loc.t -> program_mode:bool ->
env -> evar_map -> types -> evar_map * types
-(** [inh_conv_coerce_to resolve_tc Loc.t env isevars j t] coerces [j] to an
+(** [inh_conv_coerce_to resolve_tc Loc.t env isevars j t] coerces [j] to an
object of type [t]; i.e. it inserts a coercion into [j], if needed, in such
a way [t] and [j.uj_type] are convertible; it fails if no coercion is
applicable. resolve_tc=false disables resolving type classes (as the last
diff --git a/pretyping/constr_matching.ml b/pretyping/constr_matching.ml
index d1cc21d82f..7d1bb5e3b1 100644
--- a/pretyping/constr_matching.ml
+++ b/pretyping/constr_matching.ml
@@ -291,46 +291,46 @@ let matches_core env sigma allow_bound_rels
(let diff = Array.length args2 - Array.length args1 in
if diff >= 0 then
let args21, args22 = Array.chop diff args2 in
- let c = mkApp(c2,args21) in
+ let c = mkApp(c2,args21) in
let subst =
match meta with
| None -> subst
| Some n -> merge_binding sigma allow_bound_rels ctx n c subst in
Array.fold_left2 (sorec ctx env) subst args1 args22
else (* Might be a projection on the right *)
- match EConstr.kind sigma c2 with
- | Proj (pr, c) when not (Projection.unfolded pr) ->
- (try let term = Retyping.expand_projection env sigma pr c (Array.to_list args2) in
- sorec ctx env subst p term
- with Retyping.RetypeError _ -> raise PatternMatchingFailure)
- | _ -> raise PatternMatchingFailure)
-
+ match EConstr.kind sigma c2 with
+ | Proj (pr, c) when not (Projection.unfolded pr) ->
+ (try let term = Retyping.expand_projection env sigma pr c (Array.to_list args2) in
+ sorec ctx env subst p term
+ with Retyping.RetypeError _ -> raise PatternMatchingFailure)
+ | _ -> raise PatternMatchingFailure)
+
| PApp (c1,arg1), App (c2,arg2) ->
- (match c1, EConstr.kind sigma c2 with
+ (match c1, EConstr.kind sigma c2 with
| PRef (GlobRef.ConstRef r), Proj (pr,c) when not (Constant.equal r (Projection.constant pr))
- || Projection.unfolded pr ->
- raise PatternMatchingFailure
- | PProj (pr1,c1), Proj (pr,c) ->
- if Projection.equal pr1 pr then
- try Array.fold_left2 (sorec ctx env) (sorec ctx env subst c1 c) arg1 arg2
- with Invalid_argument _ -> raise PatternMatchingFailure
- else raise PatternMatchingFailure
- | _, Proj (pr,c) when not (Projection.unfolded pr) ->
- (try let term = Retyping.expand_projection env sigma pr c (Array.to_list arg2) in
- sorec ctx env subst p term
- with Retyping.RetypeError _ -> raise PatternMatchingFailure)
- | _, _ ->
+ || Projection.unfolded pr ->
+ raise PatternMatchingFailure
+ | PProj (pr1,c1), Proj (pr,c) ->
+ if Projection.equal pr1 pr then
+ try Array.fold_left2 (sorec ctx env) (sorec ctx env subst c1 c) arg1 arg2
+ with Invalid_argument _ -> raise PatternMatchingFailure
+ else raise PatternMatchingFailure
+ | _, Proj (pr,c) when not (Projection.unfolded pr) ->
+ (try let term = Retyping.expand_projection env sigma pr c (Array.to_list arg2) in
+ sorec ctx env subst p term
+ with Retyping.RetypeError _ -> raise PatternMatchingFailure)
+ | _, _ ->
try Array.fold_left2 (sorec ctx env) (sorec ctx env subst c1 c2) arg1 arg2
with Invalid_argument _ -> raise PatternMatchingFailure)
-
+
| PApp (PRef (GlobRef.ConstRef c1), _), Proj (pr, c2)
- when Projection.unfolded pr || not (Constant.equal c1 (Projection.constant pr)) ->
- raise PatternMatchingFailure
-
+ when Projection.unfolded pr || not (Constant.equal c1 (Projection.constant pr)) ->
+ raise PatternMatchingFailure
+
| PApp (c, args), Proj (pr, c2) ->
- (try let term = Retyping.expand_projection env sigma pr c2 [] in
- sorec ctx env subst p term
- with Retyping.RetypeError _ -> raise PatternMatchingFailure)
+ (try let term = Retyping.expand_projection env sigma pr c2 [] in
+ sorec ctx env subst p term
+ with Retyping.RetypeError _ -> raise PatternMatchingFailure)
| PProj (p1,c1), Proj (p2,c2) when Projection.equal p1 p2 ->
sorec ctx env subst c1 c2
@@ -352,23 +352,23 @@ let matches_core env sigma allow_bound_rels
(add_binders na1 na2 binding_vars (sorec ctx env subst c1 c2)) d1 d2
| PIf (a1,b1,b1'), Case (ci,_,a2,[|b2;b2'|]) ->
- let ctx_b2,b2 = decompose_lam_n_decls sigma ci.ci_cstr_ndecls.(0) b2 in
- let ctx_b2',b2' = decompose_lam_n_decls sigma ci.ci_cstr_ndecls.(1) b2' in
- let n = Context.Rel.length ctx_b2 in
+ let ctx_b2,b2 = decompose_lam_n_decls sigma ci.ci_cstr_ndecls.(0) b2 in
+ let ctx_b2',b2' = decompose_lam_n_decls sigma ci.ci_cstr_ndecls.(1) b2' in
+ let n = Context.Rel.length ctx_b2 in
let n' = Context.Rel.length ctx_b2' in
- if Vars.noccur_between sigma 1 n b2 && Vars.noccur_between sigma 1 n' b2' then
+ if Vars.noccur_between sigma 1 n b2 && Vars.noccur_between sigma 1 n' b2' then
let f l (LocalAssum (na,t) | LocalDef (na,_,t)) = push_binder Anonymous na t l in
- let ctx_br = List.fold_left f ctx ctx_b2 in
- let ctx_br' = List.fold_left f ctx ctx_b2' in
- let b1 = lift_pattern n b1 and b1' = lift_pattern n' b1' in
- sorec ctx_br' (push_rel_context ctx_b2' env)
- (sorec ctx_br (push_rel_context ctx_b2 env)
+ let ctx_br = List.fold_left f ctx ctx_b2 in
+ let ctx_br' = List.fold_left f ctx ctx_b2' in
+ let b1 = lift_pattern n b1 and b1' = lift_pattern n' b1' in
+ sorec ctx_br' (push_rel_context ctx_b2' env)
+ (sorec ctx_br (push_rel_context ctx_b2 env)
(sorec ctx env subst a1 a2) b1 b2) b1' b2'
else
raise PatternMatchingFailure
| PCase (ci1,p1,a1,br1), Case (ci2,p2,a2,br2) ->
- let n2 = Array.length br2 in
+ let n2 = Array.length br2 in
let () = match ci1.cip_ind with
| None -> ()
| Some ind1 ->
@@ -380,14 +380,14 @@ let matches_core env sigma allow_bound_rels
if not ci1.cip_extensible && not (Int.equal (List.length br1) n2)
then raise PatternMatchingFailure
in
- let chk_branch subst (j,n,c) =
- (* (ind,j+1) is normally known to be a correct constructor
- and br2 a correct match over the same inductive *)
- assert (j < n2);
- sorec ctx env subst c br2.(j)
- in
- let chk_head = sorec ctx env (sorec ctx env subst a1 a2) p1 p2 in
- List.fold_left chk_branch chk_head br1
+ let chk_branch subst (j,n,c) =
+ (* (ind,j+1) is normally known to be a correct constructor
+ and br2 a correct match over the same inductive *)
+ assert (j < n2);
+ sorec ctx env subst c br2.(j)
+ in
+ let chk_head = sorec ctx env (sorec ctx env subst a1 a2) p1 p2 in
+ List.fold_left chk_branch chk_head br1
| PFix ((ln1,i1),(lna1,tl1,bl1)), Fix ((ln2,i2),(lna2,tl2,bl2))
when Array.equal Int.equal ln1 ln2 && i1 = i2 ->
diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml
index 5dd4772bcc..862865bd90 100644
--- a/pretyping/detyping.ml
+++ b/pretyping/detyping.ml
@@ -133,8 +133,8 @@ let add_name na b t (nenv, env) =
add_name na nenv, push_rel (match b with
| None -> LocalAssum (make_annot na r,t)
| Some b -> LocalDef (make_annot na r,b,t)
- )
- env
+ )
+ env
let add_name_opt na b t (nenv, env) =
match t with
@@ -199,7 +199,7 @@ module PrintingCasesIf =
let member_message s b =
str "Cases on elements of " ++ s ++
str
- (if b then " are printed using a `if' form"
+ (if b then " are printed using a `if' form"
else " are not printed using a `if' form")
end)
@@ -212,7 +212,7 @@ module PrintingCasesLet =
let member_message s b =
str "Cases on elements of " ++ s ++
str
- (if b then " are printed using a `let' form"
+ (if b then " are printed using a `let' form"
else " are not printed using a `let' form")
end)
@@ -227,11 +227,11 @@ let wildcard_value = ref true
let force_wildcard () = !wildcard_value
let () = declare_bool_option
- { optdepr = false;
- optname = "forced wildcard";
- optkey = ["Printing";"Wildcard"];
- optread = force_wildcard;
- optwrite = (:=) wildcard_value }
+ { optdepr = false;
+ optname = "forced wildcard";
+ optkey = ["Printing";"Wildcard"];
+ optread = force_wildcard;
+ optwrite = (:=) wildcard_value }
let fast_name_generation = ref false
@@ -247,33 +247,33 @@ let synth_type_value = ref true
let synthetize_type () = !synth_type_value
let () = declare_bool_option
- { optdepr = false;
- optname = "pattern matching return type synthesizability";
- optkey = ["Printing";"Synth"];
- optread = synthetize_type;
- optwrite = (:=) synth_type_value }
+ { optdepr = false;
+ optname = "pattern matching return type synthesizability";
+ optkey = ["Printing";"Synth"];
+ optread = synthetize_type;
+ optwrite = (:=) synth_type_value }
let reverse_matching_value = ref true
let reverse_matching () = !reverse_matching_value
let () = declare_bool_option
- { optdepr = false;
- optname = "pattern-matching reversibility";
- optkey = ["Printing";"Matching"];
- optread = reverse_matching;
- optwrite = (:=) reverse_matching_value }
+ { optdepr = false;
+ optname = "pattern-matching reversibility";
+ optkey = ["Printing";"Matching"];
+ optread = reverse_matching;
+ optwrite = (:=) reverse_matching_value }
let print_primproj_params_value = ref false
let print_primproj_params () = !print_primproj_params_value
let () = declare_bool_option
- { optdepr = false;
- optname = "printing of primitive projection parameters";
- optkey = ["Printing";"Primitive";"Projection";"Parameters"];
- optread = print_primproj_params;
- optwrite = (:=) print_primproj_params_value }
+ { optdepr = false;
+ optname = "printing of primitive projection parameters";
+ optkey = ["Printing";"Primitive";"Projection";"Parameters"];
+ optread = print_primproj_params;
+ optwrite = (:=) print_primproj_params_value }
+
-
(* Auxiliary function for MutCase printing *)
(* [computable] tries to tell if the predicate typing the result is inferable*)
@@ -304,11 +304,11 @@ let lookup_name_as_displayed env sigma t s =
| Prod (name,_,c') ->
(match compute_displayed_name_in sigma RenamingForGoal avoid name.binder_name c' with
| (Name id,avoid') -> if Id.equal id s then Some n else lookup avoid' (n+1) c'
- | (Anonymous,avoid') -> lookup avoid' (n+1) (pop c'))
+ | (Anonymous,avoid') -> lookup avoid' (n+1) (pop c'))
| LetIn (name,_,_,c') ->
(match Namegen.compute_displayed_name_in sigma RenamingForGoal avoid name.binder_name c' with
| (Name id,avoid') -> if Id.equal id s then Some n else lookup avoid' (n+1) c'
- | (Anonymous,avoid') -> lookup avoid' (n+1) (pop c'))
+ | (Anonymous,avoid') -> lookup avoid' (n+1) (pop c'))
| Cast (c,_,_) -> lookup avoid n c
| _ -> None
in lookup (Environ.ids_of_named_context_val (Environ.named_context_val env)) 1 t
@@ -319,23 +319,23 @@ let lookup_index_as_renamed env sigma t n =
(match Namegen.compute_displayed_name_in sigma RenamingForGoal Id.Set.empty name.binder_name c' with
(Name _,_) -> lookup n (d+1) c'
| (Anonymous,_) ->
- if Int.equal n 0 then
- Some (d-1)
- else if Int.equal n 1 then
- Some d
- else
- lookup (n-1) (d+1) c')
+ if Int.equal n 0 then
+ Some (d-1)
+ else if Int.equal n 1 then
+ Some d
+ else
+ lookup (n-1) (d+1) c')
| LetIn (name,_,_,c') ->
(match Namegen.compute_displayed_name_in sigma RenamingForGoal Id.Set.empty name.binder_name c' with
| (Name _,_) -> lookup n (d+1) c'
| (Anonymous,_) ->
- if Int.equal n 0 then
- Some (d-1)
- else if Int.equal n 1 then
- Some d
- else
- lookup (n-1) (d+1) c'
- )
+ if Int.equal n 0 then
+ Some (d-1)
+ else if Int.equal n 1 then
+ Some d
+ else
+ lookup (n-1) (d+1) c'
+ )
| Cast (c,_,_) -> lookup n d c
| _ -> if Int.equal n 0 then Some (d-1) else None
in lookup n 1 t
@@ -444,10 +444,10 @@ let rec decomp_branch tags nal flags (avoid,env as e) sigma c =
| Lambda (na,t,c),false -> na.binder_name,c,true,None,Some t
| LetIn (na,b,t,c),true ->
na.binder_name,c,false,Some b,Some t
- | _, false ->
- Name default_dependent_ident,(applist (lift 1 c, [mkRel 1])),
+ | _, false ->
+ Name default_dependent_ident,(applist (lift 1 c, [mkRel 1])),
false,None,None
- | _, true ->
+ | _, true ->
Anonymous,lift 1 c,false,None,None
in
let na',avoid' = compute_name sigma ~let_in ~pattern:true flags avoid env na c in
@@ -468,14 +468,14 @@ and align_tree nal isgoal (e,c as rhs) sigma = match nal with
| Case (ci,p,c,cl) when
eq_constr sigma c (mkRel (List.index Name.equal na (fst (snd e))))
&& not (Int.equal (Array.length cl) 0)
- && (* don't contract if p dependent *)
- computable sigma p (List.length ci.ci_pp_info.ind_tags) (* FIXME: can do better *) ->
- let clauses = build_tree na isgoal e sigma ci cl in
- List.flatten
+ && (* don't contract if p dependent *)
+ computable sigma p (List.length ci.ci_pp_info.ind_tags) (* FIXME: can do better *) ->
+ let clauses = build_tree na isgoal e sigma ci cl in
+ List.flatten
(List.map (fun (ids,pat,rhs) ->
- let lines = align_tree nal isgoal rhs sigma in
+ let lines = align_tree nal isgoal rhs sigma in
List.map (fun (ids',hd,rest) -> Id.Set.fold Id.Set.add ids ids',pat::hd,rest) lines)
- clauses)
+ clauses)
| _ ->
let na = update_name sigma na rhs in
let pat = DAst.make @@ PatVar na in
@@ -518,15 +518,15 @@ let it_destRLambda_or_LetIn_names l c =
| _, true::l -> (* let-expansion *) aux l (Anonymous :: nal) c
| _, false::l ->
(* eta-expansion *)
- let next l =
- let x = next_ident_away default_dependent_ident l in
- (* Not efficient but unusual and no function to get free glob_vars *)
+ let next l =
+ let x = next_ident_away default_dependent_ident l in
+ (* Not efficient but unusual and no function to get free glob_vars *)
(* if occur_glob_constr x c then next (x::l) else x in *)
- x
- in
- let x = next (free_glob_vars c) in
- let a = DAst.make @@ GVar x in
- aux l (Name x :: nal)
+ x
+ in
+ let x = next (free_glob_vars c) in
+ let a = DAst.make @@ GVar x in
+ aux l (Name x :: nal)
(match DAst.get c with
| GApp (p,l) -> DAst.make ?loc:c.CAst.loc @@ GApp (p,l@[a])
| _ -> DAst.make @@ GApp (c,[a]))
@@ -557,13 +557,13 @@ let detype_case computable detype detype_eqns testdep avoid data p c bl =
if !Flags.raw_print then
RegularStyle
else if st == LetPatternStyle then
- st
+ st
else if PrintingLet.active indsp then
- LetStyle
+ LetStyle
else if PrintingIf.active indsp then
- IfStyle
+ IfStyle
else
- st
+ st
with Not_found -> st
in
match tag, aliastyp with
@@ -574,13 +574,13 @@ let detype_case computable detype detype_eqns testdep avoid data p c bl =
| IfStyle, None ->
let bl' = Array.map detype bl in
let nondepbrs =
- Array.map3 (extract_nondep_branches testdep) bl bl' constagsl in
+ Array.map3 (extract_nondep_branches testdep) bl bl' constagsl in
if Array.for_all ((!=) None) nondepbrs then
- GIf (tomatch,(alias,pred),
+ GIf (tomatch,(alias,pred),
Option.get nondepbrs.(0),Option.get nondepbrs.(1))
else
- let eqnl = detype_eqns constructs constagsl bl in
- GCases (tag,pred,[tomatch,(alias,aliastyp)],eqnl)
+ let eqnl = detype_eqns constructs constagsl bl in
+ GCases (tag,pred,[tomatch,(alias,aliastyp)],eqnl)
| _ ->
let eqnl = detype_eqns constructs constagsl bl in
GCases (tag,pred,[tomatch,(alias,aliastyp)],eqnl)
@@ -712,7 +712,7 @@ let detype_level sigma l =
let l = hack_qualid_of_univ_level sigma l in
UNamed (GType l)
-let detype_instance sigma l =
+let detype_instance sigma l =
let l = EInstance.kind sigma l in
if Univ.Instance.is_empty l then None
else Some (List.map (detype_level sigma) (Array.to_list (Univ.Instance.to_array l)))
@@ -737,37 +737,37 @@ and detype_r d flags avoid env sigma t =
let s = "_UNBOUND_REL_"^(string_of_int n)
in GVar (Id.of_string s))
| Meta n ->
- (* Meta in constr are not user-parsable and are mapped to Evar *)
+ (* Meta in constr are not user-parsable and are mapped to Evar *)
if n = Constr_matching.special_meta then
(* Using a dash to be unparsable *)
- GEvar (Id.of_string_soft "CONTEXT-HOLE", [])
+ GEvar (Id.of_string_soft "CONTEXT-HOLE", [])
else
- GEvar (Id.of_string_soft ("M" ^ string_of_int n), [])
+ GEvar (Id.of_string_soft ("M" ^ string_of_int n), [])
| Var id ->
(* Discriminate between section variable and non-section variable *)
(try let _ = Global.lookup_named id in GRef (GlobRef.VarRef id, None)
- with Not_found -> GVar id)
+ with Not_found -> GVar id)
| Sort s -> GSort (detype_sort sigma (ESorts.kind sigma s))
| Cast (c1,REVERTcast,c2) when not !Flags.raw_print ->
DAst.get (detype d flags avoid env sigma c1)
| Cast (c1,k,c2) ->
let d1 = detype d flags avoid env sigma c1 in
- let d2 = detype d flags avoid env sigma c2 in
+ let d2 = detype d flags avoid env sigma c2 in
let cast = match k with
| VMcast -> CastVM d2
| NATIVEcast -> CastNative d2
| _ -> CastConv d2
in
- GCast(d1,cast)
+ GCast(d1,cast)
| Prod (na,ty,c) -> detype_binder d flags BProd avoid env sigma na None ty c
| Lambda (na,ty,c) -> detype_binder d flags BLambda avoid env sigma na None ty c
| LetIn (na,b,ty,c) -> detype_binder d flags BLetIn avoid env sigma na (Some b) ty c
| App (f,args) ->
- let mkapp f' args' =
- match DAst.get f' with
- | GApp (f',args'') ->
- GApp (f',args''@args')
- | _ -> GApp (f',args')
+ let mkapp f' args' =
+ match DAst.get f' with
+ | GApp (f',args'') ->
+ GApp (f',args''@args')
+ | _ -> GApp (f',args')
in
mkapp (detype d flags avoid env sigma f)
(Array.map_to_list (detype d flags avoid env sigma) args)
@@ -781,12 +781,12 @@ and detype_r d flags avoid env sigma t =
(args @ [detype d flags avoid env sigma c]))
in
if flags.flg_lax || !Flags.in_debugger || !Flags.in_toplevel then
- try noparams ()
- with _ ->
- (* lax mode, used by debug printers only *)
+ try noparams ()
+ with _ ->
+ (* lax mode, used by debug printers only *)
GApp (DAst.make @@ GRef (GlobRef.ConstRef (Projection.constant p), None),
- [detype d flags avoid env sigma c])
- else
+ [detype d flags avoid env sigma c])
+ else
if print_primproj_params () then
try
let c = Retyping.expand_projection (snd env) sigma p c [] in
@@ -800,7 +800,7 @@ and detype_r d flags avoid env sigma t =
| LocalDef _ -> true
| LocalAssum (id,_) ->
try let n = List.index Name.equal (Name id.binder_name) (fst env) in
- isRelN sigma n c
+ isRelN sigma n c
with Not_found -> isVarId sigma id.binder_name c
in
let id,l =
@@ -824,12 +824,12 @@ and detype_r d flags avoid env sigma t =
| Construct (cstr_sp,u) ->
GRef (GlobRef.ConstructRef cstr_sp, detype_instance sigma u)
| Case (ci,p,c,bl) ->
- let comp = computable sigma p (List.length (ci.ci_pp_info.ind_tags)) in
- detype_case comp (detype d flags avoid env sigma)
- (detype_eqns d flags avoid env sigma ci comp)
- (is_nondep_branch sigma) avoid
- (ci.ci_ind,ci.ci_pp_info.style,
- ci.ci_pp_info.cstr_tags,ci.ci_pp_info.ind_tags)
+ let comp = computable sigma p (List.length (ci.ci_pp_info.ind_tags)) in
+ detype_case comp (detype d flags avoid env sigma)
+ (detype_eqns d flags avoid env sigma ci comp)
+ (is_nondep_branch sigma) avoid
+ (ci.ci_ind,ci.ci_pp_info.style,
+ ci.ci_pp_info.cstr_tags,ci.ci_pp_info.ind_tags)
p c bl
| Fix (nvn,recdef) -> detype_fix (detype d) flags avoid env sigma nvn recdef
| CoFix (n,recdef) -> detype_cofix (detype d) flags avoid env sigma n recdef
@@ -870,20 +870,20 @@ and detype_eqn d flags avoid env sigma constr construct_nargs branch =
buildrec new_ids (pat::patlist) new_avoid new_env l b'
| Cast (c,_,_), l -> (* Oui, il y a parfois des cast *)
- buildrec ids patlist avoid env l c
+ buildrec ids patlist avoid env l c
| _, true::l ->
- let pat = DAst.make @@ PatVar Anonymous in
+ let pat = DAst.make @@ PatVar Anonymous in
buildrec ids (pat::patlist) avoid env l b
| _, false::l ->
(* eta-expansion : n'arrivera plus lorsque tous les
termes seront construits à partir de la syntaxe Cases *)
(* nommage de la nouvelle variable *)
- let new_b = applist (lift 1 b, [mkRel 1]) in
+ let new_b = applist (lift 1 b, [mkRel 1]) in
let pat,new_avoid,new_env,new_ids =
- make_pat Anonymous avoid env new_b None mkProp ids in
- buildrec new_ids (pat::patlist) new_avoid new_env l new_b
+ make_pat Anonymous avoid env new_b None mkProp ids in
+ buildrec new_ids (pat::patlist) new_avoid new_env l new_b
in
buildrec Id.Set.empty [] avoid env construct_nargs branch
@@ -912,13 +912,13 @@ let detype_rel_context d flags where avoid env sigma sign =
let na = get_name decl in
let t = get_type decl in
let na',avoid' =
- match where with
- | None -> na,avoid
- | Some c ->
+ match where with
+ | None -> na,avoid
+ | Some c ->
compute_name sigma ~let_in:(is_local_def decl) ~pattern:false flags avoid env na c
in
let b = match decl with
- | LocalAssum _ -> None
+ | LocalAssum _ -> None
| LocalDef (_,b,_) -> Some b
in
let b' = Option.map (detype d flags avoid env sigma) b in
@@ -926,7 +926,7 @@ let detype_rel_context d flags where avoid env sigma sign =
(na',Explicit,b',t') :: aux avoid' (add_name na' b t env) rest
in aux avoid env (List.rev sign)
-let detype_names isgoal avoid nenv env sigma t =
+let detype_names isgoal avoid nenv env sigma t =
let flags = { flg_isgoal = isgoal; flg_lax = false } in
let avoid = Avoid.make ~fast:!fast_name_generation avoid in
detype Now flags avoid (nenv,env) sigma t
@@ -1008,8 +1008,8 @@ let rec subst_cases_pattern subst = DAst.map (function
| PatCstr (((kn,i),j),cpl,n) as pat ->
let kn' = subst_mind subst kn
and cpl' = List.Smart.map (subst_cases_pattern subst) cpl in
- if kn' == kn && cpl' == cpl then pat else
- PatCstr (((kn',i),j),cpl',n)
+ if kn' == kn && cpl' == cpl then pat else
+ PatCstr (((kn',i),j),cpl',n)
)
let (f_subst_genarg, subst_genarg_hook) = Hook.make ()
@@ -1034,25 +1034,25 @@ let rec subst_glob_constr env subst = DAst.map (function
| GApp (r,rl) as raw ->
let r' = subst_glob_constr env subst r
and rl' = List.Smart.map (subst_glob_constr env subst) rl in
- if r' == r && rl' == rl then raw else
- GApp(r',rl')
+ if r' == r && rl' == rl then raw else
+ GApp(r',rl')
| GLambda (n,bk,r1,r2) as raw ->
let r1' = subst_glob_constr env subst r1 and r2' = subst_glob_constr env subst r2 in
- if r1' == r1 && r2' == r2 then raw else
- GLambda (n,bk,r1',r2')
+ if r1' == r1 && r2' == r2 then raw else
+ GLambda (n,bk,r1',r2')
| GProd (n,bk,r1,r2) as raw ->
let r1' = subst_glob_constr env subst r1 and r2' = subst_glob_constr env subst r2 in
- if r1' == r1 && r2' == r2 then raw else
- GProd (n,bk,r1',r2')
+ if r1' == r1 && r2' == r2 then raw else
+ GProd (n,bk,r1',r2')
| GLetIn (n,r1,t,r2) as raw ->
let r1' = subst_glob_constr env subst r1 in
let r2' = subst_glob_constr env subst r2 in
let t' = Option.Smart.map (subst_glob_constr env subst) t in
- if r1' == r1 && t == t' && r2' == r2 then raw else
- GLetIn (n,r1',t',r2')
+ if r1' == r1 && t == t' && r2' == r2 then raw else
+ GLetIn (n,r1',t',r2')
| GCases (sty,rtno,rl,branches) as raw ->
let open CAst in
@@ -1067,21 +1067,21 @@ let rec subst_glob_constr env subst = DAst.map (function
if a == a' && topt == topt' then y else (a',(n,topt'))) rl
and branches' = List.Smart.map
(fun ({loc;v=(idl,cpl,r)} as branch) ->
- let cpl' =
+ let cpl' =
List.Smart.map (subst_cases_pattern subst) cpl
and r' = subst_glob_constr env subst r in
- if cpl' == cpl && r' == r then branch else
+ if cpl' == cpl && r' == r then branch else
CAst.(make ?loc (idl,cpl',r')))
- branches
+ branches
in
- if rtno' == rtno && rl' == rl && branches' == branches then raw else
- GCases (sty,rtno',rl',branches')
+ if rtno' == rtno && rl' == rl && branches' == branches then raw else
+ GCases (sty,rtno',rl',branches')
| GLetTuple (nal,(na,po),b,c) as raw ->
let po' = Option.Smart.map (subst_glob_constr env subst) po
and b' = subst_glob_constr env subst b
and c' = subst_glob_constr env subst c in
- if po' == po && b' == b && c' == c then raw else
+ if po' == po && b' == b && c' == c then raw else
GLetTuple (nal,(na,po'),b',c')
| GIf (c,(na,po),b1,b2) as raw ->
@@ -1089,7 +1089,7 @@ let rec subst_glob_constr env subst = DAst.map (function
and b1' = subst_glob_constr env subst b1
and b2' = subst_glob_constr env subst b2
and c' = subst_glob_constr env subst c in
- if c' == c && po' == po && b1' == b1 && b2' == b2 then raw else
+ if c' == c && po' == po && b1' == b1 && b2' == b2 then raw else
GIf (c',(na,po'),b1',b2')
| GRec (fix,ida,bl,ra1,ra2) as raw ->
@@ -1101,8 +1101,8 @@ let rec subst_glob_constr env subst = DAst.map (function
let obd' = Option.Smart.map (subst_glob_constr env subst) obd in
if ty'==ty && obd'==obd then dcl else (na,k,obd',ty')))
bl in
- if ra1' == ra1 && ra2' == ra2 && bl'==bl then raw else
- GRec (fix,ida,bl',ra1',ra2')
+ if ra1' == ra1 && ra2' == ra2 && bl'==bl then raw else
+ GRec (fix,ida,bl',ra1',ra2')
| GHole (knd, naming, solve) as raw ->
let nknd = match knd with
diff --git a/pretyping/detyping.mli b/pretyping/detyping.mli
index 9eb014aa62..21957b4775 100644
--- a/pretyping/detyping.mli
+++ b/pretyping/detyping.mli
@@ -41,9 +41,9 @@ val subst_glob_constr : env -> substitution -> glob_constr -> glob_constr
val factorize_eqns : 'a cases_clauses_g -> 'a disjunctive_cases_clauses_g
-(** [detype isgoal avoid ctx c] turns a closed [c], into a glob_constr
- de Bruijn indexes are turned to bound names, avoiding names in [avoid]
- [isgoal] tells if naming must avoid global-level synonyms as intro does
+(** [detype isgoal avoid ctx c] turns a closed [c], into a glob_constr
+ de Bruijn indexes are turned to bound names, avoiding names in [avoid]
+ [isgoal] tells if naming must avoid global-level synonyms as intro does
[ctx] gives the names of the free variables *)
val detype_names : bool -> Id.Set.t -> names_context -> env -> evar_map -> constr -> glob_constr
@@ -52,7 +52,7 @@ val detype : 'a delay -> ?lax:bool -> bool -> Id.Set.t -> env -> evar_map -> con
val detype_sort : evar_map -> Sorts.t -> glob_sort
-val detype_rel_context : 'a delay -> ?lax:bool -> constr option -> Id.Set.t -> (names_context * env) ->
+val detype_rel_context : 'a delay -> ?lax:bool -> constr option -> Id.Set.t -> (names_context * env) ->
evar_map -> rel_context -> 'a glob_decl_g list
val share_pattern_names :
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index 73d0c6f821..2130d4ce90 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -96,7 +96,7 @@ let unfold_projection env evd ts p c =
if TransparentState.is_transparent_constant ts cst then
Some (mkProj (Projection.unfold p, c))
else None
-
+
let eval_flexible_term ts env evd c =
match EConstr.kind evd c with
| Const (c, u) ->
@@ -111,12 +111,12 @@ let eval_flexible_term ts env evd c =
| Var id ->
(try
if TransparentState.is_transparent_variable ts id then
- env |> lookup_named id |> NamedDecl.get_value
- else None
+ env |> lookup_named id |> NamedDecl.get_value
+ else None
with Not_found -> None)
| LetIn (_,b,_,c) -> Some (subst1 b c)
| Lambda _ -> Some c
- | Proj (p, c) ->
+ | Proj (p, c) ->
if Projection.unfolded p then assert false
else unfold_projection env evd ts p c
| _ -> assert false
@@ -227,7 +227,7 @@ let occur_rigidly flags env evd (evk,_) t =
| Normal b -> b
| Reducible -> false
-(* [check_conv_record env sigma (t1,stack1) (t2,stack2)] tries to decompose
+(* [check_conv_record env sigma (t1,stack1) (t2,stack2)] tries to decompose
the problem (t1 stack1) = (t2 stack2) into a problem
stack1 = params1@[c1]@extra_args1
@@ -256,12 +256,12 @@ let check_conv_record env sigma (t1,sk1) (t2,sk2) =
let _, a, b = destProd sigma t2 in
if noccurn sigma 1 b then
lookup_canonical_conversion (proji, Prod_cs),
- (Stack.append_app [|a;pop b|] Stack.empty)
+ (Stack.append_app [|a;pop b|] Stack.empty)
else raise Not_found
| Sort s ->
let s = ESorts.kind sigma s in
- lookup_canonical_conversion
- (proji, Sort_cs (Sorts.family s)),[]
+ lookup_canonical_conversion
+ (proji, Sort_cs (Sorts.family s)),[]
| Proj (p, c) ->
let c2 = GlobRef.ConstRef (Projection.constant p) in
let c = Retyping.expand_projection env sigma p c [] in
@@ -269,11 +269,11 @@ let check_conv_record env sigma (t1,sk1) (t2,sk2) =
let sk2 = Stack.append_app args sk2 in
lookup_canonical_conversion (proji, Const_cs c2), sk2
| _ ->
- let (c2, _) = Termops.global_of_constr sigma t2 in
- lookup_canonical_conversion (proji, Const_cs c2),sk2
+ let (c2, _) = Termops.global_of_constr sigma t2 in
+ lookup_canonical_conversion (proji, Const_cs c2),sk2
with Not_found ->
- let (c, cs) = lookup_canonical_conversion (proji,Default_cs) in
- (c,cs),[]
+ let (c, cs) = lookup_canonical_conversion (proji,Default_cs) in
+ (c,cs),[]
in
let t', { o_DEF = c; o_CTX = ctx; o_INJ=n; o_TABS = bs;
o_TPARAMS = params; o_NPARAMS = nparams; o_TCOMPS = us } = canon_s in
@@ -283,9 +283,9 @@ let check_conv_record env sigma (t1,sk1) (t2,sk2) =
match arg with
| Some c -> (* A primitive projection applied to c *)
let ty = Retyping.get_type_of ~lax:true env sigma c in
- let (i,u), ind_args =
- try Inductiveops.find_mrectype env sigma ty
- with _ -> raise Not_found
+ let (i,u), ind_args =
+ try Inductiveops.find_mrectype env sigma ty
+ with _ -> raise Not_found
in Stack.append_app_list ind_args Stack.empty, c, sk1
| None ->
match Stack.strip_n_app nparams sk1 with
@@ -338,8 +338,8 @@ let ise_and evd l =
| [f] -> f i
| f1::l ->
match f1 i with
- | Success i' -> ise_and i' l
- | UnifFailure _ as x -> x in
+ | Success i' -> ise_and i' l
+ | UnifFailure _ as x -> x in
ise_and evd l
let ise_exact ise x1 x2 =
@@ -353,8 +353,8 @@ let ise_array2 evd f v1 v2 =
| -1 -> Success i
| n ->
match f i v1.(n) v2.(n) with
- | Success i' -> allrec i' (n-1)
- | UnifFailure _ as x -> x in
+ | Success i' -> allrec i' (n-1)
+ | UnifFailure _ as x -> x in
let lv1 = Array.length v1 in
if Int.equal lv1 (Array.length v2) then allrec evd (pred lv1)
else UnifFailure (evd,NotSameArgSize)
@@ -367,8 +367,8 @@ let rec ise_app_stack2 env f evd sk1 sk2 =
let (t1,l1) = Stack.decomp_node_last node1 q1 in
let (t2,l2) = Stack.decomp_node_last node2 q2 in
begin match ise_app_stack2 env f evd l1 l2 with
- |(_,UnifFailure _) as x -> x
- |x,Success i' -> x,f env i' CONV t1 t2
+ |(_,UnifFailure _) as x -> x
+ |x,Success i' -> x,f env i' CONV t1 t2
end
| _, _ -> (sk1,sk2), Success evd
@@ -385,8 +385,8 @@ let ise_stack2 no_app env evd f sk1 sk2 =
| Stack.Case (_,t1,c1,_)::q1, Stack.Case (_,t2,c2,_)::q2 ->
(match f env i CONV t1 t2 with
| Success i' ->
- (match ise_array2 i' (fun ii -> f env ii CONV) c1 c2 with
- | Success i'' -> ise_stack2 true i'' q1 q2
+ (match ise_array2 i' (fun ii -> f env ii CONV) c1 c2 with
+ | Success i'' -> ise_stack2 true i'' q1 q2
| UnifFailure _ as x -> fail x)
| UnifFailure _ as x -> fail x)
| Stack.Proj (p1,_)::q1, Stack.Proj (p2,_)::q2 ->
@@ -397,18 +397,18 @@ let ise_stack2 no_app env evd f sk1 sk2 =
Stack.Fix (((li2, i2),(_,tys2,bds2)),a2,_)::q2 ->
if Int.equal i1 i2 && Array.equal Int.equal li1 li2 then
match ise_and i [
- (fun i -> ise_array2 i (fun ii -> f env ii CONV) tys1 tys2);
- (fun i -> ise_array2 i (fun ii -> f (push_rec_types recdef1 env) ii CONV) bds1 bds2);
- (fun i -> ise_exact (ise_stack2 false i) a1 a2)] with
+ (fun i -> ise_array2 i (fun ii -> f env ii CONV) tys1 tys2);
+ (fun i -> ise_array2 i (fun ii -> f (push_rec_types recdef1 env) ii CONV) bds1 bds2);
+ (fun i -> ise_exact (ise_stack2 false i) a1 a2)] with
| Success i' -> ise_stack2 true i' q1 q2
| UnifFailure _ as x -> fail x
else fail (UnifFailure (i,NotSameHead))
| Stack.App _ :: _, Stack.App _ :: _ ->
if no_app && deep then fail ((*dummy*)UnifFailure(i,NotSameHead)) else
- begin match ise_app_stack2 env f i sk1 sk2 with
- |_,(UnifFailure _ as x) -> fail x
- |(l1, l2), Success i' -> ise_stack2 true i' l1 l2
- end
+ begin match ise_app_stack2 env f i sk1 sk2 with
+ |_,(UnifFailure _ as x) -> fail x
+ |(l1, l2), Success i' -> ise_stack2 true i' l1 l2
+ end
|_, _ -> fail (UnifFailure (i,(* Maybe improve: *) NotSameHead))
in ise_stack2 false evd (List.rev sk1) (List.rev sk2)
@@ -425,21 +425,21 @@ let exact_ise_stack2 env evd f sk1 sk2 =
| Stack.Fix (((li1, i1),(_,tys1,bds1 as recdef1)),a1,_)::q1,
Stack.Fix (((li2, i2),(_,tys2,bds2)),a2,_)::q2 ->
if Int.equal i1 i2 && Array.equal Int.equal li1 li2 then
- ise_and i [
- (fun i -> ise_stack2 i q1 q2);
- (fun i -> ise_array2 i (fun ii -> f env ii CONV) tys1 tys2);
- (fun i -> ise_array2 i (fun ii -> f (push_rec_types recdef1 env) ii CONV) bds1 bds2);
- (fun i -> ise_stack2 i a1 a2)]
+ ise_and i [
+ (fun i -> ise_stack2 i q1 q2);
+ (fun i -> ise_array2 i (fun ii -> f env ii CONV) tys1 tys2);
+ (fun i -> ise_array2 i (fun ii -> f (push_rec_types recdef1 env) ii CONV) bds1 bds2);
+ (fun i -> ise_stack2 i a1 a2)]
else UnifFailure (i,NotSameHead)
| Stack.Proj (p1,_)::q1, Stack.Proj (p2,_)::q2 ->
if Projection.Repr.equal (Projection.repr p1) (Projection.repr p2)
then ise_stack2 i q1 q2
else (UnifFailure (i, NotSameHead))
| Stack.App _ :: _, Stack.App _ :: _ ->
- begin match ise_app_stack2 env f i sk1 sk2 with
- |_,(UnifFailure _ as x) -> x
- |(l1, l2), Success i' -> ise_stack2 i' l1 l2
- end
+ begin match ise_app_stack2 env f i sk1 sk2 with
+ |_,(UnifFailure _ as x) -> x
+ |(l1, l2), Success i' -> ise_stack2 i' l1 l2
+ end
|_, _ -> UnifFailure (i,(* Maybe improve: *) NotSameHead)
in
if Reductionops.Stack.compare_shape sk1 sk2 then
@@ -482,23 +482,23 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
| None -> UnifFailure (evd, ConversionFailed (env,term1,term2))
| exception Univ.UniverseInconsistency e -> UnifFailure (evd, UnifUnivInconsistency e)
in
- match e with
- | UnifFailure (evd, e) when not (is_ground_env evd env) -> None
- | _ -> Some e)
+ match e with
+ | UnifFailure (evd, e) when not (is_ground_env evd env) -> None
+ | _ -> Some e)
else None
in
match ground_test with
| Some result -> result
| None ->
(* Until pattern-unification is used consistently, use nohdbeta to not
- destroy beta-redexes that can be used for 1st-order unification *)
+ destroy beta-redexes that can be used for 1st-order unification *)
let term1 = apprec_nohdbeta flags env evd term1 in
let term2 = apprec_nohdbeta flags env evd term2 in
- let default () =
+ let default () =
evar_eqappr_x flags env evd pbty
(whd_nored_state evd (term1,Stack.empty))
(whd_nored_state evd (term2,Stack.empty))
- in
+ in
begin match EConstr.kind evd term1, EConstr.kind evd term2 with
| Evar ev, _ when Evd.is_undefined evd (fst ev) && not (is_frozen flags ev) ->
(match solve_simple_eqn (conv_fun evar_conv_x) flags env evd
@@ -510,7 +510,7 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
NotClean: pruning in solve_simple_eqn is incomplete wrt
Miller patterns *)
default ()
- | x -> x)
+ | x -> x)
| _, Evar ev when Evd.is_undefined evd (fst ev) && not (is_frozen flags ev) ->
(match solve_simple_eqn (conv_fun evar_conv_x) flags env evd
(position_problem false pbty,ev,term1) with
@@ -520,7 +520,7 @@ let rec evar_conv_x flags env evd pbty term1 term2 =
NotClean: pruning in solve_simple_eqn is incomplete wrt
Miller patterns *)
default ()
- | x -> x)
+ | x -> x)
| _ -> default ()
end
@@ -533,10 +533,10 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
match is_unification_pattern_evar env evd ev lF tM with
| None -> fallback ()
| Some l1' -> (* Miller-Pfenning's patterns unification *)
- let t2 = tM in
- let t2 = solve_pattern_eqn env evd l1' t2 in
+ let t2 = tM in
+ let t2 = solve_pattern_eqn env evd l1' t2 in
solve_simple_eqn (conv_fun evar_conv_x) flags env evd
- (position_problem on_left pbty,ev,t2)
+ (position_problem on_left pbty,ev,t2)
in
let consume_stack on_left (termF,skF) (termO,skO) evd =
let switch f a b = if on_left then f a b else f b a in
@@ -628,12 +628,12 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
let not_only_app = Stack.not_purely_applicative skM in
match Stack.list_of_app_stack skF with
| None -> quick_fail evd
- | Some lF ->
+ | Some lF ->
let tM = Stack.zip evd apprM in
- miller_pfenning on_left
- (fun () -> if not_only_app then (* Postpone the use of an heuristic *)
+ miller_pfenning on_left
+ (fun () -> if not_only_app then (* Postpone the use of an heuristic *)
switch (fun x y -> Success (Evarutil.add_unification_pb (pbty,env,x,y) i)) (Stack.zip evd apprF) tM
- else quick_fail i)
+ else quick_fail i)
ev lF tM i
in
let flex_maybeflex on_left ev (termF,skF as apprF) (termM, skM as apprM) vM =
@@ -641,36 +641,36 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
let delta i =
switch (evar_eqappr_x flags env i pbty) apprF
(whd_betaiota_deltazeta_for_iota_state flags.open_ts env i (vM,skM))
- in
+ in
let default i = ise_try i [miller on_left ev apprF apprM;
consume on_left apprF apprM;
delta]
in
match EConstr.kind evd termM with
| Proj (p, c) when not (Stack.is_empty skF) ->
- (* Might be ?X args = p.c args', and we have to eta-expand the
- primitive projection if |args| >= |args'|+1. *)
- let nargsF = Stack.args_size skF and nargsM = Stack.args_size skM in
- begin
- (* ?X argsF' ~= (p.c ..) argsM' -> ?X ~= (p.c ..), no need to expand *)
- if nargsF <= nargsM then default evd
- else
- let f =
- try
- let termM' = Retyping.expand_projection env evd p c [] in
+ (* Might be ?X args = p.c args', and we have to eta-expand the
+ primitive projection if |args| >= |args'|+1. *)
+ let nargsF = Stack.args_size skF and nargsM = Stack.args_size skM in
+ begin
+ (* ?X argsF' ~= (p.c ..) argsM' -> ?X ~= (p.c ..), no need to expand *)
+ if nargsF <= nargsM then default evd
+ else
+ let f =
+ try
+ let termM' = Retyping.expand_projection env evd p c [] in
let apprM' =
whd_betaiota_deltazeta_for_iota_state flags.open_ts env evd (termM',skM)
- in
- let delta' i =
+ in
+ let delta' i =
switch (evar_eqappr_x flags env i pbty) apprF apprM'
- in
+ in
fun i -> ise_try i [miller on_left ev apprF apprM';
consume on_left apprF apprM'; delta']
- with Retyping.RetypeError _ ->
- (* Happens thanks to w_unify building ill-typed terms *)
- default
- in f evd
- end
+ with Retyping.RetypeError _ ->
+ (* Happens thanks to w_unify building ill-typed terms *)
+ default
+ in f evd
+ end
| _ -> default evd
in
let flex_rigid on_left ev (termF, skF as apprF) (termR, skR as apprR) =
@@ -772,17 +772,17 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
let app_empty = match sk1, sk2 with [], [] -> true | _ -> false in
(* Evar must be undefined since we have flushed evars *)
let () = if !debug_unification then
- let open Pp in
+ let open Pp in
Feedback.msg_debug (v 0 (pr_state env evd appr1 ++ cut () ++ pr_state env evd appr2 ++ cut ())) in
match (flex_kind_of_term flags env evd term1 sk1,
flex_kind_of_term flags env evd term2 sk2) with
| Flexible (sp1,al1), Flexible (sp2,al2) ->
(* sk1[?ev1] =? sk2[?ev2] *)
let f1 i = first_order env i term1 term2 sk1 sk2
- and f2 i =
+ and f2 i =
if Evar.equal sp1 sp2 then
match ise_stack2 false env i (evar_conv_x flags) sk1 sk2 with
- |None, Success i' ->
+ |None, Success i' ->
Success (solve_refl (fun flags p env i pbty a1 a2 ->
let flags =
match p with
@@ -791,7 +791,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
in
is_success (evar_conv_x flags env i pbty a1 a2)) flags
env i' (position_problem true pbty) sp1 al1 al2)
- |_, (UnifFailure _ as x) -> x
+ |_, (UnifFailure _ as x) -> x
|Some _, _ -> UnifFailure (i,NotSameArgSize)
else UnifFailure (i,NotSameHead)
and f3 i = miller true (sp1,al1) appr1 appr2 i
@@ -810,7 +810,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
| Flexible ev1, MaybeFlexible v2 ->
flex_maybeflex true ev1 appr1 appr2 v2
- | MaybeFlexible v1, Flexible ev2 ->
+ | MaybeFlexible v1, Flexible ev2 ->
flex_maybeflex false ev2 appr2 appr1 v1
| MaybeFlexible v1, MaybeFlexible v2 -> begin
@@ -822,9 +822,9 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
[(fun i -> evar_conv_x flags env i CUMUL t1 t2);
(fun i -> evar_conv_x flags env i CUMUL t2 t1)]);
(fun i -> evar_conv_x flags env i CONV b1 b2);
- (fun i ->
- let b = nf_evar i b1 in
- let t = nf_evar i t1 in
+ (fun i ->
+ let b = nf_evar i b1 in
+ let t = nf_evar i t1 in
let na = Nameops.Name.pick_annot na1 na2 in
evar_conv_x flags (push_rel (RelDecl.LocalDef (na,b,t)) env) i pbty c'1 c'2);
(fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2)]
@@ -832,105 +832,105 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
let out1 = whd_betaiota_deltazeta_for_iota_state flags.open_ts env i (v1,sk1)
and out2 = whd_betaiota_deltazeta_for_iota_state flags.open_ts env i (v2,sk2)
in evar_eqappr_x flags env i pbty out1 out2
- in
- ise_try evd [f1; f2]
+ in
+ ise_try evd [f1; f2]
| Proj (p, c), Proj (p', c') when Projection.repr_equal p p' ->
- let f1 i =
- ise_and i
+ let f1 i =
+ ise_and i
[(fun i -> evar_conv_x flags env i CONV c c');
(fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2)]
- and f2 i =
+ and f2 i =
let out1 = whd_betaiota_deltazeta_for_iota_state flags.open_ts env i (v1,sk1)
and out2 = whd_betaiota_deltazeta_for_iota_state flags.open_ts env i (v2,sk2)
in evar_eqappr_x flags env i pbty out1 out2
- in
- ise_try evd [f1; f2]
-
- (* Catch the p.c ~= p c' cases *)
- | Proj (p,c), Const (p',u) when Constant.equal (Projection.constant p) p' ->
- let res =
- try Some (destApp evd (Retyping.expand_projection env evd p c []))
- with Retyping.RetypeError _ -> None
- in
- (match res with
- | Some (f1,args1) ->
+ in
+ ise_try evd [f1; f2]
+
+ (* Catch the p.c ~= p c' cases *)
+ | Proj (p,c), Const (p',u) when Constant.equal (Projection.constant p) p' ->
+ let res =
+ try Some (destApp evd (Retyping.expand_projection env evd p c []))
+ with Retyping.RetypeError _ -> None
+ in
+ (match res with
+ | Some (f1,args1) ->
evar_eqappr_x flags env evd pbty (f1,Stack.append_app args1 sk1)
appr2
- | None -> UnifFailure (evd,NotSameHead))
-
- | Const (p,u), Proj (p',c') when Constant.equal p (Projection.constant p') ->
- let res =
- try Some (destApp evd (Retyping.expand_projection env evd p' c' []))
- with Retyping.RetypeError _ -> None
- in
- (match res with
- | Some (f2,args2) ->
+ | None -> UnifFailure (evd,NotSameHead))
+
+ | Const (p,u), Proj (p',c') when Constant.equal p (Projection.constant p') ->
+ let res =
+ try Some (destApp evd (Retyping.expand_projection env evd p' c' []))
+ with Retyping.RetypeError _ -> None
+ in
+ (match res with
+ | Some (f2,args2) ->
evar_eqappr_x flags env evd pbty appr1 (f2,Stack.append_app args2 sk2)
- | None -> UnifFailure (evd,NotSameHead))
-
- | _, _ ->
- let f1 i =
- (* Gather the universe constraints that would make term1 and term2 equal.
- If these only involve unifications of flexible universes to other universes,
- allow this identification (first-order unification of universes). Otherwise
- fallback to unfolding.
- *)
+ | None -> UnifFailure (evd,NotSameHead))
+
+ | _, _ ->
+ let f1 i =
+ (* Gather the universe constraints that would make term1 and term2 equal.
+ If these only involve unifications of flexible universes to other universes,
+ allow this identification (first-order unification of universes). Otherwise
+ fallback to unfolding.
+ *)
let univs = EConstr.eq_constr_universes env evd term1 term2 in
match univs with
| Some univs ->
- ise_and i [(fun i ->
- try Success (Evd.add_universe_constraints i univs)
- with UniversesDiffer -> UnifFailure (i,NotSameHead)
- | Univ.UniverseInconsistency p -> UnifFailure (i, UnifUnivInconsistency p));
+ ise_and i [(fun i ->
+ try Success (Evd.add_universe_constraints i univs)
+ with UniversesDiffer -> UnifFailure (i,NotSameHead)
+ | Univ.UniverseInconsistency p -> UnifFailure (i, UnifUnivInconsistency p));
(fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2)]
| None ->
UnifFailure (i,NotSameHead)
- and f2 i =
- (try
+ and f2 i =
+ (try
if not flags.with_cs then raise Not_found
else conv_record flags env i
(try check_conv_record env i appr1 appr2
- with Not_found -> check_conv_record env i appr2 appr1)
+ with Not_found -> check_conv_record env i appr2 appr1)
with Not_found -> UnifFailure (i,NoCanonicalStructure))
- and f3 i =
+ and f3 i =
(* heuristic: unfold second argument first, exception made
if the first argument is a beta-redex (expand a constant
only if necessary) or the second argument is potentially
usable as a canonical projection or canonical value *)
let rec is_unnamed (hd, args) = match EConstr.kind i hd with
| (Var _|Construct _|Ind _|Const _|Prod _|Sort _|Int _ |Float _) ->
- Stack.not_purely_applicative args
+ Stack.not_purely_applicative args
| (CoFix _|Meta _|Rel _)-> true
| Evar _ -> Stack.not_purely_applicative args
- (* false (* immediate solution without Canon Struct *)*)
+ (* false (* immediate solution without Canon Struct *)*)
| Lambda _ -> assert (match args with [] -> true | _ -> false); true
| LetIn (_,b,_,c) -> is_unnamed
(whd_betaiota_deltazeta_for_iota_state
flags.open_ts env i (subst1 b c, args))
- | Fix _ -> true (* Partially applied fix can be the result of a whd call *)
- | Proj (p, _) -> Projection.unfolded p || Stack.not_purely_applicative args
+ | Fix _ -> true (* Partially applied fix can be the result of a whd call *)
+ | Proj (p, _) -> Projection.unfolded p || Stack.not_purely_applicative args
| Case _ | App _| Cast _ -> assert false in
let rhs_is_stuck_and_unnamed () =
- let applicative_stack = fst (Stack.strip_app sk2) in
- is_unnamed
+ let applicative_stack = fst (Stack.strip_app sk2) in
+ is_unnamed
(whd_betaiota_deltazeta_for_iota_state
flags.open_ts env i (v2, applicative_stack)) in
let rhs_is_already_stuck =
rhs_is_already_stuck || rhs_is_stuck_and_unnamed () in
- if (EConstr.isLambda i term1 || rhs_is_already_stuck)
- && (not (Stack.not_purely_applicative sk1)) then
+ if (EConstr.isLambda i term1 || rhs_is_already_stuck)
+ && (not (Stack.not_purely_applicative sk1)) then
evar_eqappr_x ~rhs_is_already_stuck flags env i pbty
- (whd_betaiota_deltazeta_for_iota_state
+ (whd_betaiota_deltazeta_for_iota_state
flags.open_ts env i(v1,sk1))
appr2
- else
+ else
evar_eqappr_x flags env i pbty appr1
- (whd_betaiota_deltazeta_for_iota_state
+ (whd_betaiota_deltazeta_for_iota_state
flags.open_ts env i (v2,sk2))
- in
- ise_try evd [f1; f2; f3]
+ in
+ ise_try evd [f1; f2; f3]
end
| Rigid, Rigid when EConstr.isLambda evd term1 && EConstr.isLambda evd term2 ->
@@ -939,7 +939,7 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
ise_and evd
[(fun i -> evar_conv_x flags env i CONV c1 c2);
(fun i ->
- let c = nf_evar i c1 in
+ let c = nf_evar i c1 in
let na = Nameops.Name.pick_annot na1 na2 in
evar_conv_x flags (push_rel (RelDecl.LocalAssum (na,c)) env) i CONV c'1 c'2);
(* When in modulo_betaiota = false case, lambda's are not reduced *)
@@ -949,31 +949,31 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
| Rigid, Flexible ev2 -> flex_rigid false ev2 appr2 appr1
| MaybeFlexible v1, Rigid ->
- let f3 i =
- (try
+ let f3 i =
+ (try
if not flags.with_cs then raise Not_found
else conv_record flags env i (check_conv_record env i appr1 appr2)
with Not_found -> UnifFailure (i,NoCanonicalStructure))
- and f4 i =
+ and f4 i =
evar_eqappr_x flags env i pbty
- (whd_betaiota_deltazeta_for_iota_state
+ (whd_betaiota_deltazeta_for_iota_state
flags.open_ts env i (v1,sk1))
appr2
- in
- ise_try evd [f3; f4]
+ in
+ ise_try evd [f3; f4]
| Rigid, MaybeFlexible v2 ->
- let f3 i =
- (try
+ let f3 i =
+ (try
if not flags.with_cs then raise Not_found
else conv_record flags env i (check_conv_record env i appr2 appr1)
with Not_found -> UnifFailure (i,NoCanonicalStructure))
- and f4 i =
+ and f4 i =
evar_eqappr_x flags env i pbty appr1
- (whd_betaiota_deltazeta_for_iota_state
+ (whd_betaiota_deltazeta_for_iota_state
flags.open_ts env i (v2,sk2))
- in
- ise_try evd [f3; f4]
+ in
+ ise_try evd [f3; f4]
(* Eta-expansion *)
| Rigid, _ when isLambda evd term1 && (* if ever ill-typed: *) List.is_empty sk1 ->
@@ -985,39 +985,39 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
| Rigid, Rigid -> begin
match EConstr.kind evd term1, EConstr.kind evd term2 with
- | Sort s1, Sort s2 when app_empty ->
- (try
+ | Sort s1, Sort s2 when app_empty ->
+ (try
let s1 = ESorts.kind evd s1 in
let s2 = ESorts.kind evd s2 in
- let evd' =
- if pbty == CONV
- then Evd.set_eq_sort env evd s1 s2
- else Evd.set_leq_sort env evd s1 s2
- in Success evd'
- with Univ.UniverseInconsistency p ->
+ let evd' =
+ if pbty == CONV
+ then Evd.set_eq_sort env evd s1 s2
+ else Evd.set_leq_sort env evd s1 s2
+ in Success evd'
+ with Univ.UniverseInconsistency p ->
UnifFailure (evd,UnifUnivInconsistency p)
- | e when CErrors.noncritical e -> UnifFailure (evd,NotSameHead))
+ | e when CErrors.noncritical e -> UnifFailure (evd,NotSameHead))
| Prod (n1,c1,c'1), Prod (n2,c2,c'2) when app_empty ->
ise_and evd
[(fun i -> evar_conv_x flags env i CONV c1 c2);
(fun i ->
- let c = nf_evar i c1 in
+ let c = nf_evar i c1 in
let na = Nameops.Name.pick_annot n1 n2 in
evar_conv_x flags (push_rel (RelDecl.LocalAssum (na,c)) env) i pbty c'1 c'2)]
- | Rel x1, Rel x2 ->
- if Int.equal x1 x2 then
+ | Rel x1, Rel x2 ->
+ if Int.equal x1 x2 then
exact_ise_stack2 env evd (evar_conv_x flags) sk1 sk2
else UnifFailure (evd,NotSameHead)
- | Var var1, Var var2 ->
- if Id.equal var1 var2 then
+ | Var var1, Var var2 ->
+ if Id.equal var1 var2 then
exact_ise_stack2 env evd (evar_conv_x flags) sk1 sk2
else UnifFailure (evd,NotSameHead)
- | Const _, Const _
- | Ind _, Ind _
+ | Const _, Const _
+ | Ind _, Ind _
| Construct _, Construct _
| Int _, Int _
| Float _, Float _ ->
@@ -1032,19 +1032,19 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
|Some _, _ -> UnifFailure (evd,NotSameArgSize)
else UnifFailure (evd,NotSameHead)
- | Construct u, _ ->
+ | Construct u, _ ->
eta_constructor flags env evd sk1 u sk2 term2
-
- | _, Construct u ->
+
+ | _, Construct u ->
eta_constructor flags env evd sk2 u sk1 term1
| Fix ((li1, i1),(_,tys1,bds1 as recdef1)), Fix ((li2, i2),(_,tys2,bds2)) -> (* Partially applied fixs *)
- if Int.equal i1 i2 && Array.equal Int.equal li1 li2 then
+ if Int.equal i1 i2 && Array.equal Int.equal li1 li2 then
ise_and evd [
(fun i -> ise_array2 i (fun i' -> evar_conv_x flags env i' CONV) tys1 tys2);
(fun i -> ise_array2 i (fun i' -> evar_conv_x flags (push_rec_types recdef1 env) i' CONV) bds1 bds2);
(fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2)]
- else UnifFailure (evd, NotSameHead)
+ else UnifFailure (evd, NotSameHead)
| CoFix (i1,(_,tys1,bds1 as recdef1)), CoFix (i2,(_,tys2,bds2)) ->
if Int.equal i1 i2 then
@@ -1053,20 +1053,20 @@ and evar_eqappr_x ?(rhs_is_already_stuck = false) flags env evd pbty
(fun i -> evar_conv_x flags env i CONV) tys1 tys2);
(fun i -> ise_array2 i
(fun i -> evar_conv_x flags (push_rec_types recdef1 env) i CONV)
- bds1 bds2);
+ bds1 bds2);
(fun i -> exact_ise_stack2 env i
(evar_conv_x flags) sk1 sk2)]
else UnifFailure (evd,NotSameHead)
- | (Meta _, _) | (_, Meta _) ->
+ | (Meta _, _) | (_, Meta _) ->
begin match ise_stack2 true env evd (evar_conv_x flags) sk1 sk2 with
- |_, (UnifFailure _ as x) -> x
+ |_, (UnifFailure _ as x) -> x
|None, Success i' -> evar_conv_x flags env i' CONV term1 term2
|Some (sk1',sk2'), Success i' -> evar_conv_x flags env i' CONV (Stack.zip i' (term1,sk1')) (Stack.zip i' (term2,sk2'))
- end
+ end
| (Ind _ | Sort _ | Prod _ | CoFix _ | Fix _ | Rel _ | Var _ | Const _ | Int _ | Float _ | Evar _ | Lambda _), _ ->
- UnifFailure (evd,NotSameHead)
+ UnifFailure (evd,NotSameHead)
| _, (Ind _ | Sort _ | Prod _ | CoFix _ | Fix _ | Rel _ | Var _ | Const _ | Int _ | Evar _ | Lambda _) ->
UnifFailure (evd,NotSameHead)
| Case _, _ -> UnifFailure (evd,NotSameHead)
@@ -1103,32 +1103,32 @@ and conv_record flags env evd (ctx,(h,h2),c,bs,(params,params1),(us,us2),(sk1,sk
if Reductionops.Stack.compare_shape sk1 sk2 then
let (evd',ks,_,test) =
List.fold_left
- (fun (i,ks,m,test) b ->
- if match n with Some n -> Int.equal m n | None -> false then
- let ty = Retyping.get_type_of env i t2 in
+ (fun (i,ks,m,test) b ->
+ if match n with Some n -> Int.equal m n | None -> false then
+ let ty = Retyping.get_type_of env i t2 in
let test i = evar_conv_x flags env i CUMUL ty (substl ks b) in
- (i,t2::ks, m-1, test)
- else
- let dloc = Loc.tag Evar_kinds.InternalHole in
+ (i,t2::ks, m-1, test)
+ else
+ let dloc = Loc.tag Evar_kinds.InternalHole in
let (i', ev) = Evarutil.new_evar env i ~src:dloc (substl ks b) in
- (i', ev :: ks, m - 1,test))
- (evd,[],List.length bs,fun i -> Success i) bs
+ (i', ev :: ks, m - 1,test))
+ (evd,[],List.length bs,fun i -> Success i) bs
in
let app = mkApp (c, Array.rev_of_list ks) in
ise_and evd'
[(fun i ->
- exact_ise_stack2 env i
+ exact_ise_stack2 env i
(fun env' i' cpb x1 x -> evar_conv_x flags env' i' cpb x1 (substl ks x))
params1 params);
(fun i ->
- exact_ise_stack2 env i
+ exact_ise_stack2 env i
(fun env' i' cpb u1 u -> evar_conv_x flags env' i' cpb u1 (substl ks u))
us2 us);
(fun i -> evar_conv_x flags env i CONV c1 app);
(fun i -> exact_ise_stack2 env i (evar_conv_x flags) sk1 sk2);
test;
(fun i -> evar_conv_x flags env i CONV h2
- (fst (decompose_app_vect i (substl ks h))))]
+ (fst (decompose_app_vect i (substl ks h))))]
else UnifFailure(evd,(*dummy*)NotSameHead)
and eta_constructor flags env evd sk1 ((ind, i), u) sk2 term2 =
@@ -1137,18 +1137,18 @@ and eta_constructor flags env evd sk1 ((ind, i), u) sk2 term2 =
match get_projections env ind with
| Some projs when mib.mind_finite == BiFinite ->
let pars = mib.mind_nparams in
- (try
- let l1' = Stack.tail pars sk1 in
- let l2' =
- let term = Stack.zip evd (term2,sk2) in
- List.map (fun p -> EConstr.mkProj (Projection.make p false, term)) (Array.to_list projs)
- in
+ (try
+ let l1' = Stack.tail pars sk1 in
+ let l2' =
+ let term = Stack.zip evd (term2,sk2) in
+ List.map (fun p -> EConstr.mkProj (Projection.make p false, term)) (Array.to_list projs)
+ in
exact_ise_stack2 env evd (evar_conv_x { flags with with_cs = false}) l1'
- (Stack.append_app_list l2' Stack.empty)
+ (Stack.append_app_list l2' Stack.empty)
with
- | Invalid_argument _ ->
- (* Stack.tail: partially applied constructor *)
- UnifFailure(evd,NotSameHead))
+ | Invalid_argument _ ->
+ (* Stack.tail: partially applied constructor *)
+ UnifFailure(evd,NotSameHead))
| _ -> UnifFailure (evd,NotSameHead)
let evar_conv_x flags = evar_conv_x flags
@@ -1569,7 +1569,7 @@ let apply_conversion_problem_heuristic flags env evd with_ho pbty t1 t2 =
let (term1,l1 as appr1) = try destApp evd t1 with DestKO -> (t1, [||]) in
let (term2,l2 as appr2) = try destApp evd t2 with DestKO -> (t2, [||]) in
let () = if !debug_unification then
- let open Pp in
+ let open Pp in
Feedback.msg_debug (v 0 (str "Heuristic:" ++ spc () ++
Termops.Internal.print_constr_env env evd t1 ++ cut () ++
Termops.Internal.print_constr_env env evd t2 ++ cut ())) in
@@ -1705,7 +1705,7 @@ let solve_unif_constraints_with_heuristics env
match pbs with
| (pbty,env,t1,t2 as pb) :: pbs ->
(match apply_conversion_problem_heuristic flags env evd with_ho pbty t1 t2 with
- | Success evd' ->
+ | Success evd' ->
let evd' = solve_unconstrained_evars_with_candidates flags evd' in
let (evd', rest) = extract_all_conv_pbs evd' in
begin match rest with
@@ -1719,11 +1719,11 @@ let solve_unif_constraints_with_heuristics env
if is_beyond_capabilities reason then
aux evd pbs progress ((pb,reason) :: stuck)
else aux evd [] false ((pb,reason) :: stuck))
- | _ ->
+ | _ ->
if progress then aux evd (List.map fst stuck) false []
- else
- match stuck with
- | [] -> (* We're finished *) evd
+ else
+ match stuck with
+ | [] -> (* We're finished *) evd
| ((pbty,env,t1,t2 as pb), reason) :: _ ->
(* There remains stuck problems *)
Pretype_errors.error_cannot_unify ?loc:(loc_of_conv_pb evd pb)
diff --git a/pretyping/evarconv.mli b/pretyping/evarconv.mli
index e1dd0a0cdc..a1acf8b382 100644
--- a/pretyping/evarconv.mli
+++ b/pretyping/evarconv.mli
@@ -76,9 +76,9 @@ val check_problems_are_solved : env -> evar_map -> unit
(** Check if a canonical structure is applicable *)
-val check_conv_record : env -> evar_map ->
+val check_conv_record : env -> evar_map ->
state -> state ->
- Univ.ContextSet.t * (constr * constr)
+ Univ.ContextSet.t * (constr * constr)
* constr * constr list * (constr Stack.t * constr Stack.t) *
(constr Stack.t * constr Stack.t) *
(constr Stack.t * constr Stack.t) * constr *
diff --git a/pretyping/evardefine.ml b/pretyping/evardefine.ml
index 705ab56703..aebdd14396 100644
--- a/pretyping/evardefine.ml
+++ b/pretyping/evardefine.ml
@@ -94,13 +94,13 @@ let define_pure_evar_as_product env evd evk =
(* Impredicative product, conclusion must fall in [Prop]. *)
new_evar newenv evd1 concl ~src ~filter
else
- let status = univ_flexible_alg in
- let evd3, (rng, srng) =
+ let status = univ_flexible_alg in
+ let evd3, (rng, srng) =
new_type_evar newenv evd1 status ~src ~filter
in
- let prods = Univ.sup (univ_of_sort u1) (univ_of_sort srng) in
+ let prods = Univ.sup (univ_of_sort u1) (univ_of_sort srng) in
let evd3 = Evd.set_leq_sort evenv evd3 (Sorts.sort_of_univ prods) (ESorts.kind evd1 s) in
- evd3, rng
+ evd3, rng
in
let prod = mkProd (make_annot (Name id) rdom, dom, subst_var id rng) in
let evd3 = Evd.define evk prod evd2 in
@@ -169,7 +169,7 @@ let rec evar_absorb_arguments env evd (evk,args as ev) = function
let define_evar_as_sort env evd (ev,args) =
let evd, s = new_sort_variable univ_rigid evd in
- let evi = Evd.find_undefined evd ev in
+ let evi = Evd.find_undefined evd ev in
let concl = Reductionops.whd_all (evar_env evi) evd evi.evar_concl in
let sort = destSort evd concl in
let evd' = Evd.define ev (mkSort s) evd in
@@ -185,15 +185,15 @@ let split_tycon ?loc env evd tycon =
let t = Reductionops.whd_all env evd c in
match EConstr.kind evd t with
| Prod (na,dom,rng) -> evd, (na, dom, rng)
- | Evar ev (* ev is undefined because of whd_all *) ->
+ | Evar ev (* ev is undefined because of whd_all *) ->
let (evd',prod) = define_evar_as_product env evd ev in
let (na,dom,rng) = destProd evd prod in
let anon = {na with binder_name = Anonymous} in
evd',(anon, dom, rng)
| App (c,args) when isEvar evd c ->
let (evd',lam) = define_evar_as_lambda env evd (destEvar evd c) in
- real_split evd' (mkApp (lam,args))
- | _ -> error_not_product ?loc env evd c
+ real_split evd' (mkApp (lam,args))
+ | _ -> error_not_product ?loc env evd c
in
match tycon with
| None -> evd,(make_annot Anonymous Relevant,None,None)
diff --git a/pretyping/evarsolve.ml b/pretyping/evarsolve.ml
index 769079dea7..5a23525fb0 100644
--- a/pretyping/evarsolve.ml
+++ b/pretyping/evarsolve.ml
@@ -84,14 +84,14 @@ let get_polymorphic_positions env sigma f =
| _ -> assert false
let refresh_universes ?(status=univ_rigid) ?(onlyalg=false) ?(refreshset=false)
- pbty env evd t =
+ pbty env evd t =
let evdref = ref evd in
(* direction: true for fresh universes lower than the existing ones *)
let refresh_sort status ~direction s =
let s = ESorts.kind !evdref s in
let sigma, s' = new_sort_variable status !evdref in
evdref := sigma;
- let evd =
+ let evd =
if direction then set_leq_sort env !evdref s' s
else set_leq_sort env !evdref s s'
in evdref := evd; mkSort s'
@@ -103,13 +103,13 @@ let refresh_universes ?(status=univ_rigid) ?(onlyalg=false) ?(refreshset=false)
| Type u ->
(* TODO: check if max(l,u) is not ok as well *)
(match Univ.universe_level u with
- | None -> refresh_sort status ~direction s
- | Some l ->
+ | None -> refresh_sort status ~direction s
+ | Some l ->
(match Evd.universe_rigidity !evdref l with
- | UnivRigid ->
- if not onlyalg then refresh_sort status ~direction s
- else t
- | UnivFlexible alg ->
+ | UnivRigid ->
+ if not onlyalg then refresh_sort status ~direction s
+ else t
+ | UnivFlexible alg ->
(if alg then
evdref := Evd.make_nonalgebraic_variable !evdref l);
t))
@@ -130,7 +130,7 @@ let refresh_universes ?(status=univ_rigid) ?(onlyalg=false) ?(refreshset=false)
| App (f, args) when Termops.is_template_polymorphic_ind env !evdref f ->
let pos = get_polymorphic_positions env !evdref f in
refresh_polymorphic_positions args pos; t
- | App (f, args) when top && isEvar !evdref f ->
+ | App (f, args) when top && isEvar !evdref f ->
let f' = refresh_term_evars ~onevars:true ~top:false f in
let args' = Array.map (refresh_term_evars ~onevars ~top:false) args in
if f' == f && args' == args then t
@@ -149,23 +149,23 @@ let refresh_universes ?(status=univ_rigid) ?(onlyalg=false) ?(refreshset=false)
| _ -> EConstr.map !evdref (refresh_term_evars ~onevars ~top:false) t
and refresh_polymorphic_positions args pos =
let rec aux i = function
- | Some l :: ls ->
- if i < Array.length args then
+ | Some l :: ls ->
+ if i < Array.length args then
ignore(refresh_term_evars ~onevars:true ~top:false args.(i));
aux (succ i) ls
- | None :: ls ->
- if i < Array.length args then
+ | None :: ls ->
+ if i < Array.length args then
ignore(refresh_term_evars ~onevars:false ~top:false args.(i));
- aux (succ i) ls
+ aux (succ i) ls
| [] -> ()
in aux 0 pos
in
- let t' =
+ let t' =
if isArity !evdref t then
match pbty with
| None ->
- (* No cumulativity needed, but we still need to refresh the algebraics *)
- refresh ~onlyalg:true univ_flexible ~direction:false t
+ (* No cumulativity needed, but we still need to refresh the algebraics *)
+ refresh ~onlyalg:true univ_flexible ~direction:false t
| Some direction -> refresh ~onlyalg status ~direction t
else refresh_term_evars ~onevars:false ~top:true t
in !evdref, t'
@@ -192,22 +192,22 @@ let recheck_applications unify flags env evdref t =
let fty = Retyping.get_type_of env !evdref f in
let argsty = Array.map (fun x -> aux env x; Retyping.get_type_of env !evdref x) args in
let rec aux i ty =
- if i < Array.length argsty then
- match EConstr.kind !evdref (whd_all env !evdref ty) with
+ if i < Array.length argsty then
+ match EConstr.kind !evdref (whd_all env !evdref ty) with
| Prod (na, dom, codom) ->
(match unify flags TypeUnification env !evdref Reduction.CUMUL argsty.(i) dom with
| Success evd -> evdref := evd;
- aux (succ i) (subst1 args.(i) codom)
- | UnifFailure (evd, reason) ->
- Pretype_errors.error_cannot_unify env evd ~reason (argsty.(i), dom))
- | _ -> raise (IllTypedInstance (env, ty, argsty.(i)))
+ aux (succ i) (subst1 args.(i) codom)
+ | UnifFailure (evd, reason) ->
+ Pretype_errors.error_cannot_unify env evd ~reason (argsty.(i), dom))
+ | _ -> raise (IllTypedInstance (env, ty, argsty.(i)))
else ()
in aux 0 fty
| _ ->
iter_with_full_binders !evdref (fun d env -> push_rel d env) aux env t
in aux env t
-
+
(*------------------------------------*
* Restricting existing evars *
*------------------------------------*)
@@ -351,25 +351,25 @@ let compute_var_aliases sign sigma =
let compute_rel_aliases var_aliases rels sigma =
snd (List.fold_right
- (fun decl (n,aliases) ->
- (n-1,
- match decl with
+ (fun decl (n,aliases) ->
+ (n-1,
+ match decl with
| LocalDef (_,t,u) ->
- (match EConstr.kind sigma t with
- | Var id' ->
- let aliases_of_n =
- try Id.Map.find id' var_aliases with Not_found -> empty_aliasing in
- Int.Map.add n (push_alias aliases_of_n (VarAlias id')) aliases
- | Rel p ->
- let aliases_of_n =
- try Int.Map.find (p+n) aliases with Not_found -> empty_aliasing in
- Int.Map.add n (push_alias aliases_of_n (RelAlias (p+n))) aliases
- | _ ->
- Int.Map.add n (make_aliasing (lift n (mkCast(t,DEFAULTcast,u)))) aliases)
- | LocalAssum _ -> aliases)
- )
- rels
- (List.length rels,Int.Map.empty))
+ (match EConstr.kind sigma t with
+ | Var id' ->
+ let aliases_of_n =
+ try Id.Map.find id' var_aliases with Not_found -> empty_aliasing in
+ Int.Map.add n (push_alias aliases_of_n (VarAlias id')) aliases
+ | Rel p ->
+ let aliases_of_n =
+ try Int.Map.find (p+n) aliases with Not_found -> empty_aliasing in
+ Int.Map.add n (push_alias aliases_of_n (RelAlias (p+n))) aliases
+ | _ ->
+ Int.Map.add n (make_aliasing (lift n (mkCast(t,DEFAULTcast,u)))) aliases)
+ | LocalAssum _ -> aliases)
+ )
+ rels
+ (List.length rels,Int.Map.empty))
let make_alias_map env sigma =
(* We compute the chain of aliases for each var and rel *)
@@ -732,7 +732,7 @@ let materialize_evar define_fun env evd k (evk1,args1) ty_in_env =
let evd,t_in_sign =
let s = Retyping.get_sort_of env evd t_in_env in
let evd,ty_t_in_sign = refresh_universes
- ~status:univ_flexible (Some false) env evd (mkSort s) in
+ ~status:univ_flexible (Some false) env evd (mkSort s) in
define_evar_from_virtual_equation define_fun env evd src t_in_env
ty_t_in_sign sign filter inst_in_env in
let evd,d' = match d with
@@ -1326,9 +1326,9 @@ let solve_evar_evar ?(force=false) f unify flags env evd pbty (evk1,args1 as ev1
let evi = Evd.find evd evk1 in
let downcast evk t evd = downcast evk t evd in
let evd =
- try
+ try
(* ?X : Π Δ. Type i = ?Y : Π Δ'. Type j.
- The body of ?X and ?Y just has to be of type Π Δ. Type k for some k <= i, j. *)
+ The body of ?X and ?Y just has to be of type Π Δ. Type k for some k <= i, j. *)
let evienv = Evd.evar_env evi in
let concl1 = EConstr.Unsafe.to_constr evi.evar_concl in
let ctx1, i = Reduction.dest_arity evienv concl1 in
@@ -1339,22 +1339,22 @@ let solve_evar_evar ?(force=false) f unify flags env evd pbty (evk1,args1 as ev1
let ctx2, j = Reduction.dest_arity evi2env concl2 in
let ctx2 = List.map (fun c -> map_rel_decl EConstr.of_constr c) ctx2 in
let ui, uj = univ_of_sort i, univ_of_sort j in
- if i == j || Evd.check_eq evd ui uj
- then (* Shortcut, i = j *)
- evd
- else if Evd.check_leq evd ui uj then
+ if i == j || Evd.check_eq evd ui uj
+ then (* Shortcut, i = j *)
+ evd
+ else if Evd.check_leq evd ui uj then
let t2 = it_mkProd_or_LetIn (mkSort i) ctx2 in
downcast evk2 t2 evd
- else if Evd.check_leq evd uj ui then
+ else if Evd.check_leq evd uj ui then
let t1 = it_mkProd_or_LetIn (mkSort j) ctx1 in
downcast evk1 t1 evd
- else
- let evd, k = Evd.new_sort_variable univ_flexible_alg evd in
+ else
+ let evd, k = Evd.new_sort_variable univ_flexible_alg evd in
let t1 = it_mkProd_or_LetIn (mkSort k) ctx1 in
let t2 = it_mkProd_or_LetIn (mkSort k) ctx2 in
- let evd = Evd.set_leq_sort env (Evd.set_leq_sort env evd k i) k j in
+ let evd = Evd.set_leq_sort env (Evd.set_leq_sort env evd k i) k j in
downcast evk2 t2 (downcast evk1 t1 evd)
- with Reduction.NotArity ->
+ with Reduction.NotArity ->
evd in
solve_evar_evar_aux force f unify flags env evd pbty ev1 ev2
@@ -1419,7 +1419,7 @@ let solve_candidates unify flags env evd (evk,argsv) rhs =
if Evd.is_undefined evd evk then
let evd' = Evd.define evk c evd in
check_evar_instance unify flags evd' evk c
- else evd
+ else evd
| l when List.length l < List.length l' ->
let candidates = List.map fst l in
restrict_evar evd evk None (UpdateWith candidates)
@@ -1614,10 +1614,10 @@ let rec invert_definition unify flags choose imitate_defs
| None ->
(* Evar/Rigid problem (or assimilated if not normal): we "imitate" *)
map_constr_with_full_binders !evdref (fun d (env,k) -> push_rel d env, k+1)
- imitate envk t
+ imitate envk t
in
let rhs = whd_beta evd rhs (* heuristic *) in
- let fast rhs =
+ let fast rhs =
let filter_ctxt = evar_filtered_context evi in
let names = ref Id.Set.empty in
let rec is_id_subst ctxt s =
@@ -1627,19 +1627,19 @@ let rec invert_definition unify flags choose imitate_defs
names := Id.Set.add id !names;
isVarId evd id c && is_id_subst ctxt' s'
| [], [] -> true
- | _ -> false
+ | _ -> false
in
is_id_subst filter_ctxt (Array.to_list argsv) &&
closed0 evd rhs &&
- Id.Set.subset (collect_vars evd rhs) !names
+ Id.Set.subset (collect_vars evd rhs) !names
in
let body =
if fast rhs then nf_evar evd rhs (* FIXME? *)
else
let t' = imitate (env,0) rhs in
- if !progress then
+ if !progress then
(recheck_applications unify flags (evar_env evi) evdref t'; t')
- else t'
+ else t'
in (!evdref,body)
(* [define] tries to solve the problem "?ev[args] = rhs" when "?ev" is
@@ -1688,7 +1688,7 @@ and evar_define unify flags ?(choose=false) ?(imitate_defs=true) env evd pbty (e
solve_refl (fun flags _b env sigma pb c c' -> is_fconv pb env sigma c c') flags
env evd pbty evk argsv argsv2
| _ ->
- raise (OccurCheckIn (evd,rhs))
+ raise (OccurCheckIn (evd,rhs))
(* This code (i.e. solve_pb, etc.) takes a unification
* problem, and tries to solve it. If it solves it, then it removes
diff --git a/pretyping/evarsolve.mli b/pretyping/evarsolve.mli
index 9d5d75d9ba..908adac7e4 100644
--- a/pretyping/evarsolve.mli
+++ b/pretyping/evarsolve.mli
@@ -41,7 +41,7 @@ type unification_result =
val is_success : unification_result -> bool
-(** Replace the vars and rels that are aliases to other vars and rels by
+(** Replace the vars and rels that are aliases to other vars and rels by
their representative that is most ancient in the context *)
val expand_vars_in_term : env -> evar_map -> constr -> constr
@@ -130,5 +130,5 @@ val check_evar_instance : unifier -> unify_flags ->
val remove_instance_local_defs :
evar_map -> Evar.t -> 'a array -> 'a list
-val get_type_of_refresh :
+val get_type_of_refresh :
?polyprop:bool -> ?lax:bool -> env -> evar_map -> constr -> evar_map * types
diff --git a/pretyping/find_subterm.ml b/pretyping/find_subterm.ml
index 9db37bfa9b..2d64692cc6 100644
--- a/pretyping/find_subterm.ml
+++ b/pretyping/find_subterm.ml
@@ -161,13 +161,13 @@ let make_eq_univs_test env evd c =
match EConstr.eq_constr_universes_proj env evd c c' with
| None -> raise (NotUnifiable None)
| Some cst ->
- try Evd.add_universe_constraints evd cst
- with Evd.UniversesDiffer -> raise (NotUnifiable None)
+ try Evd.add_universe_constraints evd cst
+ with Evd.UniversesDiffer -> raise (NotUnifiable None)
);
merge_fun = (fun evd _ -> evd);
testing_state = evd;
last_found = None
-}
+}
let subst_closed_term_occ env evd occs c t =
let test = make_eq_univs_test env evd c in
diff --git a/pretyping/find_subterm.mli b/pretyping/find_subterm.mli
index 3ad69e6e50..6f9dac400f 100644
--- a/pretyping/find_subterm.mli
+++ b/pretyping/find_subterm.mli
@@ -60,7 +60,7 @@ val replace_term_occ_decl_modulo :
val subst_closed_term_occ : env -> evar_map -> occurrences or_like_first ->
constr -> constr -> constr * evar_map
-(** [subst_closed_term_occ_decl evd occl c decl] replaces occurrences of
+(** [subst_closed_term_occ_decl evd occl c decl] replaces occurrences of
closed [c] at positions [occl] by [Rel 1] in [decl]. *)
val subst_closed_term_occ_decl : env -> evar_map ->
(occurrences * hyp_location_flag) or_like_first ->
diff --git a/pretyping/glob_ops.ml b/pretyping/glob_ops.ml
index 03bb633fa0..1264b0b33c 100644
--- a/pretyping/glob_ops.ml
+++ b/pretyping/glob_ops.ml
@@ -246,7 +246,7 @@ let fold_glob_constr f acc = DAst.with_val (function
| GRec (_,_,bl,tyl,bv) ->
let acc = Array.fold_left
(List.fold_left (fun acc (na,k,bbd,bty) ->
- f (Option.fold_left f acc bbd) bty)) acc bl in
+ f (Option.fold_left f acc bbd) bty)) acc bl in
Array.fold_left f (Array.fold_left f acc tyl) bv
| GCast (c,k) ->
let acc = match k with
@@ -283,8 +283,8 @@ let fold_glob_constr_with_binders g f v acc = DAst.(with_val (function
let v' = Array.fold_right g idl v in
let f' i acc fid =
let v,acc =
- List.fold_left
- (fun (v,acc) (na,k,bbd,bty) ->
+ List.fold_left
+ (fun (v,acc) (na,k,bbd,bty) ->
(Name.fold_right g na v, f v (Option.fold_left (f v) acc bbd) bty))
(v,acc)
bll.(i) in
diff --git a/pretyping/indrec.ml b/pretyping/indrec.ml
index 0a6c3afd0d..1d240db33c 100644
--- a/pretyping/indrec.ml
+++ b/pretyping/indrec.ml
@@ -69,7 +69,7 @@ let is_private mib =
let check_privacy_block mib =
if is_private mib then
user_err (str"case analysis on a private inductive type")
-
+
(**********************************************************************)
(* Building case analysis schemes *)
(* Christine Paulin, 1996 *)
@@ -82,10 +82,10 @@ let mis_make_case_com dep env sigma (ind, u as pind) (mib,mip as specif) kind =
let relevance = Sorts.relevance_of_sort_family kind in
let () = if Option.is_empty projs then check_privacy_block mib in
- let () =
+ let () =
if not (Sorts.family_leq kind (elim_sort specif)) then
raise
- (RecursionSchemeError
+ (RecursionSchemeError
(env, NotAllowedCaseAnalysis (false, fst (UnivGen.fresh_sort_in_family kind), pind)))
in
let ndepar = mip.mind_nrealdecls + 1 in
@@ -112,26 +112,26 @@ let mis_make_case_com dep env sigma (ind, u as pind) (mib,mip as specif) kind =
if dep then Context.Rel.to_extended_vect mkRel 0 deparsign
else Context.Rel.to_extended_vect mkRel 1 arsign) in
let p =
- it_mkLambda_or_LetIn_name env'
- ((if dep then mkLambda_name env' else mkLambda)
+ it_mkLambda_or_LetIn_name env'
+ ((if dep then mkLambda_name env' else mkLambda)
(make_annot Anonymous r,depind,pbody))
arsign
in
- let obj =
- match projs with
- | None -> mkCase (ci, lift ndepar p, mkRel 1,
- Termops.rel_vect ndepar k)
- | Some ps ->
- let term =
- mkApp (mkRel 2,
- Array.map
- (fun p -> mkProj (Projection.make p true, mkRel 1)) ps) in
- if dep then
- let ty = mkApp (mkRel 3, [| mkRel 1 |]) in
- mkCast (term, DEFAULTcast, ty)
- else term
+ let obj =
+ match projs with
+ | None -> mkCase (ci, lift ndepar p, mkRel 1,
+ Termops.rel_vect ndepar k)
+ | Some ps ->
+ let term =
+ mkApp (mkRel 2,
+ Array.map
+ (fun p -> mkProj (Projection.make p true, mkRel 1)) ps) in
+ if dep then
+ let ty = mkApp (mkRel 3, [| mkRel 1 |]) in
+ mkCast (term, DEFAULTcast, ty)
+ else term
in
- it_mkLambda_or_LetIn_name env' obj deparsign
+ it_mkLambda_or_LetIn_name env' obj deparsign
else
let cs = lift_constructor (k+1) constrs.(k) in
let t = build_branch_type env sigma dep (mkRel (k+1)) cs in
@@ -141,7 +141,7 @@ let mis_make_case_com dep env sigma (ind, u as pind) (mib,mip as specif) kind =
let (sigma, s) = Evd.fresh_sort_in_family ~rigid:Evd.univ_flexible_alg sigma kind in
let typP = make_arity env' sigma dep indf s in
let typP = EConstr.Unsafe.to_constr typP in
- let c =
+ let c =
it_mkLambda_or_LetIn_name env
(mkLambda_string "P" Sorts.Relevant typP
(add_branch (push_rel (LocalAssum (make_annot Anonymous Sorts.Relevant,typP)) env') 0)) lnamespar
@@ -180,19 +180,19 @@ let type_rec_branch is_rec dep env sigma (vargs,depPvect,decP) tyi cs recargs =
| LetIn (n,b,t,c) when List.is_empty largs ->
let d = LocalDef (n,b,t) in
mkLetIn (n,b,t,prec (push_rel d env) (i+1) (d::sign) c)
- | Ind (_,_) ->
- let realargs = List.skipn nparams largs in
- let base = applist (lift i pk,realargs) in
+ | Ind (_,_) ->
+ let realargs = List.skipn nparams largs in
+ let base = applist (lift i pk,realargs) in
if depK then
- Reduction.beta_appvect
+ Reduction.beta_appvect
base [|applist (mkRel (i+1), Context.Rel.to_extended_list mkRel 0 sign)|]
else
- base
- | _ ->
- let t' = whd_all env sigma (EConstr.of_constr p) in
- let t' = EConstr.Unsafe.to_constr t' in
- if Constr.equal p' t' then assert false
- else prec env i sign t'
+ base
+ | _ ->
+ let t' = whd_all env sigma (EConstr.of_constr p) in
+ let t' = EConstr.Unsafe.to_constr t' in
+ if Constr.equal p' t' then assert false
+ else prec env i sign t'
in
prec env 0 []
in
@@ -200,43 +200,43 @@ let type_rec_branch is_rec dep env sigma (vargs,depPvect,decP) tyi cs recargs =
if nhyps > 0 then match kind c with
| Prod (n,t,c_0) ->
let (optionpos,rest) =
- match recargs with
- | [] -> None,[]
+ match recargs with
+ | [] -> None,[]
| ra::rest ->
(match dest_recarg ra with
- | Mrec (_,j) when is_rec -> (depPvect.(j),rest)
- | Imbr _ -> (None,rest)
+ | Mrec (_,j) when is_rec -> (depPvect.(j),rest)
+ | Imbr _ -> (None,rest)
| _ -> (None, rest))
- in
+ in
(match optionpos with
- | None ->
- make_prod env
+ | None ->
+ make_prod env
(n,t,
process_constr (push_rel (LocalAssum (n,t)) env) (i+1) c_0 rest
- (nhyps-1) (i::li))
+ (nhyps-1) (i::li))
| Some(dep',p) ->
- let nP = lift (i+1+decP) p in
+ let nP = lift (i+1+decP) p in
let env' = push_rel (LocalAssum (n,t)) env in
let t_0 = process_pos env' dep' nP (lift 1 t) in
let r_0 = Retyping.relevance_of_type env' sigma (EConstr.of_constr t_0) in
- make_prod_dep (dep || dep') env
+ make_prod_dep (dep || dep') env
(n,t,
mkArrow t_0 r_0
- (process_constr
+ (process_constr
(push_rel (LocalAssum (make_annot Anonymous n.binder_relevance,t_0)) env')
- (i+2) (lift 1 c_0) rest (nhyps-1) (i::li))))
+ (i+2) (lift 1 c_0) rest (nhyps-1) (i::li))))
| LetIn (n,b,t,c_0) ->
mkLetIn (n,b,t,
- process_constr
+ process_constr
(push_rel (LocalDef (n,b,t)) env)
- (i+1) c_0 recargs (nhyps-1) li)
+ (i+1) c_0 recargs (nhyps-1) li)
| _ -> assert false
else
if dep then
- let realargs = List.rev_map (fun k -> mkRel (i-k)) li in
+ let realargs = List.rev_map (fun k -> mkRel (i-k)) li in
let params = List.map (lift i) vargs in
let co = applist (mkConstructU cs.cs_cstr,params@realargs) in
- Reduction.beta_appvect c [|co|]
+ Reduction.beta_appvect c [|co|]
else c
in
let nhyps = List.length cs.cs_args in
@@ -260,15 +260,15 @@ let make_rec_branch_arg env sigma (nparrec,fvect,decF) f cstr recargs =
| LetIn (n,b,t,c) when List.is_empty largs ->
let d = LocalDef (n,b,t) in
mkLetIn (n,b,t,prec (push_rel d env) (i+1) (d::hyps) c)
- | Ind _ ->
+ | Ind _ ->
let realargs = List.skipn nparrec largs
and arg = appvect (mkRel (i+1), Context.Rel.to_extended_vect mkRel 0 hyps) in
applist(lift i fk,realargs@[arg])
- | _ ->
- let t' = whd_all env sigma (EConstr.of_constr p) in
- let t' = EConstr.Unsafe.to_constr t' in
- if Constr.equal t' p' then assert false
- else prec env i hyps t'
+ | _ ->
+ let t' = whd_all env sigma (EConstr.of_constr p) in
+ let t' = EConstr.Unsafe.to_constr t' in
+ if Constr.equal t' p' then assert false
+ else prec env i hyps t'
in
prec env 0 []
in
@@ -276,30 +276,30 @@ let make_rec_branch_arg env sigma (nparrec,fvect,decF) f cstr recargs =
let rec process_constr env i f = function
| (LocalAssum (n,t) as d)::cprest, recarg::rest ->
let optionpos =
- match dest_recarg recarg with
+ match dest_recarg recarg with
| Norec -> None
| Imbr _ -> None
| Mrec (_,i) -> fvect.(i)
- in
+ in
(match optionpos with
| None ->
- mkLambda_name env
+ mkLambda_name env
(n,t,process_constr (push_rel d env) (i+1)
- (EConstr.Unsafe.to_constr (whd_beta Evd.empty (EConstr.of_constr (applist (lift 1 f, [(mkRel 1)])))))
- (cprest,rest))
+ (EConstr.Unsafe.to_constr (whd_beta Evd.empty (EConstr.of_constr (applist (lift 1 f, [(mkRel 1)])))))
+ (cprest,rest))
| Some(_,f_0) ->
- let nF = lift (i+1+decF) f_0 in
+ let nF = lift (i+1+decF) f_0 in
let env' = push_rel d env in
- let arg = process_pos env' nF (lift 1 t) in
+ let arg = process_pos env' nF (lift 1 t) in
mkLambda_name env
(n,t,process_constr env' (i+1)
- (EConstr.Unsafe.to_constr (whd_beta Evd.empty (EConstr.of_constr (applist (lift 1 f, [(mkRel 1); arg])))))
- (cprest,rest)))
+ (EConstr.Unsafe.to_constr (whd_beta Evd.empty (EConstr.of_constr (applist (lift 1 f, [(mkRel 1); arg])))))
+ (cprest,rest)))
| (LocalDef (n,c,t) as d)::cprest, rest ->
- mkLetIn
+ mkLetIn
(n,c,t,
- process_constr (push_rel d env) (i+1) (lift 1 f)
- (cprest,rest))
+ process_constr (push_rel d env) (i+1) (lift 1 f)
+ (cprest,rest))
| [],[] -> f
| _,[] | [],_ -> anomaly (Pp.str "process_constr.")
@@ -318,8 +318,8 @@ let mis_make_indrec env sigma ?(force_mutual=false) listdepkind mib u =
Array.make mib.mind_ntypes (None : (bool * constr) option) in
let _ =
let rec
- assign k = function
- | [] -> ()
+ assign k = function
+ | [] -> ()
| ((indi,u),mibi,mipi,dep,_)::rest ->
(Array.set depPvec (snd indi) (Some(dep,mkRel k));
assign (k-1) rest)
@@ -356,79 +356,79 @@ let mis_make_indrec env sigma ?(force_mutual=false) listdepkind mib u =
(* constructors in context of the Cases expr, i.e.
P1..P_nrec f1..f_nbconstruct F_1..F_nrec a_1..a_nar x:I *)
- let args' = Context.Rel.to_extended_list mkRel (dect+nrec) lnamesparrec in
- let args'' = Context.Rel.to_extended_list mkRel ndepar lnonparrec in
+ let args' = Context.Rel.to_extended_list mkRel (dect+nrec) lnamesparrec in
+ let args'' = Context.Rel.to_extended_list mkRel ndepar lnonparrec in
let indf' = make_ind_family((indi,u),args'@args'') in
- let branches =
- let constrs = get_constructors env indf' in
- let fi = Termops.rel_vect (dect-i-nctyi) nctyi in
- let vecfi = Array.map
- (fun f -> appvect (f, Context.Rel.to_extended_vect mkRel ndepar lnonparrec))
- fi
- in
- Array.map3
- (make_rec_branch_arg env !evdref
- (nparrec,depPvec,larsign))
+ let branches =
+ let constrs = get_constructors env indf' in
+ let fi = Termops.rel_vect (dect-i-nctyi) nctyi in
+ let vecfi = Array.map
+ (fun f -> appvect (f, Context.Rel.to_extended_vect mkRel ndepar lnonparrec))
+ fi
+ in
+ Array.map3
+ (make_rec_branch_arg env !evdref
+ (nparrec,depPvec,larsign))
vecfi constrs (dest_subterms recargsvec.(tyi))
- in
+ in
- let j = (match depPvec.(tyi) with
- | Some (_,c) when isRel c -> destRel c
- | _ -> assert false)
- in
+ let j = (match depPvec.(tyi) with
+ | Some (_,c) when isRel c -> destRel c
+ | _ -> assert false)
+ in
- (* Predicate in the context of the case *)
+ (* Predicate in the context of the case *)
let depind' = build_dependent_inductive env indf' in
let arsign',s = get_arity env indf' in
let r = Sorts.relevance_of_sort_family s in
let deparsign' = LocalAssum (make_annot Anonymous r,depind')::arsign' in
- let pargs =
- let nrpar = Context.Rel.to_extended_list mkRel (2*ndepar) lnonparrec
- and nrar = if dep then Context.Rel.to_extended_list mkRel 0 deparsign'
- else Context.Rel.to_extended_list mkRel 1 arsign'
- in nrpar@nrar
+ let pargs =
+ let nrpar = Context.Rel.to_extended_list mkRel (2*ndepar) lnonparrec
+ and nrar = if dep then Context.Rel.to_extended_list mkRel 0 deparsign'
+ else Context.Rel.to_extended_list mkRel 1 arsign'
+ in nrpar@nrar
- in
+ in
- (* body of i-th component of the mutual fixpoint *)
+ (* body of i-th component of the mutual fixpoint *)
let target_relevance = Sorts.relevance_of_sort_family target_sort in
- let deftyi =
+ let deftyi =
let rci = target_relevance in
let ci = make_case_info env indi rci RegularStyle in
- let concl = applist (mkRel (dect+j+ndepar),pargs) in
- let pred =
- it_mkLambda_or_LetIn_name env
- ((if dep then mkLambda_name env else mkLambda)
+ let concl = applist (mkRel (dect+j+ndepar),pargs) in
+ let pred =
+ it_mkLambda_or_LetIn_name env
+ ((if dep then mkLambda_name env else mkLambda)
(make_annot Anonymous r,depind',concl))
- arsign'
- in
- let obj =
- Inductiveops.make_case_or_project env !evdref indf ci (EConstr.of_constr pred)
- (EConstr.mkRel 1) (Array.map EConstr.of_constr branches)
- in
- let obj = EConstr.to_constr !evdref obj in
- it_mkLambda_or_LetIn_name env obj
- (Termops.lift_rel_context nrec deparsign)
- in
-
- (* type of i-th component of the mutual fixpoint *)
-
- let typtyi =
- let concl =
- let pargs = if dep then Context.Rel.to_extended_vect mkRel 0 deparsign
- else Context.Rel.to_extended_vect mkRel 1 arsign
- in appvect (mkRel (nbconstruct+ndepar+nonrecpar+j),pargs)
- in it_mkProd_or_LetIn_name env
- concl
- deparsign
+ arsign'
+ in
+ let obj =
+ Inductiveops.make_case_or_project env !evdref indf ci (EConstr.of_constr pred)
+ (EConstr.mkRel 1) (Array.map EConstr.of_constr branches)
+ in
+ let obj = EConstr.to_constr !evdref obj in
+ it_mkLambda_or_LetIn_name env obj
+ (Termops.lift_rel_context nrec deparsign)
+ in
+
+ (* type of i-th component of the mutual fixpoint *)
+
+ let typtyi =
+ let concl =
+ let pargs = if dep then Context.Rel.to_extended_vect mkRel 0 deparsign
+ else Context.Rel.to_extended_vect mkRel 1 arsign
+ in appvect (mkRel (nbconstruct+ndepar+nonrecpar+j),pargs)
+ in it_mkProd_or_LetIn_name env
+ concl
+ deparsign
in
mrec (i+nctyi) (Context.Rel.nhyps arsign ::ln) (target_relevance::lrelevance) (typtyi::ltyp)
(deftyi::ldef) rest
| [] ->
- let fixn = Array.of_list (List.rev ln) in
+ let fixn = Array.of_list (List.rev ln) in
let fixtyi = Array.of_list (List.rev ltyp) in
let fixdef = Array.of_list (List.rev ldef) in
let lrelevance = CArray.rev_of_list lrelevance in
@@ -440,55 +440,55 @@ let mis_make_indrec env sigma ?(force_mutual=false) listdepkind mib u =
let rec make_branch env i = function
| ((indi,u),mibi,mipi,dep,sfam)::rest ->
let tyi = snd indi in
- let nconstr = Array.length mipi.mind_consnames in
- let rec onerec env j =
- if Int.equal j nconstr then
- make_branch env (i+j) rest
- else
- let recarg = (dest_subterms recargsvec.(tyi)).(j) in
- let recarg = recargpar@recarg in
- let vargs = Context.Rel.to_extended_list mkRel (nrec+i+j) lnamesparrec in
- let cs = get_constructor ((indi,u),mibi,mipi,vargs) (j+1) in
- let p_0 =
- type_rec_branch
+ let nconstr = Array.length mipi.mind_consnames in
+ let rec onerec env j =
+ if Int.equal j nconstr then
+ make_branch env (i+j) rest
+ else
+ let recarg = (dest_subterms recargsvec.(tyi)).(j) in
+ let recarg = recargpar@recarg in
+ let vargs = Context.Rel.to_extended_list mkRel (nrec+i+j) lnamesparrec in
+ let cs = get_constructor ((indi,u),mibi,mipi,vargs) (j+1) in
+ let p_0 =
+ type_rec_branch
true dep env !evdref (vargs,depPvec,i+j) tyi cs recarg
in
let r_0 = Sorts.relevance_of_sort_family sfam in
mkLambda_string "f" r_0 p_0
(onerec (push_rel (LocalAssum (make_annot Anonymous r_0,p_0)) env) (j+1))
- in onerec env 0
+ in onerec env 0
| [] ->
- makefix i listdepkind
+ makefix i listdepkind
in
let rec put_arity env i = function
| ((indi,u),_,_,dep,kinds)::rest ->
- let indf = make_ind_family ((indi,u), Context.Rel.to_extended_list mkRel i lnamesparrec) in
- let s =
+ let indf = make_ind_family ((indi,u), Context.Rel.to_extended_list mkRel i lnamesparrec) in
+ let s =
let sigma, res = Evd.fresh_sort_in_family ~rigid:Evd.univ_flexible_alg !evdref kinds in
evdref := sigma; res
- in
- let typP = make_arity env !evdref dep indf s in
+ in
+ let typP = make_arity env !evdref dep indf s in
let typP = EConstr.Unsafe.to_constr typP in
mkLambda_string "P" Sorts.Relevant typP
(put_arity (push_rel (LocalAssum (anonR,typP)) env) (i+1) rest)
| [] ->
- make_branch env 0 listdepkind
+ make_branch env 0 listdepkind
in
(* Body on make_one_rec *)
let ((indi,u),mibi,mipi,dep,kind) = List.nth listdepkind p in
if force_mutual || (mis_is_recursive_subset
- (List.map (fun ((indi,u),_,_,_,_) -> snd indi) listdepkind)
- mipi.mind_recargs)
+ (List.map (fun ((indi,u),_,_,_,_) -> snd indi) listdepkind)
+ mipi.mind_recargs)
then
- let env' = push_rel_context lnamesparrec env in
- it_mkLambda_or_LetIn_name env (put_arity env' 0 listdepkind)
- lnamesparrec
+ let env' = push_rel_context lnamesparrec env in
+ it_mkLambda_or_LetIn_name env (put_arity env' 0 listdepkind)
+ lnamesparrec
else
let evd = !evdref in
let (evd, c) = mis_make_case_com dep env evd (indi,u) (mibi,mipi) kind in
- evdref := evd; c
+ evdref := evd; c
in
(* Body of mis_make_indrec *)
!evdref, List.init nrec make_one_rec
@@ -533,12 +533,12 @@ let weaken_sort_scheme env evd set sort npars term ty =
let rec drec np elim =
match kind elim with
| Prod (n,t,c) ->
- if Int.equal np 0 then
+ if Int.equal np 0 then
let osort, t' = change_sort_arity sort t in
- evdref := (if set then Evd.set_eq_sort else Evd.set_leq_sort) env !evdref sort osort;
+ evdref := (if set then Evd.set_eq_sort else Evd.set_leq_sort) env !evdref sort osort;
mkProd (n, t', c),
mkLambda (n, t', mkApp(term,Termops.rel_vect 0 (npars+1)))
- else
+ else
let c',term' = drec (np-1) c in
mkProd (n, t, c'), mkLambda (n, t, term')
| LetIn (n,b,t,c) -> let c',term' = drec np c in
@@ -558,12 +558,12 @@ let check_arities env listdepkind =
(fun ln (((_,ni as mind),u),mibi,mipi,dep,kind) ->
let kelim = elim_sort (mibi,mipi) in
if not (Sorts.family_leq kind kelim) then raise
- (RecursionSchemeError
+ (RecursionSchemeError
(env, NotAllowedCaseAnalysis (true, fst (UnivGen.fresh_sort_in_family kind),(mind,u))))
else if Int.List.mem ni ln then raise
(RecursionSchemeError (env, NotMutualInScheme (mind,mind)))
else ni::ln)
- [] listdepkind
+ [] listdepkind
in true
let build_mutual_induction_scheme env sigma ?(force_mutual=false) = function
@@ -573,16 +573,16 @@ let build_mutual_induction_scheme env sigma ?(force_mutual=false) = function
raise (RecursionSchemeError (env, NotAllowedDependentAnalysis (true, mind)));
let (sp,tyi) = mind in
let listdepkind =
- ((mind,u),mib,mip,dep,s)::
- (List.map
- (function ((mind',u'),dep',s') ->
- let (sp',_) = mind' in
- if MutInd.equal sp sp' then
+ ((mind,u),mib,mip,dep,s)::
+ (List.map
+ (function ((mind',u'),dep',s') ->
+ let (sp',_) = mind' in
+ if MutInd.equal sp sp' then
let (mibi',mipi') = lookup_mind_specif env mind' in
- ((mind',u'),mibi',mipi',dep',s')
- else
+ ((mind',u'),mibi',mipi',dep',s')
+ else
raise (RecursionSchemeError (env, NotMutualInScheme (mind,mind'))))
- lrecspec)
+ lrecspec)
in
let _ = check_arities env listdepkind in
mis_make_indrec env sigma ~force_mutual listdepkind mib u
diff --git a/pretyping/inductiveops.mli b/pretyping/inductiveops.mli
index 55eb74cacf..06466cc67d 100644
--- a/pretyping/inductiveops.mli
+++ b/pretyping/inductiveops.mli
@@ -151,7 +151,7 @@ val has_dependent_elim : mutual_inductive_body -> bool
(** Primitive projections *)
val type_of_projection_knowing_arg : env -> evar_map -> Projection.t ->
- EConstr.t -> EConstr.types -> types
+ EConstr.t -> EConstr.types -> types
(** Extract information from an inductive family *)
diff --git a/pretyping/locusops.ml b/pretyping/locusops.ml
index 9c6cf090a2..ffb29bb38c 100644
--- a/pretyping/locusops.ml
+++ b/pretyping/locusops.ml
@@ -71,12 +71,12 @@ let simple_clause_of enum_hyps cl =
let hyps =
match cl.onhyps with
| None ->
- List.map Option.make (enum_hyps ())
+ List.map Option.make (enum_hyps ())
| Some l ->
- List.map (fun ((occs,id),w) ->
+ List.map (fun ((occs,id),w) ->
if not (is_all_occurrences occs) then error_occurrences ();
- if w = InHypValueOnly then error_body_selection ();
- Some id) l in
+ if w = InHypValueOnly then error_body_selection ();
+ Some id) l in
if cl.concl_occs = NoOccurrences then hyps
else
if not (is_all_occurrences cl.concl_occs) then error_occurrences ()
@@ -88,10 +88,10 @@ let concrete_clause_of enum_hyps cl =
let hyps =
match cl.onhyps with
| None ->
- let f id = OnHyp (id,AllOccurrences,InHyp) in
- List.map f (enum_hyps ())
+ let f id = OnHyp (id,AllOccurrences,InHyp) in
+ List.map f (enum_hyps ())
| Some l ->
- List.map (fun ((occs,id),w) -> OnHyp (id,occs,w)) l in
+ List.map (fun ((occs,id),w) -> OnHyp (id,occs,w)) l in
if cl.concl_occs = NoOccurrences then hyps
else
OnConcl cl.concl_occs :: hyps
diff --git a/pretyping/nativenorm.ml b/pretyping/nativenorm.ml
index 0178d5c009..2db674d397 100644
--- a/pretyping/nativenorm.ml
+++ b/pretyping/nativenorm.ml
@@ -29,7 +29,7 @@ exception Find_at of int
(* profiling *)
let profiling_enabled = ref false
-
+
(* for supported platforms, filename for profiler results *)
let profile_filename = ref "native_compute_profile.data"
@@ -52,8 +52,8 @@ let set_profile_filename fn =
(* find unused profile filename *)
let get_available_profile_filename () =
let profile_filename = get_profile_filename () in
- let dir = Filename.dirname profile_filename in
- let base = Filename.basename profile_filename in
+ let dir = Filename.dirname profile_filename in
+ let base = Filename.basename profile_filename in
(* starting with OCaml 4.04, could use Filename.remove_extension and Filename.extension, which
gets rid of need for exception-handling here
*)
@@ -65,7 +65,7 @@ let get_available_profile_filename () =
(nm,ex)
with Invalid_argument _ -> (base,"")
in
- try
+ try
(* unlikely race: fn deleted, another process uses fn *)
Filename.temp_file ~temp_dir:dir (name ^ "_") ext
with Sys_error s ->
@@ -75,16 +75,16 @@ let get_available_profile_filename () =
let get_profiling_enabled () =
!profiling_enabled
-
+
let set_profiling_enabled b =
profiling_enabled := b
-
+
let invert_tag cst tag reloc_tbl =
try
for j = 0 to Array.length reloc_tbl - 1 do
let tagj,arity = reloc_tbl.(j) in
if Int.equal tag tagj && (cst && Int.equal arity 0 || not(cst || Int.equal arity 0)) then
- raise (Find_at j)
+ raise (Find_at j)
else ()
done;raise Not_found
with Find_at j -> (j+1)
@@ -101,7 +101,7 @@ let app_type env c =
let t = whd_all env c in
try destApp t with DestKO -> (t,[||])
-
+
let find_rectype_a env c =
let (t, l) = app_type env c in
match kind t with
@@ -117,7 +117,7 @@ let type_constructor mind mib u (ctx, typ) params =
let nparams = Array.length params in
if Int.equal nparams 0 then ctyp
else
- let _,ctyp = decompose_prod_n nparams ctyp in
+ let _,ctyp = decompose_prod_n nparams ctyp in
substl (List.rev (Array.to_list params)) ctyp
let construct_of_constr_notnative const env tag (mind, _ as ind) u allargs =
@@ -127,12 +127,12 @@ let construct_of_constr_notnative const env tag (mind, _ as ind) u allargs =
let i = invert_tag const tag mip.mind_reloc_tbl in
let ctyp = type_constructor mind mib u (mip.mind_nf_lc.(i-1)) params in
(mkApp(mkConstructU((ind,i),u), params), ctyp)
-
+
let construct_of_constr const env sigma tag typ =
let t, l = app_type env typ in
match EConstr.kind_upto sigma t with
- | Ind (ind,u) ->
+ | Ind (ind,u) ->
construct_of_constr_notnative const env tag ind u l
| _ ->
assert (Constr.equal t (Typeops.type_of_int env));
@@ -165,7 +165,7 @@ let build_branches_type env sigma (mind,_ as _ind) mib mip u params p =
let params = Array.map (lift ndecl) params in
let dep_cstr = mkApp(mkApp(mkConstructU (cstr,snd ind),params),relargs) in
mkApp(papp,[|dep_cstr|])
- in
+ in
decl, decl_with_letin, codom
in Array.mapi build_one_branch mip.mind_nf_lc
@@ -174,11 +174,11 @@ let build_case_type p realargs c =
(* normalisation of values *)
-let branch_of_switch lvl ans bs =
+let branch_of_switch lvl ans bs =
let tbl = ans.asw_reloc in
- let branch i =
+ let branch i =
let tag,arity = tbl.(i) in
- let ci =
+ let ci =
if Int.equal arity 0 then mk_const tag
else mk_block tag (mk_rels_accu lvl arity) in
bs ci in
@@ -195,11 +195,11 @@ let get_proj env (ind, proj_arg) =
let rec nf_val env sigma v typ =
match kind_of_value v with
| Vaccu accu -> nf_accu env sigma accu
- | Vfun f ->
+ | Vfun f ->
let lvl = nb_rel env in
let name,dom,codom =
- try decompose_prod env typ
- with DestKO ->
+ try decompose_prod env typ
+ with DestKO ->
CErrors.anomaly
(Pp.strbrk "Returned a functional value in a type not recognized as a product type.")
in
@@ -221,7 +221,7 @@ and nf_type env sigma v =
and nf_type_sort env sigma v =
match kind_of_value v with
- | Vaccu accu ->
+ | Vaccu accu ->
let t,s = nf_accu_type env sigma accu in
let s =
try
@@ -249,12 +249,12 @@ and nf_accu_type env sigma accu =
mkApp(a,Array.of_list args), t
and nf_args env sigma args t =
- let aux arg (t,l) =
+ let aux arg (t,l) =
let _,dom,codom =
try decompose_prod env t with
- DestKO ->
- CErrors.anomaly
- (Pp.strbrk "Returned a functional value in a type not recognized as a product type.")
+ DestKO ->
+ CErrors.anomaly
+ (Pp.strbrk "Returned a functional value in a type not recognized as a product type.")
in
let c = nf_val env sigma arg dom in
(subst1 c codom, c::l)
@@ -268,10 +268,10 @@ and nf_bargs env sigma b t =
Array.init len
(fun i ->
let _,dom,codom =
- try decompose_prod env !t with
- DestKO ->
- CErrors.anomaly
- (Pp.strbrk "Returned a functional value in a type not recognized as a product type.")
+ try decompose_prod env !t with
+ DestKO ->
+ CErrors.anomaly
+ (Pp.strbrk "Returned a functional value in a type not recognized as a product type.")
in
let c = nf_val env sigma (block_field b i) dom in
t := subst1 c codom; c)
@@ -318,9 +318,9 @@ and nf_atom_type env sigma atom =
let nparams = mib.mind_nparams in
let params,realargs = Array.chop nparams allargs in
let nparamdecls = Context.Rel.length (Inductive.inductive_paramdecls (mib,u)) in
- let pT =
+ let pT =
hnf_prod_applist_assum env nparamdecls
- (Inductiveops.type_of_inductive env ind) (Array.to_list params) in
+ (Inductiveops.type_of_inductive env ind) (Array.to_list params) in
let p = nf_predicate env sigma ind mip params p pT in
(* Calcul du type des branches *)
let btypes = build_branches_type env sigma (fst ind) mib mip u params p in
@@ -330,11 +330,11 @@ and nf_atom_type env sigma atom =
let decl,decl_with_letin,codom = btypes.(i) in
let b = nf_val (Termops.push_rels_assum decl env) sigma v codom in
Termops.it_mkLambda_or_LetIn_from_no_LetIn b decl_with_letin
- in
+ in
let branchs = Array.mapi mkbranch bsw in
let tcase = build_case_type p realargs a in
let ci = ans.asw_ci in
- mkCase(ci, p, a, branchs), tcase
+ mkCase(ci, p, a, branchs), tcase
| Afix(tt,ft,rp,s) ->
let tt = Array.map (fun t -> nf_type_sort env sigma t) tt in
let tt = Array.map fst tt and rt = Array.map snd tt in
@@ -393,7 +393,7 @@ and nf_predicate env sigma ind mip params v pT =
let k = nb_rel env in
let vb = f (mk_rel_accu k) in
let body =
- nf_predicate (push_rel (LocalAssum (name,dom)) env) sigma ind mip params vb codom in
+ nf_predicate (push_rel (LocalAssum (name,dom)) env) sigma ind mip params vb codom in
mkLambda(name,dom,body)
| _ -> nf_type env sigma v
end
@@ -444,23 +444,23 @@ let start_profiler_linux profile_fn =
let dev_null = Unix.descr_of_out_channel (open_out_bin "/dev/null") in
let _ = Feedback.msg_info (Pp.str ("Profiling to file " ^ profile_fn)) in
let perf = "perf" in
- let profiler_pid =
+ let profiler_pid =
Unix.create_process
perf
[|perf; "record"; "-g"; "-o"; profile_fn; "-p"; string_of_int coq_pid |]
Unix.stdin dev_null dev_null
in
(* doesn't seem to be a way to test whether process creation succeeded *)
- if !Flags.debug then
+ if !Flags.debug then
Feedback.msg_debug (Pp.str (Format.sprintf "Native compute profiler started, pid = %d, output to: %s" profiler_pid profile_fn));
Some profiler_pid
(* kill profiler via SIGINT *)
-let stop_profiler_linux m_pid =
- match m_pid with
+let stop_profiler_linux m_pid =
+ match m_pid with
| Some pid -> (
let _ = if !Flags.debug then Feedback.msg_debug (Pp.str "Stopping native code profiler") in
- try
+ try
Unix.kill pid Sys.sigint;
let _ = Unix.waitpid [] pid in ()
with Unix.Unix_error (Unix.ESRCH,"kill","") ->
@@ -475,7 +475,7 @@ let start_profiler () =
| _ ->
let _ = Feedback.msg_info
(Pp.str (Format.sprintf "Native_compute profiling not supported on the platform: %s"
- (profiler_platform ()))) in
+ (profiler_platform ()))) in
None
let stop_profiler m_pid =
diff --git a/pretyping/patternops.ml b/pretyping/patternops.ml
index 0c4312dc77..9ca3529b5c 100644
--- a/pretyping/patternops.ml
+++ b/pretyping/patternops.ml
@@ -136,7 +136,7 @@ let rec head_pattern_bound t =
| PRef r -> r
| PVar id -> GlobRef.VarRef id
| PEvar _ | PRel _ | PMeta _ | PSoApp _ | PSort _ | PFix _ | PProj _
- -> raise BoundPattern
+ -> raise BoundPattern
(* Perhaps they were arguments, but we don't beta-reduce *)
| PLambda _ -> raise BoundPattern
| PCoFix _ | PInt _ | PFloat _ -> anomaly ~label:"head_pattern_bound" (Pp.str "not a type.")
@@ -180,7 +180,7 @@ let pattern_of_constr env sigma t =
| Const (sp,u) -> PRef (GlobRef.ConstRef (Constant.make1 (Constant.canonical sp)))
| Ind (sp,u) -> PRef (canonical_gr (GlobRef.IndRef sp))
| Construct (sp,u) -> PRef (canonical_gr (GlobRef.ConstructRef sp))
- | Proj (p, c) ->
+ | Proj (p, c) ->
pattern_of_constr env (EConstr.Unsafe.to_constr (Retyping.expand_projection env sigma p (EConstr.of_constr c) []))
| Evar (evk,ctxt as ev) ->
(match snd (Evd.evar_source evk sigma) with
@@ -192,20 +192,20 @@ let pattern_of_constr env sigma t =
if Evd.is_defined sigma evk then pattern_of_constr env (Evd.existential_value0 sigma ev)
else PEvar (evk,Array.map (pattern_of_constr env) ctxt)
| Evar_kinds.MatchingVar (Evar_kinds.SecondOrderPatVar ido) -> assert false
- | _ ->
- PMeta None)
+ | _ ->
+ PMeta None)
| Case (ci,p,a,br) ->
let cip =
- { cip_style = ci.ci_pp_info.style;
- cip_ind = Some ci.ci_ind;
- cip_ind_tags = Some ci.ci_pp_info.ind_tags;
- cip_extensible = false }
- in
- let branch_of_constr i c =
- (i, ci.ci_pp_info.cstr_tags.(i), pattern_of_constr env c)
- in
- PCase (cip, pattern_of_constr env p, pattern_of_constr env a,
- Array.to_list (Array.mapi branch_of_constr br))
+ { cip_style = ci.ci_pp_info.style;
+ cip_ind = Some ci.ci_ind;
+ cip_ind_tags = Some ci.ci_pp_info.ind_tags;
+ cip_extensible = false }
+ in
+ let branch_of_constr i c =
+ (i, ci.ci_pp_info.cstr_tags.(i), pattern_of_constr env c)
+ in
+ PCase (cip, pattern_of_constr env p, pattern_of_constr env a,
+ Array.to_list (Array.mapi branch_of_constr br))
| Fix (lni,(lna,tl,bl)) ->
let push env na2 c2 = push_rel (LocalAssum (na2,c2)) env in
let env' = Array.fold_left2 push env lna tl in
@@ -244,7 +244,7 @@ let map_pattern_with_binders g f l = function
let error_instantiate_pattern id l =
let is = match l with
- | [_] -> "is"
+ | [_] -> "is"
| _ -> "are"
in
user_err (str "Cannot substitute the term bound to " ++ Id.print id
@@ -257,23 +257,23 @@ let instantiate_pattern env sigma lvar c =
let rec aux vars = function
| PVar id as x ->
(try
- let ctx,c = Id.Map.find id lvar in
- try
- let inst =
- List.map
+ let ctx,c = Id.Map.find id lvar in
+ try
+ let inst =
+ List.map
(fun id -> mkRel (List.index Name.equal (Name id) vars))
ctx
in
- let c = substl inst c in
+ let c = substl inst c in
(* FIXME: Stupid workaround to pattern_of_constr being evar sensitive *)
- let c = Evarutil.nf_evar sigma c in
- pattern_of_constr env sigma (EConstr.Unsafe.to_constr c)
- with Not_found (* List.index failed *) ->
- let vars =
- List.map_filter (function Name id -> Some id | _ -> None) vars in
- error_instantiate_pattern id (List.subtract Id.equal ctx vars)
+ let c = Evarutil.nf_evar sigma c in
+ pattern_of_constr env sigma (EConstr.Unsafe.to_constr c)
+ with Not_found (* List.index failed *) ->
+ let vars =
+ List.map_filter (function Name id -> Some id | _ -> None) vars in
+ error_instantiate_pattern id (List.subtract Id.equal ctx vars)
with Not_found (* Map.find failed *) ->
- x)
+ x)
| c ->
map_pattern_with_binders (fun id vars -> id::vars) aux vars c in
aux [] c
@@ -297,44 +297,44 @@ let rec subst_pattern env sigma subst pat =
| PRel _
| PInt _
| PFloat _ -> pat
- | PProj (p,c) ->
+ | PProj (p,c) ->
let p' = Projection.map (subst_mind subst) p in
let c' = subst_pattern env sigma subst c in
- if p' == p && c' == c then pat else
- PProj(p',c')
+ if p' == p && c' == c then pat else
+ PProj(p',c')
| PApp (f,args) ->
let f' = subst_pattern env sigma subst f in
let args' = Array.Smart.map (subst_pattern env sigma subst) args in
- if f' == f && args' == args then pat else
- PApp (f',args')
+ if f' == f && args' == args then pat else
+ PApp (f',args')
| PSoApp (i,args) ->
let args' = List.Smart.map (subst_pattern env sigma subst) args in
- if args' == args then pat else
- PSoApp (i,args')
+ if args' == args then pat else
+ PSoApp (i,args')
| PLambda (name,c1,c2) ->
let c1' = subst_pattern env sigma subst c1 in
let c2' = subst_pattern env sigma subst c2 in
- if c1' == c1 && c2' == c2 then pat else
- PLambda (name,c1',c2')
+ if c1' == c1 && c2' == c2 then pat else
+ PLambda (name,c1',c2')
| PProd (name,c1,c2) ->
let c1' = subst_pattern env sigma subst c1 in
let c2' = subst_pattern env sigma subst c2 in
- if c1' == c1 && c2' == c2 then pat else
- PProd (name,c1',c2')
+ if c1' == c1 && c2' == c2 then pat else
+ PProd (name,c1',c2')
| PLetIn (name,c1,t,c2) ->
let c1' = subst_pattern env sigma subst c1 in
let t' = Option.Smart.map (subst_pattern env sigma subst) t in
let c2' = subst_pattern env sigma subst c2 in
- if c1' == c1 && t' == t && c2' == c2 then pat else
- PLetIn (name,c1',t',c2')
+ if c1' == c1 && t' == t && c2' == c2 then pat else
+ PLetIn (name,c1',t',c2')
| PSort _
| PMeta _ -> pat
| PIf (c,c1,c2) ->
let c' = subst_pattern env sigma subst c in
let c1' = subst_pattern env sigma subst c1 in
let c2' = subst_pattern env sigma subst c2 in
- if c' == c && c1' == c1 && c2' == c2 then pat else
- PIf (c',c1',c2')
+ if c' == c && c1' == c1 && c2' == c2 then pat else
+ PIf (c',c1',c2')
| PCase (cip,typ,c,branches) ->
let ind = cip.cip_ind in
let ind' = Option.Smart.map (subst_ind subst) ind in
@@ -343,7 +343,7 @@ let rec subst_pattern env sigma subst pat =
let c' = subst_pattern env sigma subst c in
let subst_branch ((i,n,c) as br) =
let c' = subst_pattern env sigma subst c in
- if c' == c then br else (i,n,c')
+ if c' == c then br else (i,n,c')
in
let branches' = List.Smart.map subst_branch branches in
if cip' == cip && typ' == typ && c' == c && branches' == branches
@@ -400,21 +400,21 @@ let rec pat_of_raw metas vars = DAst.with_loc_val (fun ?loc -> function
metas := n::!metas; PSoApp (n, List.map (pat_of_raw metas vars) cl)
| _ ->
PApp (pat_of_raw metas vars c,
- Array.of_list (List.map (pat_of_raw metas vars) cl))
+ Array.of_list (List.map (pat_of_raw metas vars) cl))
end
| GLambda (na,bk,c1,c2) ->
Name.iter (fun n -> metas := n::!metas) na;
PLambda (na, pat_of_raw metas vars c1,
- pat_of_raw metas (na::vars) c2)
+ pat_of_raw metas (na::vars) c2)
| GProd (na,bk,c1,c2) ->
Name.iter (fun n -> metas := n::!metas) na;
PProd (na, pat_of_raw metas vars c1,
- pat_of_raw metas (na::vars) c2)
+ pat_of_raw metas (na::vars) c2)
| GLetIn (na,c1,t,c2) ->
Name.iter (fun n -> metas := n::!metas) na;
PLetIn (na, pat_of_raw metas vars c1,
Option.map (pat_of_raw metas vars) t,
- pat_of_raw metas (na::vars) c2)
+ pat_of_raw metas (na::vars) c2)
| GSort gs ->
(try PSort (Glob_ops.glob_sort_family gs)
with Glob_ops.ComplexSort -> user_err ?loc (str "Unexpected universe in pattern."))
@@ -431,26 +431,26 @@ let rec pat_of_raw metas vars = DAst.with_loc_val (fun ?loc -> function
GLambda (na,Explicit, DAst.make @@ GHole (Evar_kinds.InternalHole, Namegen.IntroAnonymous, None),c) in
let c = List.fold_right mkGLambda nal c in
let cip =
- { cip_style = LetStyle;
- cip_ind = None;
- cip_ind_tags = None;
- cip_extensible = false }
+ { cip_style = LetStyle;
+ cip_ind = None;
+ cip_ind_tags = None;
+ cip_extensible = false }
in
let tags = List.map (fun _ -> false) nal (* Approximation which can be without let-ins... *) in
PCase (cip, PMeta None, pat_of_raw metas vars b,
[0,tags,pat_of_raw metas vars c])
| GCases (sty,p,[c,(na,indnames)],brs) ->
- let get_ind p = match DAst.get p with
+ let get_ind p = match DAst.get p with
| PatCstr((ind,_),_,_) -> Some ind
| _ -> None
in
let get_ind = function
| {CAst.v=(_,[p],_)}::_ -> get_ind p
- | _ -> None
+ | _ -> None
in
let ind_tags,ind = match indnames with
| Some {CAst.v=(ind,nal)} -> Some (List.length nal), Some ind
- | None -> None, get_ind brs
+ | None -> None, get_ind brs
in
let ext,brs = pats_of_glob_branches loc metas vars ind brs
in
@@ -459,21 +459,21 @@ let rec pat_of_raw metas vars = DAst.with_loc_val (fun ?loc -> function
let nvars = na :: List.rev nal @ vars in
rev_it_mkPLambdaUntyped nal (mkPLambdaUntyped na (pat_of_raw metas nvars p))
| None, _ -> PMeta None
- | Some p, None ->
+ | Some p, None ->
match DAst.get p with
| GHole _ -> PMeta None
| _ ->
user_err ?loc (strbrk "Clause \"in\" expected in patterns over \"match\" expressions with an explicit \"return\" clause.")
in
let info =
- { cip_style = sty;
- cip_ind = ind;
- cip_ind_tags = None;
- cip_extensible = ext }
+ { cip_style = sty;
+ cip_ind = ind;
+ cip_ind_tags = None;
+ cip_extensible = ext }
in
(* Nota : when we have a non-trivial predicate,
- the inductive type is known. Same when we have at least
- one non-trivial branch. These facts are used in [Constrextern]. *)
+ the inductive type is known. Same when we have at least
+ one non-trivial branch. These facts are used in [Constrextern]. *)
PCase (info, pred, pat_of_raw metas vars c, brs)
| GRec (GFix (ln,n), ids, decls, tl, cl) ->
diff --git a/pretyping/pretyping.ml b/pretyping/pretyping.ml
index 2e1cb9ff08..4925f3e5fa 100644
--- a/pretyping/pretyping.ml
+++ b/pretyping/pretyping.ml
@@ -95,8 +95,8 @@ let search_guard ?loc env possible_indexes fixdefs =
(* we now search recursively among all combinations *)
(try
List.iter
- (fun l ->
- let indexes = Array.of_list l in
+ (fun l ->
+ let indexes = Array.of_list l in
let fix = ((indexes, 0),fixdefs) in
(* spiwack: We search for a unspecified structural
argument under the assumption that we need to check the
@@ -108,10 +108,10 @@ let search_guard ?loc env possible_indexes fixdefs =
let flags = { (typing_flags env) with Declarations.check_guarded = true } in
let env = Environ.set_typing_flags flags env in
check_fix env fix; raise (Found indexes)
- with TypeError _ -> ())
- (List.combinations possible_indexes);
+ with TypeError _ -> ())
+ (List.combinations possible_indexes);
let errmsg = "Cannot guess decreasing argument of fix." in
- user_err ?loc ~hdr:"search_guard" (Pp.str errmsg)
+ user_err ?loc ~hdr:"search_guard" (Pp.str errmsg)
with Found indexes -> indexes)
let esearch_guard ?loc env sigma indexes fix =
@@ -281,10 +281,10 @@ let check_extra_evars_are_solved env current_sigma frozen = match frozen with
(fun evk ->
if not (Evd.is_defined current_sigma evk) then
let (loc,k) = evar_source evk current_sigma in
- match k with
- | Evar_kinds.ImplicitArg (gr, (i, id), false) -> ()
- | _ ->
- error_unsolvable_implicit ?loc env current_sigma evk None) pending
+ match k with
+ | Evar_kinds.ImplicitArg (gr, (i, id), false) -> ()
+ | _ ->
+ error_unsolvable_implicit ?loc env current_sigma evk None) pending
(* [check_evars] fails if some unresolved evar remains *)
@@ -424,8 +424,8 @@ let interp_instance ?loc evd l =
str " universe instances must be greater or equal to Set.");
evd, Some (Univ.Instance.of_array (Array.of_list (List.rev l')))
-let pretype_global ?loc rigid env evd gr us =
- let evd, instance =
+let pretype_global ?loc rigid env evd gr us =
+ let evd, instance =
match us with
| None -> evd, None
| Some l -> interp_instance ?loc evd l
@@ -454,7 +454,7 @@ let interp_sort ?loc evd : glob_sort -> _ = function
| UNamed l -> interp_sort_info ?loc evd l
let judge_of_sort ?loc evd s =
- let judge =
+ let judge =
{ uj_val = mkType s; uj_type = mkType (Univ.super s) }
in
evd, judge
@@ -571,9 +571,9 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
let sigma =
match tycon with
| Some t ->
- let fixi = match fixkind with
- | GFix (vn,i) -> i
- | GCoFix i -> i
+ let fixi = match fixkind with
+ | GFix (vn,i) -> i
+ | GCoFix i -> i
in
begin match Evarconv.unify_delay !!env sigma ftys.(fixi) t with
| exception Evarconv.UnableToUnify _ -> sigma
@@ -605,32 +605,32 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
let ftys = Array.map nf ftys in (* FIXME *)
let fdefs = Array.map (fun x -> nf (j_val x)) vdefj in
let fixj = match fixkind with
- | GFix (vn,i) ->
- (* First, let's find the guard indexes. *)
- (* If recursive argument was not given by user, we try all args.
- An earlier approach was to look only for inductive arguments,
- but doing it properly involves delta-reduction, and it finally
+ | GFix (vn,i) ->
+ (* First, let's find the guard indexes. *)
+ (* If recursive argument was not given by user, we try all args.
+ An earlier approach was to look only for inductive arguments,
+ but doing it properly involves delta-reduction, and it finally
doesn't seem worth the effort (except for huge mutual
- fixpoints ?) *)
- let possible_indexes =
- Array.to_list (Array.mapi
+ fixpoints ?) *)
+ let possible_indexes =
+ Array.to_list (Array.mapi
(fun i annot -> match annot with
- | Some n -> [n]
- | None -> List.map_i (fun i _ -> i) 0 ctxtv.(i))
+ | Some n -> [n]
+ | None -> List.map_i (fun i _ -> i) 0 ctxtv.(i))
vn)
- in
+ in
let fixdecls = (names,ftys,fdefs) in
let indexes = esearch_guard ?loc !!env sigma possible_indexes fixdecls in
make_judge (mkFix ((indexes,i),fixdecls)) ftys.(i)
| GCoFix i ->
let fixdecls = (names,ftys,fdefs) in
- let cofix = (i, fixdecls) in
+ let cofix = (i, fixdecls) in
(try check_cofix !!env (i, nf_fix sigma fixdecls)
with reraise ->
let (e, info) = CErrors.push reraise in
let info = Option.cata (Loc.add_loc info) info loc in
iraise (e, info));
- make_judge (mkCoFix cofix) ftys.(i)
+ make_judge (mkCoFix cofix) ftys.(i)
in
inh_conv_coerce_to_tycon ?loc env sigma fixj tycon
@@ -674,7 +674,7 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
with Not_found -> []
else []
in
- let app_f =
+ let app_f =
match EConstr.kind sigma fj.uj_val with
| Const (p, u) when Recordops.is_primitive_projection p ->
let p = Option.get @@ Recordops.find_primitive_projection p in
@@ -824,37 +824,37 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
let (IndType (indf,realargs)) =
try find_rectype !!env sigma cj.uj_type
with Not_found ->
- let cloc = loc_of_glob_constr c in
+ let cloc = loc_of_glob_constr c in
error_case_not_inductive ?loc:cloc !!env sigma cj
in
let ind = fst (fst (dest_ind_family indf)) in
let cstrs = get_constructors !!env indf in
if not (Int.equal (Array.length cstrs) 1) then
user_err ?loc (str "Destructing let is only for inductive types" ++
- str " with one constructor.");
+ str " with one constructor.");
let cs = cstrs.(0) in
if not (Int.equal (List.length nal) cs.cs_nargs) then
- user_err ?loc:loc (str "Destructing let on this type expects " ++
- int cs.cs_nargs ++ str " variables.");
- let fsign, record =
+ user_err ?loc:loc (str "Destructing let on this type expects " ++
+ int cs.cs_nargs ++ str " variables.");
+ let fsign, record =
let set_name na d = set_name na (map_rel_decl EConstr.of_constr d) in
match Environ.get_projections !!env ind with
| None ->
- List.map2 set_name (List.rev nal) cs.cs_args, false
+ List.map2 set_name (List.rev nal) cs.cs_args, false
| Some ps ->
- let rec aux n k names l =
- match names, l with
+ let rec aux n k names l =
+ match names, l with
| na :: names, (LocalAssum (na', t) :: l) ->
let t = EConstr.of_constr t in
- let proj = Projection.make ps.(cs.cs_nargs - k) true in
+ let proj = Projection.make ps.(cs.cs_nargs - k) true in
LocalDef ({na' with binder_name = na},
lift (cs.cs_nargs - n) (mkProj (proj, cj.uj_val)), t)
- :: aux (n+1) (k + 1) names l
- | na :: names, (decl :: l) ->
- set_name na decl :: aux (n+1) k names l
- | [], [] -> []
- | _ -> assert false
- in aux 1 1 (List.rev nal) cs.cs_args, true in
+ :: aux (n+1) (k + 1) names l
+ | na :: names, (decl :: l) ->
+ set_name na decl :: aux (n+1) k names l
+ | [], [] -> []
+ | _ -> assert false
+ in aux 1 1 (List.rev nal) cs.cs_args, true in
let fsign = Context.Rel.map (whd_betaiota sigma) fsign in
let hypnaming = if program_mode then ProgramNaming else KeepUserNameAndRenameExistingButSectionNames in
let fsign,env_f = push_rel_context ~hypnaming sigma fsign env in
@@ -876,38 +876,38 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
let predenv = Cases.make_return_predicate_ltac_lvar env sigma na c cj.uj_val in
let nar = List.length arsgn in
let psign',env_p = push_rel_context ~hypnaming ~force_names:true sigma psign predenv in
- (match po with
- | Some p ->
+ (match po with
+ | Some p ->
let sigma, pj = pretype_type empty_valcon env_p sigma p in
let ccl = nf_evar sigma pj.utj_val in
- let p = it_mkLambda_or_LetIn ccl psign' in
- let inst =
- (Array.map_to_list EConstr.of_constr cs.cs_concl_realargs)
- @[EConstr.of_constr (build_dependent_constructor cs)] in
- let lp = lift cs.cs_nargs p in
+ let p = it_mkLambda_or_LetIn ccl psign' in
+ let inst =
+ (Array.map_to_list EConstr.of_constr cs.cs_concl_realargs)
+ @[EConstr.of_constr (build_dependent_constructor cs)] in
+ let lp = lift cs.cs_nargs p in
let fty = hnf_lam_applist !!env sigma lp inst in
let sigma, fj = pretype (mk_tycon fty) env_f sigma d in
- let v =
- let ind,_ = dest_ind_family indf in
+ let v =
+ let ind,_ = dest_ind_family indf in
let rci = Typing.check_allowed_sort !!env sigma ind cj.uj_val p in
obj ind rci p cj.uj_val fj.uj_val
in
sigma, { uj_val = v; uj_type = (substl (realargs@[cj.uj_val]) ccl) }
- | None ->
- let tycon = lift_tycon cs.cs_nargs tycon in
+ | None ->
+ let tycon = lift_tycon cs.cs_nargs tycon in
let sigma, fj = pretype tycon env_f sigma d in
let ccl = nf_evar sigma fj.uj_type in
- let ccl =
+ let ccl =
if noccur_between sigma 1 cs.cs_nargs ccl then
- lift (- cs.cs_nargs) ccl
- else
+ lift (- cs.cs_nargs) ccl
+ else
error_cant_find_case_type ?loc !!env sigma
- cj.uj_val in
- (* let ccl = refresh_universes ccl in *)
- let p = it_mkLambda_or_LetIn (lift (nar+1) ccl) psign' in
- let v =
- let ind,_ = dest_ind_family indf in
+ cj.uj_val in
+ (* let ccl = refresh_universes ccl in *)
+ let p = it_mkLambda_or_LetIn (lift (nar+1) ccl) psign' in
+ let v =
+ let ind,_ = dest_ind_family indf in
let rci = Typing.check_allowed_sort !!env sigma ind cj.uj_val p in
obj ind rci p cj.uj_val fj.uj_val
in sigma, { uj_val = v; uj_type = ccl })
@@ -917,12 +917,12 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
let (IndType (indf,realargs)) =
try find_rectype !!env sigma cj.uj_type
with Not_found ->
- let cloc = loc_of_glob_constr c in
+ let cloc = loc_of_glob_constr c in
error_case_not_inductive ?loc:cloc !!env sigma cj in
let cstrs = get_constructors !!env indf in
if not (Int.equal (Array.length cstrs) 2) then
- user_err ?loc
- (str "If is only for inductive types with two constructors.");
+ user_err ?loc
+ (str "If is only for inductive types with two constructors.");
let arsgn, indr =
let arsgn,s = get_arity !!env indf in
@@ -937,27 +937,27 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
let hypnaming = if program_mode then ProgramNaming else KeepUserNameAndRenameExistingButSectionNames in
let psign,env_p = push_rel_context ~hypnaming sigma psign predenv in
let sigma, pred, p = match po with
- | Some p ->
+ | Some p ->
let sigma, pj = pretype_type empty_valcon env_p sigma p in
let ccl = nf_evar sigma pj.utj_val in
let pred = it_mkLambda_or_LetIn ccl psign in
let typ = lift (- nar) (beta_applist sigma (pred,[cj.uj_val])) in
sigma, pred, typ
- | None ->
+ | None ->
let sigma, p = match tycon with
| Some ty -> sigma, ty
| None -> new_type_evar env sigma loc
- in
+ in
sigma, it_mkLambda_or_LetIn (lift (nar+1) p) psign, p in
let pred = nf_evar sigma pred in
let p = nf_evar sigma p in
let f sigma cs b =
- let n = Context.Rel.length cs.cs_args in
- let pi = lift n pred in (* liftn n 2 pred ? *)
+ let n = Context.Rel.length cs.cs_args in
+ let pi = lift n pred in (* liftn n 2 pred ? *)
let pi = beta_applist sigma (pi, [EConstr.of_constr (build_dependent_constructor cs)]) in
let cs_args = List.map (fun d -> map_rel_decl EConstr.of_constr d) cs.cs_args in
let cs_args = Context.Rel.map (whd_betaiota sigma) cs_args in
- let csgn =
+ let csgn =
List.map (set_name Anonymous) cs_args
in
let _,env_c = push_rel_context ~hypnaming sigma csgn env in
@@ -966,7 +966,7 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
let sigma, b1 = f sigma cstrs.(0) b1 in
let sigma, b2 = f sigma cstrs.(1) b2 in
let v =
- let ind,_ = dest_ind_family indf in
+ let ind,_ = dest_ind_family indf in
let pred = nf_evar sigma pred in
let rci = Typing.check_allowed_sort !!env sigma ind cj.uj_val pred in
let ci = make_case_info !!env (fst ind) rci IfStyle in
@@ -991,7 +991,7 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
~onlyalg:true ~status:Evd.univ_flexible (Some false) !!env sigma tj.utj_val in
let tval = nf_evar sigma tval in
let (sigma, cj), tval = match k with
- | VMcast ->
+ | VMcast ->
let sigma, cj = pretype empty_tycon env sigma c in
let cty = nf_evar sigma cj.uj_type and tval = nf_evar sigma tval in
if not (occur_existential sigma cty || occur_existential sigma tval) then
@@ -1000,9 +1000,9 @@ let rec pretype ~program_mode ~poly resolve_tc (tycon : type_constraint) (env :
| None ->
error_actual_type ?loc !!env sigma cj tval
(ConversionFailed (!!env,cty,tval))
- else user_err ?loc (str "Cannot check cast with vm: " ++
- str "unresolved arguments remain.")
- | NATIVEcast ->
+ else user_err ?loc (str "Cannot check cast with vm: " ++
+ str "unresolved arguments remain.")
+ | NATIVEcast ->
let sigma, cj = pretype empty_tycon env sigma c in
let cty = nf_evar sigma cj.uj_type and tval = nf_evar sigma tval in
begin
@@ -1121,13 +1121,13 @@ and pretype_type ~program_mode ~poly resolve_tc valcon (env : GlobEnv.t) sigma c
let sigma, j = pretype ~program_mode ~poly resolve_tc empty_tycon env sigma c in
let loc = loc_of_glob_constr c in
let sigma, tj = Coercion.inh_coerce_to_sort ?loc !!env sigma j in
- match valcon with
+ match valcon with
| None -> sigma, tj
- | Some v ->
+ | Some v ->
begin match Evarconv.unify_leq_delay !!env sigma v tj.utj_val with
| sigma -> sigma, tj
| exception Evarconv.UnableToUnify _ ->
- error_unexpected_type
+ error_unexpected_type
?loc:(loc_of_glob_constr c) !!env sigma tj.utj_val v
end
diff --git a/pretyping/program.ml b/pretyping/program.ml
index a15e66f329..1bc31646dd 100644
--- a/pretyping/program.ml
+++ b/pretyping/program.ml
@@ -11,7 +11,7 @@
open CErrors
open Util
-let papp evdref r args =
+let papp evdref r args =
let open EConstr in
let gr = delayed_force r in
let evd, hd = Evarutil.new_global !evdref gr in
diff --git a/pretyping/recordops.ml b/pretyping/recordops.ml
index 48838a44c4..5b416a99f9 100644
--- a/pretyping/recordops.ml
+++ b/pretyping/recordops.ml
@@ -119,7 +119,7 @@ let find_primitive_projection c =
c := [x1:B1]...[xk:Bk](Build_R a1...am t1...t_n)
If ti has the form (ci ui1...uir) where ci is a global reference (or
- a sort, or a product or a reference to a parameter) and if the
+ a sort, or a product or a reference to a parameter) and if the
corresponding projection Li of the structure R is defined, one
declares a "conversion" between ci and Li.
diff --git a/pretyping/recordops.mli b/pretyping/recordops.mli
index 3f64c06a2d..e8b0d771aa 100644
--- a/pretyping/recordops.mli
+++ b/pretyping/recordops.mli
@@ -61,8 +61,8 @@ val is_primitive_projection : Constant.t -> bool
val find_primitive_projection : Constant.t -> Projection.Repr.t option
(** {6 Canonical structures } *)
-(** A canonical structure declares "canonical" conversion hints between
- the effective components of a structure and the projections of the
+(** A canonical structure declares "canonical" conversion hints between
+ the effective components of a structure and the projections of the
structure *)
(** A cs_pattern characterizes the form of a component of canonical structure *)
diff --git a/pretyping/reductionops.ml b/pretyping/reductionops.ml
index 2952466fbb..4d4fe13983 100644
--- a/pretyping/reductionops.ml
+++ b/pretyping/reductionops.ml
@@ -134,14 +134,14 @@ module ReductionBehaviour = struct
| _ -> assert false
let inRedBehaviour = declare_object {
- (default_object "REDUCTIONBEHAVIOUR") with
- load_function = load;
- cache_function = cache;
- classify_function = classify;
- subst_function = subst;
- discharge_function = discharge;
- rebuild_function = rebuild;
- }
+ (default_object "REDUCTIONBEHAVIOUR") with
+ load_function = load;
+ cache_function = cache;
+ classify_function = classify;
+ subst_function = subst;
+ discharge_function = discharge;
+ rebuild_function = rebuild;
+ }
let set ~local r b =
Lib.add_anonymous_leaf (inRedBehaviour (local, (r, b)))
@@ -156,9 +156,9 @@ module ReductionBehaviour = struct
| Some b ->
let pp_nomatch = spc () ++ str "but avoid exposing match constructs" in
let pp_recargs recargs = spc() ++ str "when the " ++
- pr_enum (fun x -> pr_nth (x+1)) recargs ++ str (String.plural (List.length recargs) " argument") ++
- str (String.plural (if List.length recargs >= 2 then 1 else 2) " evaluate") ++
- str " to a constructor" in
+ pr_enum (fun x -> pr_nth (x+1)) recargs ++ str (String.plural (List.length recargs) " argument") ++
+ str (String.plural (if List.length recargs >= 2 then 1 else 2) " evaluate") ++
+ str " to a constructor" in
let pp_nargs nargs =
spc() ++ str "when applied to " ++ int nargs ++
str (String.plural nargs " argument") in
@@ -206,9 +206,9 @@ module Cst_stack = struct
let append2cst = function
| (c,params,[]) -> (c, h::params, [])
| (c,params,((i,t)::q)) when i = pred (Array.length t) ->
- (c, params, q)
+ (c, params, q)
| (c,params,(i,t)::q) ->
- (c, params, (succ i,t)::q)
+ (c, params, (succ i,t)::q)
in
drop_useless (List.map append2cst cst_l)
@@ -234,18 +234,18 @@ module Cst_stack = struct
(fun t (i,args) -> mkApp (t,Array.sub args i (Array.length args - i))) in
List.fold_right
(fun (cst,params,args) t -> Termops.replace_term sigma
- (reconstruct_head d args)
- (applist (cst, List.rev params))
- t) cst_l c
+ (reconstruct_head d args)
+ (applist (cst, List.rev params))
+ t) cst_l c
let pr env sigma l =
let open Pp in
let p_c c = Termops.Internal.print_constr_env env sigma c in
prlist_with_sep pr_semicolon
(fun (c,params,args) ->
- hov 1 (str"(" ++ p_c c ++ str ")" ++ spc () ++ pr_sequence p_c params ++ spc () ++ str "(args:" ++
- pr_sequence (fun (i,el) -> prvect_with_sep spc p_c (Array.sub el i (Array.length el - i))) args ++
- str ")")) l
+ hov 1 (str"(" ++ p_c c ++ str ")" ++ spc () ++ pr_sequence p_c params ++ spc () ++ str "(args:" ++
+ pr_sequence (fun (i,el) -> prvect_with_sep spc p_c (Array.sub el i (Array.length el - i))) args ++
+ str ")")) l
end
@@ -313,8 +313,8 @@ struct
let pr_app_node pr (i,a,j) =
let open Pp in surround (
- prvect_with_sep pr_comma pr (Array.sub a i (j - i + 1))
- )
+ prvect_with_sep pr_comma pr (Array.sub a i (j - i + 1))
+ )
type cst_member =
@@ -339,7 +339,7 @@ struct
| App app -> str "ZApp" ++ pr_app_node pr_c app
| Case (_,_,br,cst) ->
str "ZCase(" ++
- prvect_with_sep (pr_bar) pr_c br
+ prvect_with_sep (pr_bar) pr_c br
++ str ")"
| Proj (p,cst) ->
str "ZProj(" ++ Constant.debug_print (Projection.constant p) ++ str ")"
@@ -352,8 +352,8 @@ struct
| Cst (mem,curr,remains,params,cst_l) ->
str "ZCst(" ++ pr_cst_member pr_c mem ++ pr_comma () ++ int curr
++ pr_comma () ++
- prlist_with_sep pr_semicolon int remains ++
- pr_comma () ++ pr pr_c params ++ str ")"
+ prlist_with_sep pr_semicolon int remains ++
+ pr_comma () ++ pr pr_c params ++ str ")"
and pr pr_c l =
let open Pp in
prlist_with_sep pr_semicolon (fun x -> hov 1 (pr_member pr_c x)) l
@@ -364,7 +364,7 @@ struct
| Cst_const (c, u) ->
if Univ.Instance.is_empty u then Constant.debug_print c
else str"(" ++ Constant.debug_print c ++ str ", " ++
- Univ.Instance.pr Univ.Level.pr u ++ str")"
+ Univ.Instance.pr Univ.Level.pr u ++ str")"
| Cst_proj p ->
str".(" ++ Constant.debug_print (Projection.constant p) ++ str")"
@@ -421,13 +421,13 @@ struct
let compare_shape stk1 stk2 =
let rec compare_rec bal stk1 stk2 =
match (stk1,stk2) with
- ([],[]) -> Int.equal bal 0
+ ([],[]) -> Int.equal bal 0
| (App (i,_,j)::s1, _) -> compare_rec (bal + j + 1 - i) s1 stk2
| (_, App (i,_,j)::s2) -> compare_rec (bal - j - 1 + i) stk1 s2
| (Case(c1,_,_,_)::s1, Case(c2,_,_,_)::s2) ->
Int.equal bal 0 (* && c1.ci_ind = c2.ci_ind *) && compare_rec 0 s1 s2
| (Proj (p,_)::s1, Proj(p2,_)::s2) ->
- Int.equal bal 0 && compare_rec 0 s1 s2
+ Int.equal bal 0 && compare_rec 0 s1 s2
| (Fix(_,a1,_)::s1, Fix(_,a2,_)::s2) ->
Int.equal bal 0 && compare_rec 0 a1 a2 && compare_rec 0 s1 s2
| (Primitive(_,_,a1,_,_)::s1, Primitive(_,_,a2,_,_)::s2) ->
@@ -462,14 +462,14 @@ struct
let rec map f x = List.map (function
| (Proj (_,_)) as e -> e
- | App (i,a,j) ->
- let le = j - i + 1 in
- App (0,Array.map f (Array.sub a i le), le-1)
+ | App (i,a,j) ->
+ let le = j - i + 1 in
+ App (0,Array.map f (Array.sub a i le), le-1)
| Case (info,ty,br,alt) -> Case (info, f ty, Array.map f br, alt)
| Fix ((r,(na,ty,bo)),arg,alt) ->
Fix ((r,(na,Array.map f ty, Array.map f bo)),map f arg,alt)
| Cst (cst,curr,remains,params,alt) ->
- Cst (cst,curr,remains,map f params,alt)
+ Cst (cst,curr,remains,map f params,alt)
| Primitive (p,c,args,kargs,cst_l) ->
Primitive(p,c, map f args, kargs, cst_l)
) x
@@ -490,15 +490,15 @@ struct
let strip_n_app n s =
let rec aux n out = function
| App (i,a,j) as e :: s ->
- let nb = j - i + 1 in
- if n >= nb then
- aux (n - nb) (e::out) s
- else
- let p = i+n in
- Some (CList.rev
- (if Int.equal n 0 then out else App (i,a,p-1) :: out),
- a.(p),
- if j > p then App(succ p,a,j)::s else s)
+ let nb = j - i + 1 in
+ if n >= nb then
+ aux (n - nb) (e::out) s
+ else
+ let p = i+n in
+ Some (CList.rev
+ (if Int.equal n 0 then out else App (i,a,p-1) :: out),
+ a.(p),
+ if j > p then App(succ p,a,j)::s else s)
| s -> None
in aux n [] s
@@ -530,15 +530,15 @@ struct
let tail n0 s0 =
let rec aux n s =
if Int.equal n 0 then s else
- match s with
+ match s with
| App (i,a,j) :: s ->
- let nb = j - i + 1 in
- if n >= nb then
+ let nb = j - i + 1 in
+ if n >= nb then
aux (n - nb) s
- else
- let p = i+n in
- if j >= p then App(p,a,j)::s else s
- | _ -> raise (Invalid_argument "Reductionops.Stack.tail")
+ else
+ let p = i+n in
+ if j >= p then App(p,a,j)::s else s
+ | _ -> raise (Invalid_argument "Reductionops.Stack.tail")
in aux n0 s0
let nth s p =
@@ -551,17 +551,17 @@ struct
let rec aux sk def = function
|(cst, params, []) -> (cst, append_app_list (List.rev params) sk)
|(cst, params, (i,t)::q) -> match decomp sk with
- | Some (el,sk') when EConstr.eq_constr sigma el t.(i) ->
- if i = pred (Array.length t)
- then aux sk' def (cst, params, q)
- else aux sk' def (cst, params, (succ i,t)::q)
- | _ -> def
+ | Some (el,sk') when EConstr.eq_constr sigma el t.(i) ->
+ if i = pred (Array.length t)
+ then aux sk' def (cst, params, q)
+ else aux sk' def (cst, params, (succ i,t)::q)
+ | _ -> def
in List.fold_left (aux sk) s l
let constr_of_cst_member f sk =
match f with
| Cst_const (c, u) -> mkConstU (c, EInstance.make u), sk
- | Cst_proj p ->
+ | Cst_proj p ->
match decomp sk with
| Some (hd, sk) -> mkProj (p, hd), sk
| None -> assert false
@@ -571,8 +571,8 @@ struct
| f, [] -> f
| f, (App (i,a,j) :: s) ->
let a' = if Int.equal i 0 && Int.equal j (Array.length a - 1)
- then a
- else Array.sub a i (j - i + 1) in
+ then a
+ else Array.sub a i (j - i + 1) in
zip (mkApp (f, a'), s)
| f, (Case (ci,rt,br,cst_l)::s) when refold ->
zip (best_state sigma (mkCase (ci,rt,f,br), s) cst_l)
@@ -781,11 +781,11 @@ let reduce_mind_case sigma mia =
match EConstr.kind sigma mia.mconstr with
| Construct ((ind_sp,i),u) ->
(* let ncargs = (fst mia.mci).(i-1) in*)
- let real_cargs = List.skipn mia.mci.ci_npar mia.mcargs in
+ let real_cargs = List.skipn mia.mci.ci_npar mia.mcargs in
applist (mia.mlf.(i-1),real_cargs)
| CoFix cofix ->
- let cofix_def = contract_cofix sigma cofix in
- mkCase (mia.mci, mia.mP, applist(cofix_def,mia.mcargs), mia.mlf)
+ let cofix_def = contract_cofix sigma cofix in
+ mkCase (mia.mci, mia.mP, applist(cofix_def,mia.mcargs), mia.mlf)
| _ -> assert false
(* contracts fix==FIX[nl;i](A1...Ak;[F1...Fk]{B1....Bk}) to produce
@@ -797,10 +797,10 @@ let contract_fix ?env sigma ?reference ((recindices,bodynum),(names,types,bodies
let ind = nbodies-j-1 in
if Int.equal bodynum ind then mkFix ((recindices,ind),typedbodies)
else
- let bd = mkFix ((recindices,ind),typedbodies) in
- match env with
- | None -> bd
- | Some e ->
+ let bd = mkFix ((recindices,ind),typedbodies) in
+ match env with
+ | None -> bd
+ | Some e ->
match reference with
| None -> bd
| Some r -> magicaly_constant_of_fixbody e sigma r bd names.(ind).binder_name in
@@ -990,13 +990,13 @@ let rec whd_state_gen ?csts ~refold ~tactic_mode flags env sigma =
let open ReductionBehaviour in
let rec whrec cst_l (x, stack) =
let () = if !debug_RAKAM then
- let open Pp in
+ let open Pp in
let pr c = Termops.Internal.print_constr_env env sigma c in
Feedback.msg_debug
(h 0 (str "<<" ++ pr x ++
str "|" ++ cut () ++ Cst_stack.pr env sigma cst_l ++
- str "|" ++ cut () ++ Stack.pr pr stack ++
- str ">>"))
+ str "|" ++ cut () ++ Stack.pr pr stack ++
+ str ">>"))
in
let c0 = EConstr.kind sigma x in
let fold () =
@@ -1012,7 +1012,7 @@ let rec whd_state_gen ?csts ~refold ~tactic_mode flags env sigma =
| Var id when CClosure.RedFlags.red_set flags (CClosure.RedFlags.fVAR id) ->
(match lookup_named id env with
| LocalDef (_,body,_) ->
- whrec (if refold then Cst_stack.add_cst (mkVar id) cst_l else cst_l) (body, stack)
+ whrec (if refold then Cst_stack.add_cst (mkVar id) cst_l else cst_l) (body, stack)
| _ -> fold ())
| Evar ev -> fold ()
| Meta ev ->
@@ -1125,28 +1125,28 @@ let rec whd_state_gen ?csts ~refold ~tactic_mode flags env sigma =
| Cast (c,_,_) -> whrec cst_l (c, stack)
| App (f,cl) ->
whrec
- (if refold then Cst_stack.add_args cl cst_l else cst_l)
- (f, Stack.append_app cl stack)
+ (if refold then Cst_stack.add_args cl cst_l else cst_l)
+ (f, Stack.append_app cl stack)
| Lambda (na,t,c) ->
(match Stack.decomp stack with
| Some _ when CClosure.RedFlags.red_set flags CClosure.RedFlags.fBETA ->
- apply_subst (fun _ -> whrec) [] sigma refold cst_l x stack
+ apply_subst (fun _ -> whrec) [] sigma refold cst_l x stack
| None when CClosure.RedFlags.red_set flags CClosure.RedFlags.fETA ->
let env' = push_rel (LocalAssum (na, t)) env in
- let whrec' = whd_state_gen ~refold ~tactic_mode flags env' sigma in
+ let whrec' = whd_state_gen ~refold ~tactic_mode flags env' sigma in
(match EConstr.kind sigma (Stack.zip ~refold sigma (fst (whrec' (c, Stack.empty)))) with
| App (f,cl) ->
- let napp = Array.length cl in
- if napp > 0 then
- let (x', l'),_ = whrec' (Array.last cl, Stack.empty) in
+ let napp = Array.length cl in
+ if napp > 0 then
+ let (x', l'),_ = whrec' (Array.last cl, Stack.empty) in
match EConstr.kind sigma x', l' with
| Rel 1, [] ->
- let lc = Array.sub cl 0 (napp-1) in
- let u = if Int.equal napp 1 then f else mkApp (f,lc) in
- if noccurn sigma 1 u then (pop u,Stack.empty),Cst_stack.empty else fold ()
+ let lc = Array.sub cl 0 (napp-1) in
+ let u = if Int.equal napp 1 then f else mkApp (f,lc) in
+ if noccurn sigma 1 u then (pop u,Stack.empty),Cst_stack.empty else fold ()
| _ -> fold ()
- else fold ()
- | _ -> fold ())
+ else fold ()
+ | _ -> fold ())
| _ -> fold ())
| Case (ci,p,d,lf) ->
@@ -1156,57 +1156,57 @@ let rec whd_state_gen ?csts ~refold ~tactic_mode flags env sigma =
(match Stack.strip_n_app ri.(n) stack with
|None -> fold ()
|Some (bef,arg,s') ->
- whrec Cst_stack.empty (arg, Stack.Fix(f,bef,cst_l)::s'))
+ whrec Cst_stack.empty (arg, Stack.Fix(f,bef,cst_l)::s'))
| Construct ((ind,c),u) ->
let use_match = CClosure.RedFlags.red_set flags CClosure.RedFlags.fMATCH in
let use_fix = CClosure.RedFlags.red_set flags CClosure.RedFlags.fFIX in
if use_match || use_fix then
- match Stack.strip_app stack with
- |args, (Stack.Case(ci, _, lf,_)::s') when use_match ->
- whrec Cst_stack.empty (lf.(c-1), (Stack.tail ci.ci_npar args) @ s')
+ match Stack.strip_app stack with
+ |args, (Stack.Case(ci, _, lf,_)::s') when use_match ->
+ whrec Cst_stack.empty (lf.(c-1), (Stack.tail ci.ci_npar args) @ s')
|args, (Stack.Proj (p,_)::s') when use_match ->
whrec Cst_stack.empty (Stack.nth args (Projection.npars p + Projection.arg p), s')
- |args, (Stack.Fix (f,s',cst_l)::s'') when use_fix ->
- let x' = Stack.zip sigma (x, args) in
- let out_sk = s' @ (Stack.append_app [|x'|] s'') in
- reduce_and_refold_fix whrec env sigma refold cst_l f out_sk
- |args, (Stack.Cst (const,curr,remains,s',cst_l) :: s'') ->
- let x' = Stack.zip sigma (x, args) in
- begin match remains with
- | [] ->
- (match const with
- | Stack.Cst_const const ->
- (match constant_opt_value_in env const with
- | None -> fold ()
- | Some body ->
+ |args, (Stack.Fix (f,s',cst_l)::s'') when use_fix ->
+ let x' = Stack.zip sigma (x, args) in
+ let out_sk = s' @ (Stack.append_app [|x'|] s'') in
+ reduce_and_refold_fix whrec env sigma refold cst_l f out_sk
+ |args, (Stack.Cst (const,curr,remains,s',cst_l) :: s'') ->
+ let x' = Stack.zip sigma (x, args) in
+ begin match remains with
+ | [] ->
+ (match const with
+ | Stack.Cst_const const ->
+ (match constant_opt_value_in env const with
+ | None -> fold ()
+ | Some body ->
let const = (fst const, EInstance.make (snd const)) in
let body = EConstr.of_constr body in
- whrec (if refold then Cst_stack.add_cst (mkConstU const) cst_l else cst_l)
- (body, s' @ (Stack.append_app [|x'|] s'')))
- | Stack.Cst_proj p ->
+ whrec (if refold then Cst_stack.add_cst (mkConstU const) cst_l else cst_l)
+ (body, s' @ (Stack.append_app [|x'|] s'')))
+ | Stack.Cst_proj p ->
let stack = s' @ (Stack.append_app [|x'|] s'') in
- match Stack.strip_n_app 0 stack with
- | None -> assert false
- | Some (_,arg,s'') ->
+ match Stack.strip_n_app 0 stack with
+ | None -> assert false
+ | Some (_,arg,s'') ->
whrec Cst_stack.empty (arg, Stack.Proj (p,cst_l) :: s''))
- | next :: remains' -> match Stack.strip_n_app (next-curr-1) s'' with
- | None -> fold ()
- | Some (bef,arg,s''') ->
- whrec Cst_stack.empty
- (arg,
- Stack.Cst (const,next,remains',s' @ (Stack.append_app [|x'|] bef),cst_l) :: s''')
- end
+ | next :: remains' -> match Stack.strip_n_app (next-curr-1) s'' with
+ | None -> fold ()
+ | Some (bef,arg,s''') ->
+ whrec Cst_stack.empty
+ (arg,
+ Stack.Cst (const,next,remains',s' @ (Stack.append_app [|x'|] bef),cst_l) :: s''')
+ end
|_, (Stack.App _)::_ -> assert false
- |_, _ -> fold ()
+ |_, _ -> fold ()
else fold ()
| CoFix cofix ->
if CClosure.RedFlags.red_set flags CClosure.RedFlags.fCOFIX then
- match Stack.strip_app stack with
- |args, ((Stack.Case _ |Stack.Proj _)::s') ->
- reduce_and_refold_cofix whrec env sigma refold cst_l cofix stack
- |_ -> fold ()
+ match Stack.strip_app stack with
+ |args, ((Stack.Case _ |Stack.Proj _)::s') ->
+ reduce_and_refold_cofix whrec env sigma refold cst_l cofix stack
+ |_ -> fold ()
else fold ()
| Int _ | Float _ ->
@@ -1253,21 +1253,21 @@ let local_whd_state_gen flags sigma =
| Lambda (_,_,c) ->
(match Stack.decomp stack with
| Some (a,m) when CClosure.RedFlags.red_set flags CClosure.RedFlags.fBETA ->
- stacklam whrec [a] sigma c m
+ stacklam whrec [a] sigma c m
| None when CClosure.RedFlags.red_set flags CClosure.RedFlags.fETA ->
(match EConstr.kind sigma (Stack.zip sigma (whrec (c, Stack.empty))) with
| App (f,cl) ->
- let napp = Array.length cl in
- if napp > 0 then
- let x', l' = whrec (Array.last cl, Stack.empty) in
+ let napp = Array.length cl in
+ if napp > 0 then
+ let x', l' = whrec (Array.last cl, Stack.empty) in
match EConstr.kind sigma x', l' with
| Rel 1, [] ->
- let lc = Array.sub cl 0 (napp-1) in
- let u = if Int.equal napp 1 then f else mkApp (f,lc) in
- if noccurn sigma 1 u then (pop u,Stack.empty) else s
+ let lc = Array.sub cl 0 (napp-1) in
+ let u = if Int.equal napp 1 then f else mkApp (f,lc) in
+ if noccurn sigma 1 u then (pop u,Stack.empty) else s
| _ -> s
- else s
- | _ -> s)
+ else s
+ | _ -> s)
| _ -> s)
| Proj (p,c) when CClosure.RedFlags.red_projection flags p ->
@@ -1291,24 +1291,24 @@ let local_whd_state_gen flags sigma =
let use_match = CClosure.RedFlags.red_set flags CClosure.RedFlags.fMATCH in
let use_fix = CClosure.RedFlags.red_set flags CClosure.RedFlags.fFIX in
if use_match || use_fix then
- match Stack.strip_app stack with
- |args, (Stack.Case(ci, _, lf,_)::s') when use_match ->
- whrec (lf.(c-1), (Stack.tail ci.ci_npar args) @ s')
+ match Stack.strip_app stack with
+ |args, (Stack.Case(ci, _, lf,_)::s') when use_match ->
+ whrec (lf.(c-1), (Stack.tail ci.ci_npar args) @ s')
|args, (Stack.Proj (p,_) :: s') when use_match ->
whrec (Stack.nth args (Projection.npars p + Projection.arg p), s')
- |args, (Stack.Fix (f,s',cst)::s'') when use_fix ->
- let x' = Stack.zip sigma (x,args) in
- whrec (contract_fix sigma f, s' @ (Stack.append_app [|x'|] s''))
+ |args, (Stack.Fix (f,s',cst)::s'') when use_fix ->
+ let x' = Stack.zip sigma (x,args) in
+ whrec (contract_fix sigma f, s' @ (Stack.append_app [|x'|] s''))
|_, (Stack.App _|Stack.Cst _)::_ -> assert false
- |_, _ -> s
+ |_, _ -> s
else s
| CoFix cofix ->
if CClosure.RedFlags.red_set flags CClosure.RedFlags.fCOFIX then
- match Stack.strip_app stack with
- |args, ((Stack.Case _ | Stack.Proj _)::s') ->
- whrec (contract_cofix sigma cofix, stack)
- |_ -> s
+ match Stack.strip_app stack with
+ |args, ((Stack.Case _ | Stack.Proj _)::s') ->
+ whrec (contract_cofix sigma cofix, stack)
+ |_ -> s
else s
| Rel _ | Var _ | Sort _ | Prod _ | LetIn _ | Const _ | Ind _ | Proj _
@@ -1510,7 +1510,7 @@ let sigma_compare_instances ~flex i0 i1 sigma =
try Evd.set_eq_instances ~flex sigma i0 i1
with Evd.UniversesDiffer
| Univ.UniverseInconsistency _ ->
- raise Reduction.NotConvertible
+ raise Reduction.NotConvertible
let sigma_check_inductive_instances cv_pb variance u1 u2 sigma =
match Evarutil.compare_cumulative_instances cv_pb variance u1 u2 sigma with
@@ -1518,7 +1518,7 @@ let sigma_check_inductive_instances cv_pb variance u1 u2 sigma =
| Inr _ ->
raise Reduction.NotConvertible
-let sigma_univ_state =
+let sigma_univ_state =
let open Reduction in
{ compare_sorts = sigma_compare_sorts;
compare_instances = sigma_compare_instances;
@@ -1545,9 +1545,9 @@ let infer_conv_gen conv_fun ?(catch_incon=true) ?(pb=Reduction.CUMUL)
| None ->
let x = EConstr.Unsafe.to_constr x in
let y = EConstr.Unsafe.to_constr y in
- let sigma' =
- conv_fun pb ~l2r:false sigma ts
- env (sigma, sigma_univ_state) x y in
+ let sigma' =
+ conv_fun pb ~l2r:false sigma ts
+ env (sigma, sigma_univ_state) x y in
Some sigma'
with
| Reduction.NotConvertible -> None
@@ -1583,23 +1583,23 @@ let plain_instance sigma s c =
let l' = Array.Fun1.Smart.map irec n l in
(match EConstr.kind sigma f with
| Meta p ->
- (* Don't flatten application nodes: this is used to extract a
+ (* Don't flatten application nodes: this is used to extract a
proof-term from a proof-tree and we want to keep the structure
of the proof-tree *)
- (try let g = Metamap.find p s in
- match EConstr.kind sigma g with
+ (try let g = Metamap.find p s in
+ match EConstr.kind sigma g with
| App _ ->
let l' = Array.Fun1.Smart.map lift 1 l' in
let r = Sorts.Relevant in (* TODO fix relevance *)
let na = make_annot (Name default_plain_instance_ident) r in
mkLetIn (na,g,t,mkApp(mkRel 1, l'))
| _ -> mkApp (g,l')
- with Not_found -> mkApp (f,l'))
+ with Not_found -> mkApp (f,l'))
| _ -> mkApp (irec n f,l'))
| Cast (m,_,_) when isMeta sigma m ->
- (try lift n (Metamap.find (destMeta sigma m) s) with Not_found -> u)
+ (try lift n (Metamap.find (destMeta sigma m) s) with Not_found -> u)
| _ ->
- map_with_binders sigma succ irec n u
+ map_with_binders sigma succ irec n u
in
if Metamap.is_empty s then c
else irec 0 c
@@ -1701,10 +1701,10 @@ let splay_prod_assum env sigma =
prodec_rec (push_rel (LocalDef (x,b,t)) env)
(Context.Rel.add (LocalDef (x,b,t)) l) c
| Cast (c,_,_) -> prodec_rec env l c
- | _ ->
+ | _ ->
let t' = whd_all env sigma t in
- if EConstr.eq_constr sigma t t' then l,t
- else prodec_rec env l t'
+ if EConstr.eq_constr sigma t t' then l,t
+ else prodec_rec env l t'
in
prodec_rec env Context.Rel.empty
@@ -1751,19 +1751,19 @@ let whd_betaiota_deltazeta_for_iota_state ts env sigma s =
let (t, stack as s),csts' = whd_state_gen ~csts ~refold ~tactic_mode CClosure.betaiota env sigma s in
match Stack.strip_app stack with
|args, (Stack.Case _ :: _ as stack') ->
- let (t_o,stack_o),csts_o = whd_state_gen ~csts:csts' ~refold ~tactic_mode
- (CClosure.RedFlags.red_add_transparent CClosure.all ts) env sigma (t,args) in
- if reducible_mind_case sigma t_o then whrec csts_o (t_o, stack_o@stack') else s,csts'
+ let (t_o,stack_o),csts_o = whd_state_gen ~csts:csts' ~refold ~tactic_mode
+ (CClosure.RedFlags.red_add_transparent CClosure.all ts) env sigma (t,args) in
+ if reducible_mind_case sigma t_o then whrec csts_o (t_o, stack_o@stack') else s,csts'
|args, (Stack.Fix _ :: _ as stack') ->
- let (t_o,stack_o),csts_o = whd_state_gen ~csts:csts' ~refold ~tactic_mode
- (CClosure.RedFlags.red_add_transparent CClosure.all ts) env sigma (t,args) in
- if isConstruct sigma t_o then whrec csts_o (t_o, stack_o@stack') else s,csts'
+ let (t_o,stack_o),csts_o = whd_state_gen ~csts:csts' ~refold ~tactic_mode
+ (CClosure.RedFlags.red_add_transparent CClosure.all ts) env sigma (t,args) in
+ if isConstruct sigma t_o then whrec csts_o (t_o, stack_o@stack') else s,csts'
|args, (Stack.Proj (p,_) :: stack'') ->
- let (t_o,stack_o),csts_o = whd_state_gen ~csts:csts' ~refold ~tactic_mode
- (CClosure.RedFlags.red_add_transparent CClosure.all ts) env sigma (t,args) in
- if isConstruct sigma t_o then
+ let (t_o,stack_o),csts_o = whd_state_gen ~csts:csts' ~refold ~tactic_mode
+ (CClosure.RedFlags.red_add_transparent CClosure.all ts) env sigma (t,args) in
+ if isConstruct sigma t_o then
whrec Cst_stack.empty (Stack.nth stack_o (Projection.npars p + Projection.arg p), stack'')
- else s,csts'
+ else s,csts'
|_, ((Stack.App _|Stack.Cst _|Stack.Primitive _) :: _|[]) -> s,csts'
in
fst (whrec Cst_stack.empty s)
@@ -1822,43 +1822,43 @@ let meta_reducible_instance evd b =
let u = whd_betaiota Evd.empty u (* FIXME *) in
match EConstr.kind evd u with
| Case (ci,p,c,bl) when EConstr.isMeta evd (strip_outer_cast evd c) ->
- let m = destMeta evd (strip_outer_cast evd c) in
- (match
- try
- let g, s = Metamap.find m metas in
+ let m = destMeta evd (strip_outer_cast evd c) in
+ (match
+ try
+ let g, s = Metamap.find m metas in
let is_coerce = match s with CoerceToType -> true | _ -> false in
- if isConstruct evd g || not is_coerce then Some g else None
- with Not_found -> None
- with
- | Some g -> irec (mkCase (ci,p,g,bl))
- | None -> mkCase (ci,irec p,c,Array.map irec bl))
+ if isConstruct evd g || not is_coerce then Some g else None
+ with Not_found -> None
+ with
+ | Some g -> irec (mkCase (ci,p,g,bl))
+ | None -> mkCase (ci,irec p,c,Array.map irec bl))
| App (f,l) when EConstr.isMeta evd (strip_outer_cast evd f) ->
- let m = destMeta evd (strip_outer_cast evd f) in
- (match
- try
- let g, s = Metamap.find m metas in
+ let m = destMeta evd (strip_outer_cast evd f) in
+ (match
+ try
+ let g, s = Metamap.find m metas in
let is_coerce = match s with CoerceToType -> true | _ -> false in
- if isLambda evd g || not is_coerce then Some g else None
- with Not_found -> None
- with
- | Some g -> irec (mkApp (g,l))
- | None -> mkApp (f,Array.map irec l))
+ if isLambda evd g || not is_coerce then Some g else None
+ with Not_found -> None
+ with
+ | Some g -> irec (mkApp (g,l))
+ | None -> mkApp (f,Array.map irec l))
| Meta m ->
- (try let g, s = Metamap.find m metas in
+ (try let g, s = Metamap.find m metas in
let is_coerce = match s with CoerceToType -> true | _ -> false in
if not is_coerce then irec g else u
- with Not_found -> u)
+ with Not_found -> u)
| Proj (p,c) when isMeta evd c || isCast evd c && isMeta evd (pi1 (destCast evd c)) (* What if two nested casts? *) ->
let m = try destMeta evd c with _ -> destMeta evd (pi1 (destCast evd c)) (* idem *) in
- (match
- try
- let g, s = Metamap.find m metas in
+ (match
+ try
+ let g, s = Metamap.find m metas in
let is_coerce = match s with CoerceToType -> true | _ -> false in
- if isConstruct evd g || not is_coerce then Some g else None
- with Not_found -> None
- with
- | Some g -> irec (mkProj (p,g))
- | None -> mkProj (p,c))
+ if isConstruct evd g || not is_coerce then Some g else None
+ with Not_found -> None
+ with
+ | Some g -> irec (mkProj (p,g))
+ | None -> mkProj (p,c))
| _ -> EConstr.map evd irec u
in
if Metaset.is_empty fm then (* nf_betaiota? *) b.rebus
diff --git a/pretyping/retyping.ml b/pretyping/retyping.ml
index 966c8f6e12..f089b242a2 100644
--- a/pretyping/retyping.ml
+++ b/pretyping/retyping.ml
@@ -104,7 +104,7 @@ let retype ?(polyprop=true) sigma =
(try strip_outer_cast sigma (Evd.meta_ftype sigma n).Evd.rebus
with Not_found -> retype_error (BadMeta n))
| Rel n ->
- let ty = RelDecl.get_type (lookup_rel n env) in
+ let ty = RelDecl.get_type (lookup_rel n env) in
lift n ty
| Var id -> type_of_var env id
| Const (cst, u) -> EConstr.of_constr (rename_type_of_constant env (cst, EInstance.kind sigma u))
@@ -133,7 +133,7 @@ let retype ?(polyprop=true) sigma =
| Fix ((_,i),(_,tys,_)) -> tys.(i)
| CoFix (i,(_,tys,_)) -> tys.(i)
| App(f,args) when Termops.is_template_polymorphic_ind env sigma f ->
- let t = type_of_global_reference_knowing_parameters env f args in
+ let t = type_of_global_reference_knowing_parameters env f args in
strip_outer_cast sigma (subst_type env sigma t (Array.to_list args))
| App(f,args) ->
strip_outer_cast sigma
@@ -141,8 +141,8 @@ let retype ?(polyprop=true) sigma =
| Proj (p,c) ->
let ty = type_of env c in
EConstr.of_constr (try
- Inductiveops.type_of_projection_knowing_arg env sigma p c ty
- with Invalid_argument _ -> retype_error BadRecursiveType)
+ Inductiveops.type_of_projection_knowing_arg env sigma p c ty
+ with Invalid_argument _ -> retype_error BadRecursiveType)
| Cast (c,_, t) -> t
| Sort _ | Prod _ -> mkSort (sort_of env cstr)
| Int _ -> EConstr.of_constr (Typeops.type_of_int env)
@@ -174,9 +174,9 @@ let retype ?(polyprop=true) sigma =
| Ind (ind, u) ->
let u = EInstance.kind sigma u in
let mip = lookup_mind_specif env ind in
- EConstr.of_constr (try Inductive.type_of_inductive_knowing_parameters
- ~polyprop env (mip, u) argtyps
- with Reduction.NotArity -> retype_error NotAnArity)
+ EConstr.of_constr (try Inductive.type_of_inductive_knowing_parameters
+ ~polyprop env (mip, u) argtyps
+ with Reduction.NotArity -> retype_error NotAnArity)
| Construct (cstr, u) ->
let u = EInstance.kind sigma u in
EConstr.of_constr (type_of_constructor env (cstr, u))
@@ -192,17 +192,17 @@ let get_sort_family_of ?(truncation_style=false) ?(polyprop=true) env sigma t =
| Sort _ -> InType
| Prod (name,t,c2) ->
let s2 = sort_family_of (push_rel (LocalAssum (name,t)) env) c2 in
- if not (is_impredicative_set env) &&
- s2 == InSet && sort_family_of env t == InType then InType else s2
+ if not (is_impredicative_set env) &&
+ s2 == InSet && sort_family_of env t == InType then InType else s2
| App(f,args) when Termops.is_template_polymorphic_ind env sigma f ->
if truncation_style then InType else
- let t = type_of_global_reference_knowing_parameters env f args in
+ let t = type_of_global_reference_knowing_parameters env f args in
Sorts.family (sort_of_atomic_type env sigma t args)
| App(f,args) ->
- Sorts.family (sort_of_atomic_type env sigma (type_of env f) args)
+ Sorts.family (sort_of_atomic_type env sigma (type_of env f) args)
| Lambda _ | Fix _ | Construct _ -> retype_error NotAType
| Ind _ when truncation_style && Termops.is_template_polymorphic_ind env sigma t -> InType
- | _ ->
+ | _ ->
Sorts.family (decomp_sort env sigma (type_of env t))
in sort_family_of env t
@@ -253,12 +253,12 @@ let sorts_of_context env evc ctxt =
let expand_projection env sigma pr c args =
let ty = get_type_of ~lax:true env sigma c in
- let (i,u), ind_args =
- try Inductiveops.find_mrectype env sigma ty
+ let (i,u), ind_args =
+ try Inductiveops.find_mrectype env sigma ty
with Not_found -> retype_error BadRecursiveType
in
- mkApp (mkConstU (Projection.constant pr,u),
- Array.of_list (ind_args @ (c :: args)))
+ mkApp (mkConstU (Projection.constant pr,u),
+ Array.of_list (ind_args @ (c :: args)))
let relevance_of_term env sigma c =
if Environ.sprop_allowed env then
diff --git a/pretyping/tacred.ml b/pretyping/tacred.ml
index e8a2189611..10e8cf7e0f 100644
--- a/pretyping/tacred.ml
+++ b/pretyping/tacred.ml
@@ -61,7 +61,7 @@ let is_evaluable env = function
let value_of_evaluable_ref env evref u =
match evref with
- | EvalConstRef con ->
+ | EvalConstRef con ->
let u = Unsafe.to_instance u in
EConstr.of_constr (constant_value_in env (con, u))
| EvalVarRef id -> env |> lookup_named id |> NamedDecl.get_value |> Option.get
@@ -112,7 +112,7 @@ let destEvalRefU sigma c = match EConstr.kind sigma c with
let unsafe_reference_opt_value env sigma eval =
match eval with
| EvalConst cst ->
- (match (lookup_constant cst env).Declarations.const_body with
+ (match (lookup_constant cst env).Declarations.const_body with
| Declarations.Def c -> Some (EConstr.of_constr (Mod_subst.force_constr c))
| _ -> None)
| EvalVar id ->
@@ -124,7 +124,7 @@ let unsafe_reference_opt_value env sigma eval =
| Evar _ -> None
| c -> Some (EConstr.of_kind c)
-let reference_opt_value env sigma eval u =
+let reference_opt_value env sigma eval u =
match eval with
| EvalConst cst ->
let u = EInstance.kind sigma u in
@@ -197,15 +197,15 @@ let check_fix_reversibility sigma labs args ((lv,i),(_,tys,bds)) =
(function d -> match EConstr.kind sigma d with
| Rel k ->
if
- Array.for_all (Vars.noccurn sigma k) tys
- && Array.for_all (Vars.noccurn sigma (k+nbfix)) bds
- && k <= n
- then
- (k, List.nth labs (k-1))
- else
- raise Elimconst
+ Array.for_all (Vars.noccurn sigma k) tys
+ && Array.for_all (Vars.noccurn sigma (k+nbfix)) bds
+ && k <= n
+ then
+ (k, List.nth labs (k-1))
+ else
+ raise Elimconst
| _ ->
- raise Elimconst) args
+ raise Elimconst) args
in
let reversible_rels = List.map fst li in
if not (List.distinct_f Int.compare reversible_rels) then
@@ -238,28 +238,28 @@ let invert_name labs l {binder_name=na0} env sigma ref na =
| Name id' when Id.equal id' id ->
Some (minfxargs,ref)
| _ ->
- let refi = match ref with
- | EvalRel _ | EvalEvar _ -> None
- | EvalVar id' -> Some (EvalVar id)
+ let refi = match ref with
+ | EvalRel _ | EvalEvar _ -> None
+ | EvalVar id' -> Some (EvalVar id)
| EvalConst kn ->
let kn = Constant.change_label kn (Label.of_id id) in
if Environ.mem_constant kn env then Some (EvalConst kn) else None
in
- match refi with
- | None -> None
- | Some ref ->
- try match unsafe_reference_opt_value env sigma ref with
- | None -> None
- | Some c ->
- let labs',ccl = decompose_lam sigma c in
- let _, l' = whd_betalet_stack sigma ccl in
+ match refi with
+ | None -> None
+ | Some ref ->
+ try match unsafe_reference_opt_value env sigma ref with
+ | None -> None
+ | Some c ->
+ let labs',ccl = decompose_lam sigma c in
+ let _, l' = whd_betalet_stack sigma ccl in
let labs' = List.map snd labs' in
(* ppedrot: there used to be generic equality on terms here *)
let eq_constr c1 c2 = EConstr.eq_constr sigma c1 c2 in
- if List.equal eq_constr labs' labs &&
+ if List.equal eq_constr labs' labs &&
List.equal eq_constr l l' then Some (minfxargs,ref)
else None
- with Not_found (* Undefined ref *) -> None
+ with Not_found (* Undefined ref *) -> None
end
| Anonymous -> None (* Actually, should not occur *)
@@ -275,8 +275,8 @@ let compute_consteval_direct env sigma ref =
let open Context.Rel.Declaration in
srec (push_rel (LocalAssum (id,t)) env) (n+1) (t::labs) onlyproj g
| Fix fix when not onlyproj ->
- (try check_fix_reversibility sigma labs l fix
- with Elimconst -> NotAnElimination)
+ (try check_fix_reversibility sigma labs l fix
+ with Elimconst -> NotAnElimination)
| Case (_,_,d,_) when isRel sigma d && not onlyproj -> EliminationCases n
| Case (_,_,d,_) -> srec env n labs true d
| Proj (p, d) when isRel sigma d -> EliminationProj n
@@ -295,23 +295,23 @@ let compute_consteval_mutual_fix env sigma ref =
let open Context.Rel.Declaration in
srec (push_rel (LocalAssum (na,t)) env) (minarg+1) (t::labs) ref g
| Fix ((lv,i),(names,_,_)) ->
- (* Last known constant wrapping Fix is ref = [labs](Fix l) *)
- (match compute_consteval_direct env sigma ref with
- | NotAnElimination -> (*Above const was eliminable but this not!*)
- NotAnElimination
- | EliminationFix (minarg',minfxargs,infos) ->
- let refs =
- Array.map
- (invert_name labs l names.(i) env sigma ref) names in
- let new_minarg = max (minarg'+minarg-nargs) minarg' in
- EliminationMutualFix (new_minarg,ref,(refs,infos))
- | _ -> assert false)
+ (* Last known constant wrapping Fix is ref = [labs](Fix l) *)
+ (match compute_consteval_direct env sigma ref with
+ | NotAnElimination -> (*Above const was eliminable but this not!*)
+ NotAnElimination
+ | EliminationFix (minarg',minfxargs,infos) ->
+ let refs =
+ Array.map
+ (invert_name labs l names.(i) env sigma ref) names in
+ let new_minarg = max (minarg'+minarg-nargs) minarg' in
+ EliminationMutualFix (new_minarg,ref,(refs,infos))
+ | _ -> assert false)
| _ when isEvalRef env sigma c' ->
- (* Forget all \'s and args and do as if we had started with c' *)
- let ref,_ = destEvalRefU sigma c' in
- (match unsafe_reference_opt_value env sigma ref with
- | None -> anomaly (Pp.str "Should have been trapped by compute_direct.")
- | Some c -> srec env (minarg-nargs) [] ref c)
+ (* Forget all \'s and args and do as if we had started with c' *)
+ let ref,_ = destEvalRefU sigma c' in
+ (match unsafe_reference_opt_value env sigma ref with
+ | None -> anomaly (Pp.str "Should have been trapped by compute_direct.")
+ | Some c -> srec env (minarg-nargs) [] ref c)
| _ -> (* Should not occur *) NotAnElimination
in
match unsafe_reference_opt_value env sigma ref with
@@ -321,17 +321,17 @@ let compute_consteval_mutual_fix env sigma ref =
let compute_consteval env sigma ref =
match compute_consteval_direct env sigma ref with
| EliminationFix (_,_,(nbfix,_,_)) when not (Int.equal nbfix 1) ->
- compute_consteval_mutual_fix env sigma ref
+ compute_consteval_mutual_fix env sigma ref
| elim -> elim
let reference_eval env sigma = function
| EvalConst cst as ref ->
(try
- Cmap.find cst !eval_table
+ Cmap.find cst !eval_table
with Not_found -> begin
- let v = compute_consteval env sigma ref in
- eval_table := Cmap.add cst v !eval_table;
- v
+ let v = compute_consteval env sigma ref in
+ eval_table := Cmap.add cst v !eval_table;
+ v
end)
| ref -> compute_consteval env sigma ref
@@ -435,7 +435,7 @@ let solve_arity_problem env sigma fxminargs c =
Array.iter (check strict) rcargs
| (Var _|Const _) when isEvalRef env sigma h ->
(let ev, u = destEvalRefU sigma h in
- match reference_opt_value env sigma ev u with
+ match reference_opt_value env sigma ev u with
| Some h' ->
let bak = !evm in
(try Array.iter (check false) rcargs
@@ -473,9 +473,9 @@ let reduce_fix whdfun sigma fix stack =
| Some (recargnum,recarg) ->
let (recarg'hd,_ as recarg') = whdfun sigma recarg in
let stack' = List.assign stack recargnum (applist recarg') in
- (match EConstr.kind sigma recarg'hd with
+ (match EConstr.kind sigma recarg'hd with
| Construct _ -> Reduced (contract_fix sigma fix, stack')
- | _ -> NotReducible)
+ | _ -> NotReducible)
let contract_fix_use_function env sigma f
((recindices,bodynum),(_names,_types,bodies as typedbodies)) =
@@ -489,16 +489,16 @@ let reduce_fix_use_function env sigma f whfun fix stack =
| None -> NotReducible
| Some (recargnum,recarg) ->
let (recarg'hd,_ as recarg') =
- if EConstr.isRel sigma recarg then
- (* The recarg cannot be a local def, no worry about the right env *)
- (recarg, [])
- else
- whfun recarg in
+ if EConstr.isRel sigma recarg then
+ (* The recarg cannot be a local def, no worry about the right env *)
+ (recarg, [])
+ else
+ whfun recarg in
let stack' = List.assign stack recargnum (applist recarg') in
- (match EConstr.kind sigma recarg'hd with
+ (match EConstr.kind sigma recarg'hd with
| Construct _ ->
- Reduced (contract_fix_use_function env sigma f fix,stack')
- | _ -> NotReducible)
+ Reduced (contract_fix_use_function env sigma f fix,stack')
+ | _ -> NotReducible)
let contract_cofix_use_function env sigma f
(bodynum,(_names,_,bodies as typedbodies)) =
@@ -511,34 +511,34 @@ let contract_cofix_use_function env sigma f
let reduce_mind_case_use_function func env sigma mia =
match EConstr.kind sigma mia.mconstr with
| Construct ((ind_sp,i),u) ->
- let real_cargs = List.skipn mia.mci.ci_npar mia.mcargs in
- applist (mia.mlf.(i-1), real_cargs)
+ let real_cargs = List.skipn mia.mci.ci_npar mia.mcargs in
+ applist (mia.mlf.(i-1), real_cargs)
| CoFix (bodynum,(names,_,_) as cofix) ->
- let build_cofix_name =
- if isConst sigma func then
+ let build_cofix_name =
+ if isConst sigma func then
let minargs = List.length mia.mcargs in
- fun i ->
- if Int.equal i bodynum then Some (minargs,func)
+ fun i ->
+ if Int.equal i bodynum then Some (minargs,func)
else match names.(i).binder_name with
- | Anonymous -> None
- | Name id ->
- (* In case of a call to another component of a block of
- mutual inductive, try to reuse the global name if
- the block was indeed initially built as a global
- definition *)
+ | Anonymous -> None
+ | Name id ->
+ (* In case of a call to another component of a block of
+ mutual inductive, try to reuse the global name if
+ the block was indeed initially built as a global
+ definition *)
let (kn, u) = destConst sigma func in
let kn = Constant.change_label kn (Label.of_id id) in
let cst = (kn, EInstance.kind sigma u) in
- try match constant_opt_value_in env cst with
- | None -> None
+ try match constant_opt_value_in env cst with
+ | None -> None
(* TODO: check kn is correct *)
- | Some _ -> Some (minargs,mkConstU (kn, u))
- with Not_found -> None
- else
- fun _ -> None in
- let cofix_def =
+ | Some _ -> Some (minargs,mkConstU (kn, u))
+ with Not_found -> None
+ else
+ fun _ -> None in
+ let cofix_def =
contract_cofix_use_function env sigma build_cofix_name cofix in
- mkCase (mia.mci, mia.mP, applist(cofix_def,mia.mcargs), mia.mlf)
+ mkCase (mia.mci, mia.mP, applist(cofix_def,mia.mcargs), mia.mlf)
| _ -> assert false
@@ -567,7 +567,7 @@ let match_eval_ref_value env sigma constr stack =
if is_evaluable env (EvalConstRef (Projection.constant p)) then
Some (mkProj (Projection.unfold p, c))
else None
- | Var id when is_evaluable env (EvalVarRef id) ->
+ | Var id when is_evaluable env (EvalVarRef id) ->
env |> lookup_named id |> NamedDecl.get_value
| Rel n ->
env |> lookup_rel n |> RelDecl.get_value |> Option.map (lift n)
@@ -582,18 +582,18 @@ let special_red_case env sigma whfun (ci, p, c, lf) =
| None -> raise Redelimination
| Some gvalue ->
if reducible_mind_case sigma gvalue then
- reduce_mind_case_use_function constr env sigma
- {mP=p; mconstr=gvalue; mcargs=cargs;
+ reduce_mind_case_use_function constr env sigma
+ {mP=p; mconstr=gvalue; mcargs=cargs;
mci=ci; mlf=lf}
- else
- redrec (applist(gvalue, cargs)))
+ else
+ redrec (applist(gvalue, cargs)))
| None ->
if reducible_mind_case sigma constr then
reduce_mind_case sigma
- {mP=p; mconstr=constr; mcargs=cargs;
- mci=ci; mlf=lf}
+ {mP=p; mconstr=constr; mcargs=cargs;
+ mci=ci; mlf=lf}
else
- raise Redelimination
+ raise Redelimination
in
redrec c
@@ -603,7 +603,7 @@ let recargs = function
let reduce_projection env sigma p ~npars (recarg'hd,stack') stack =
(match EConstr.kind sigma recarg'hd with
- | Construct _ ->
+ | Construct _ ->
let proj_narg = npars + Projection.arg p in
Reduced (List.nth stack' proj_narg, stack)
| _ -> NotReducible)
@@ -611,19 +611,19 @@ let reduce_projection env sigma p ~npars (recarg'hd,stack') stack =
let reduce_proj env sigma whfun whfun' c =
let rec redrec s =
match EConstr.kind sigma s with
- | Proj (proj, c) ->
+ | Proj (proj, c) ->
let c' = try redrec c with Redelimination -> c in
let constr, cargs = whfun c' in
- (match EConstr.kind sigma constr with
- | Construct _ ->
+ (match EConstr.kind sigma constr with
+ | Construct _ ->
let proj_narg = Projection.npars proj + Projection.arg proj in
List.nth cargs proj_narg
- | _ -> raise Redelimination)
- | Case (n,p,c,brs) ->
+ | _ -> raise Redelimination)
+ | Case (n,p,c,brs) ->
let c' = redrec c in
let p = (n,p,c',brs) in
- (try special_red_case env sigma whfun' p
- with Redelimination -> mkCase p)
+ (try special_red_case env sigma whfun' p
+ with Redelimination -> mkCase p)
| _ -> raise Redelimination
in redrec c
@@ -632,30 +632,30 @@ let whd_nothing_for_iota env sigma s =
match EConstr.kind sigma x with
| Rel n ->
let open Context.Rel.Declaration in
- (match lookup_rel n env with
+ (match lookup_rel n env with
| LocalDef (_,body,_) -> whrec (lift n body, stack)
- | _ -> s)
+ | _ -> s)
| Var id ->
let open Context.Named.Declaration in
- (match lookup_named id env with
+ (match lookup_named id env with
| LocalDef (_,body,_) -> whrec (body, stack)
- | _ -> s)
+ | _ -> s)
| Evar ev -> s
| Meta ev ->
(try whrec (Evd.meta_value sigma ev, stack)
- with Not_found -> s)
+ with Not_found -> s)
| Const (const, u) ->
let u = EInstance.kind sigma u in
- (match constant_opt_value_in env (const, u) with
- | Some body -> whrec (EConstr.of_constr body, stack)
- | None -> s)
+ (match constant_opt_value_in env (const, u) with
+ | Some body -> whrec (EConstr.of_constr body, stack)
+ | None -> s)
| LetIn (_,b,_,c) -> stacklam whrec [b] sigma c stack
| Cast (c,_,_) -> whrec (c, stack)
| App (f,cl) -> whrec (f, Stack.append_app cl stack)
| Lambda (na,t,c) ->
(match Stack.decomp stack with
| Some (a,m) -> stacklam whrec [a] sigma c m
- | _ -> s)
+ | _ -> s)
| x -> s
in
@@ -701,38 +701,38 @@ let rec red_elim_const env sigma ref u largs =
in
try match reference_eval env sigma ref with
| EliminationCases n when nargs >= n ->
- let c = reference_value env sigma ref u in
- let c', lrest = whd_nothing_for_iota env sigma (applist(c,largs)) in
- let whfun = whd_simpl_stack env sigma in
+ let c = reference_value env sigma ref u in
+ let c', lrest = whd_nothing_for_iota env sigma (applist(c,largs)) in
+ let whfun = whd_simpl_stack env sigma in
(special_red_case env sigma whfun (EConstr.destCase sigma c'), lrest), nocase
| EliminationProj n when nargs >= n ->
- let c = reference_value env sigma ref u in
- let c', lrest = whd_nothing_for_iota env sigma (applist(c,largs)) in
- let whfun = whd_construct_stack env sigma in
- let whfun' = whd_simpl_stack env sigma in
- (reduce_proj env sigma whfun whfun' c', lrest), nocase
+ let c = reference_value env sigma ref u in
+ let c', lrest = whd_nothing_for_iota env sigma (applist(c,largs)) in
+ let whfun = whd_construct_stack env sigma in
+ let whfun' = whd_simpl_stack env sigma in
+ (reduce_proj env sigma whfun whfun' c', lrest), nocase
| EliminationFix (min,minfxargs,infos) when nargs >= min ->
- let c = reference_value env sigma ref u in
- let d, lrest = whd_nothing_for_iota env sigma (applist(c,largs)) in
- let f = make_elim_fun ([|Some (minfxargs,ref)|],infos) u largs in
- let whfun = whd_construct_stack env sigma in
- (match reduce_fix_use_function env sigma f whfun (destFix sigma d) lrest with
- | NotReducible -> raise Redelimination
+ let c = reference_value env sigma ref u in
+ let d, lrest = whd_nothing_for_iota env sigma (applist(c,largs)) in
+ let f = make_elim_fun ([|Some (minfxargs,ref)|],infos) u largs in
+ let whfun = whd_construct_stack env sigma in
+ (match reduce_fix_use_function env sigma f whfun (destFix sigma d) lrest with
+ | NotReducible -> raise Redelimination
| Reduced (c,rest) -> (nf_beta env sigma c, rest), nocase)
| EliminationMutualFix (min,refgoal,refinfos) when nargs >= min ->
- let rec descend (ref,u) args =
- let c = reference_value env sigma ref u in
- if evaluable_reference_eq sigma ref refgoal then
- (c,args)
- else
- let c', lrest = whd_betalet_stack sigma (applist(c,args)) in
- descend (destEvalRefU sigma c') lrest in
- let (_, midargs as s) = descend (ref,u) largs in
- let d, lrest = whd_nothing_for_iota env sigma (applist s) in
- let f = make_elim_fun refinfos u midargs in
- let whfun = whd_construct_stack env sigma in
- (match reduce_fix_use_function env sigma f whfun (destFix sigma d) lrest with
- | NotReducible -> raise Redelimination
+ let rec descend (ref,u) args =
+ let c = reference_value env sigma ref u in
+ if evaluable_reference_eq sigma ref refgoal then
+ (c,args)
+ else
+ let c', lrest = whd_betalet_stack sigma (applist(c,args)) in
+ descend (destEvalRefU sigma c') lrest in
+ let (_, midargs as s) = descend (ref,u) largs in
+ let d, lrest = whd_nothing_for_iota env sigma (applist s) in
+ let f = make_elim_fun refinfos u midargs in
+ let whfun = whd_construct_stack env sigma in
+ (match reduce_fix_use_function env sigma f whfun (destFix sigma d) lrest with
+ | NotReducible -> raise Redelimination
| Reduced (c,rest) -> (nf_beta env sigma c, rest), nocase)
| NotAnElimination when unfold_nonelim ->
let c = reference_value env sigma ref u in
@@ -740,20 +740,20 @@ let rec red_elim_const env sigma ref u largs =
| _ -> raise Redelimination
with Redelimination when unfold_anyway ->
let c = reference_value env sigma ref u in
- (whd_betaiotazeta sigma (applist (c, largs)), []), nocase
+ (whd_betaiotazeta sigma (applist (c, largs)), []), nocase
and reduce_params env sigma stack l =
let len = List.length stack in
List.fold_left (fun stack i ->
if len <= i then raise Redelimination
else
- let arg = List.nth stack i in
- let rarg = whd_construct_stack env sigma arg in
- match EConstr.kind sigma (fst rarg) with
- | Construct _ -> List.assign stack i (applist rarg)
- | _ -> raise Redelimination)
+ let arg = List.nth stack i in
+ let rarg = whd_construct_stack env sigma arg in
+ match EConstr.kind sigma (fst rarg) with
+ | Construct _ -> List.assign stack i (applist rarg)
+ | _ -> raise Redelimination)
stack l
-
+
(* reduce to whd normal form or to an applied constant that does not hide
a reducible iota/fix/cofix redex (the "simpl" tactic) *)
@@ -774,14 +774,14 @@ and whd_simpl_stack env sigma =
| Cast (c,_,_) -> redrec (applist(c, stack))
| Case (ci,p,c,lf) ->
(try
- redrec (applist(special_red_case env sigma redrec (ci,p,c,lf), stack))
- with
- Redelimination -> s')
+ redrec (applist(special_red_case env sigma redrec (ci,p,c,lf), stack))
+ with
+ Redelimination -> s')
| Fix fix ->
- (try match reduce_fix (whd_construct_stack env) sigma fix stack with
+ (try match reduce_fix (whd_construct_stack env) sigma fix stack with
| Reduced s' -> redrec (applist s')
- | NotReducible -> s'
- with Redelimination -> s')
+ | NotReducible -> s'
+ with Redelimination -> s')
| Proj (p, c) ->
(try
@@ -808,11 +808,11 @@ and whd_simpl_stack env sigma =
else s'
with Redelimination -> s')
- | _ ->
+ | _ ->
match match_eval_ref env sigma x stack with
- | Some (ref, u) ->
+ | Some (ref, u) ->
(try
- let sapp, nocase = red_elim_const env sigma ref u stack in
+ let sapp, nocase = red_elim_const env sigma ref u stack in
let hd, _ as s'' = redrec (applist(sapp)) in
let rec is_case x = match EConstr.kind sigma x with
| Lambda (_,_, x) | LetIn (_,_,_, x) | Cast (x, _,_) -> is_case x
@@ -822,7 +822,7 @@ and whd_simpl_stack env sigma =
if nocase && is_case hd then raise Redelimination
else s''
with Redelimination -> s')
- | None -> s'
+ | None -> s'
in
redrec
@@ -869,24 +869,24 @@ let try_red_product env sigma c =
| LetIn (x,a,b,t) -> redrec env (Vars.subst1 a t)
| Case (ci,p,d,lf) -> simpfun (mkCase (ci,p,redrec env d,lf))
| Proj (p, c) ->
- let c' =
- match EConstr.kind sigma c with
- | Construct _ -> c
- | _ -> redrec env c
- in
+ let c' =
+ match EConstr.kind sigma c with
+ | Construct _ -> c
+ | _ -> redrec env c
+ in
let npars = Projection.npars p in
(match reduce_projection env sigma p ~npars (whd_betaiotazeta_stack sigma c') [] with
- | Reduced s -> simpfun (applist s)
- | NotReducible -> raise Redelimination)
- | _ ->
+ | Reduced s -> simpfun (applist s)
+ | NotReducible -> raise Redelimination)
+ | _ ->
(match match_eval_ref env sigma x [] with
| Some (ref, u) ->
(* TO DO: re-fold fixpoints after expansion *)
(* to get true one-step reductions *)
- (match reference_opt_value env sigma ref u with
- | None -> raise Redelimination
- | Some c -> c)
- | _ -> raise Redelimination)
+ (match reference_opt_value env sigma ref u with
+ | None -> raise Redelimination
+ | Some c -> c)
+ | _ -> raise Redelimination)
in redrec env c
let red_product env sigma c =
@@ -927,28 +927,28 @@ let whd_simpl_orelse_delta_but_fix_old env sigma c =
(try
redrec (special_red_case env sigma whd_all (ci,p,d,lf), stack)
with Redelimination ->
- s)
+ s)
| Fix fix ->
- (match reduce_fix whd_all fix stack with
+ (match reduce_fix whd_all fix stack with
| Reduced s' -> redrec s'
- | NotReducible -> s)
+ | NotReducible -> s)
| _ when isEvalRef env x ->
- let ref = destEvalRef x in
+ let ref = destEvalRef x in
(try
- redrec (red_elim_const env sigma ref stack)
+ redrec (red_elim_const env sigma ref stack)
with Redelimination ->
match reference_opt_value env sigma ref with
- | Some c ->
- (match kind_of_term (strip_lam c) with
+ | Some c ->
+ (match kind_of_term (strip_lam c) with
| CoFix _ | Fix _ -> s
- | _ -> redrec (c, stack))
- | None -> s)
+ | _ -> redrec (c, stack))
+ | None -> s)
| _ -> s
in app_stack (redrec (c, empty_stack))
*)
-let whd_simpl_stack =
- if Flags.profile then
+let whd_simpl_stack =
+ if Flags.profile then
let key = CProfile.declare_profile "whd_simpl_stack" in
CProfile.profile3 key whd_simpl_stack
else whd_simpl_stack
@@ -965,14 +965,14 @@ let whd_simpl_orelse_delta_but_fix env sigma c =
(match EConstr.kind sigma (snd (decompose_lam sigma c)) with
| CoFix _ | Fix _ -> s'
| Proj (p,t) when
- (match EConstr.kind sigma constr with
- | Const (c', _) -> Constant.equal (Projection.constant p) c'
- | _ -> false) ->
+ (match EConstr.kind sigma constr with
+ | Const (c', _) -> Constant.equal (Projection.constant p) c'
+ | _ -> false) ->
let npars = Projection.npars p in
if List.length stack <= npars then
(* Do not show the eta-expanded form *)
- s'
- else redrec (applist (c, stack))
+ s'
+ else redrec (applist (c, stack))
| _ -> redrec (applist(c, stack)))
| None -> s'
in
@@ -1000,7 +1000,7 @@ let matches_head env sigma c t =
parameters. This is a temporary fix while rewrite etc... are not up to equivalence
of the projection and its eta expanded form.
*)
-let change_map_constr_with_binders_left_to_right g f (env, l as acc) sigma c =
+let change_map_constr_with_binders_left_to_right g f (env, l as acc) sigma c =
match EConstr.kind sigma c with
| Proj (p, r) -> (* Treat specially for partial applications *)
let t = Retyping.expand_projection env sigma p r [] in
@@ -1012,7 +1012,7 @@ let change_map_constr_with_binders_left_to_right g f (env, l as acc) sigma c =
(match EConstr.kind sigma app' with
| App (hdf', al') when hdf' == hdf ->
(* Still the same projection, we ignore the change in parameters *)
- mkProj (p, a')
+ mkProj (p, a')
| _ -> mkApp (app', [| a' |]))
| _ -> map_constr_with_binders_left_to_right sigma g f acc c
@@ -1027,11 +1027,11 @@ let e_contextually byhead (occs,c) f = begin fun env sigma t ->
else
try
let subst =
- if byhead then matches_head env sigma c t
- else Constr_matching.matches env sigma c t in
+ if byhead then matches_head env sigma c t
+ else Constr_matching.matches env sigma c t in
let ok =
- if nowhere_except_in then Int.List.mem !pos locs
- else not (Int.List.mem !pos locs) in
+ if nowhere_except_in then Int.List.mem !pos locs
+ else not (Int.List.mem !pos locs) in
incr pos;
if ok then begin
if Option.has_some nested then
@@ -1039,11 +1039,11 @@ let e_contextually byhead (occs,c) f = begin fun env sigma t ->
(* Skip inner occurrences for stable counting of occurrences *)
if locs != [] then
ignore (traverse_below (Some (!pos-1)) envc t);
- let (evm, t) = (f subst) env !evd t in
- (evd := evm; t)
+ let (evm, t) = (f subst) env !evd t in
+ (evd := evm; t)
end
else
- traverse_below nested envc t
+ traverse_below nested envc t
with Constr_matching.PatternMatchingFailure ->
traverse_below nested envc t
and traverse_below nested envc t =
@@ -1070,7 +1070,7 @@ let contextually byhead occs f env sigma t =
* n is the number of the next occurrence of name.
* ol is the occurrence list to find. *)
-let match_constr_evaluable_ref sigma c evref =
+let match_constr_evaluable_ref sigma c evref =
match EConstr.kind sigma c, evref with
| Const (c,u), EvalConstRef c' when Constant.equal c c' -> Some u
| Var id, EvalVarRef id' when Id.equal id id' -> Some EInstance.empty
@@ -1083,17 +1083,17 @@ let substlin env sigma evalref n (nowhere_except_in,locs) c =
let value u = value_of_evaluable_ref env evalref u in
let rec substrec () c =
if nowhere_except_in && !pos > maxocc then c
- else
+ else
match match_constr_evaluable_ref sigma c evalref with
| Some u ->
let ok =
- if nowhere_except_in then Int.List.mem !pos locs
- else not (Int.List.mem !pos locs) in
- incr pos;
- if ok then value u else c
- | None ->
+ if nowhere_except_in then Int.List.mem !pos locs
+ else not (Int.List.mem !pos locs) in
+ incr pos;
+ if ok then value u else c
+ | None ->
map_constr_with_binders_left_to_right sigma
- (fun _ () -> ())
+ (fun _ () -> ())
substrec () c
in
let t' = substrec () c in
@@ -1215,7 +1215,7 @@ let check_not_primitive_record env ind =
let spec = Inductive.lookup_mind_specif env (fst ind) in
if Inductive.is_primitive_record spec then
user_err (str "case analysis on a primitive record type: " ++
- str "use projections or let instead.")
+ str "use projections or let instead.")
else ind
(* put t as t'=(x1:A1)..(xn:An)B with B an inductive definition of name name
@@ -1227,18 +1227,18 @@ let reduce_to_ind_gen allow_product env sigma t =
match EConstr.kind sigma (fst (decompose_app_vect sigma t)) with
| Ind ind-> (check_privacy env ind, it_mkProd_or_LetIn t l)
| Prod (n,ty,t') ->
- let open Context.Rel.Declaration in
- if allow_product then
+ let open Context.Rel.Declaration in
+ if allow_product then
elimrec (push_rel (LocalAssum (n,ty)) env) t' ((LocalAssum (n,ty))::l)
- else
- user_err (str"Not an inductive definition.")
+ else
+ user_err (str"Not an inductive definition.")
| _ ->
- (* Last chance: we allow to bypass the Opaque flag (as it
- was partially the case between V5.10 and V8.1 *)
- let t' = whd_all env sigma t in
- match EConstr.kind sigma (fst (decompose_app_vect sigma t')) with
- | Ind ind-> (check_privacy env ind, it_mkProd_or_LetIn t' l)
- | _ -> user_err (str"Not an inductive product.")
+ (* Last chance: we allow to bypass the Opaque flag (as it
+ was partially the case between V5.10 and V8.1 *)
+ let t' = whd_all env sigma t in
+ match EConstr.kind sigma (fst (decompose_app_vect sigma t')) with
+ | Ind ind-> (check_privacy env ind, it_mkProd_or_LetIn t' l)
+ | _ -> user_err (str"Not an inductive product.")
in
elimrec env t []
@@ -1266,29 +1266,29 @@ let one_step_reduce env sigma c =
| Cast (c,_,_) -> redrec (c,stack)
| Case (ci,p,c,lf) ->
(try
- (special_red_case env sigma (whd_simpl_stack env sigma)
- (ci,p,c,lf), stack)
+ (special_red_case env sigma (whd_simpl_stack env sigma)
+ (ci,p,c,lf), stack)
with Redelimination -> raise NotStepReducible)
| Fix fix ->
- (try match reduce_fix (whd_construct_stack env) sigma fix stack with
+ (try match reduce_fix (whd_construct_stack env) sigma fix stack with
| Reduced s' -> s'
- | NotReducible -> raise NotStepReducible
+ | NotReducible -> raise NotStepReducible
with Redelimination -> raise NotStepReducible)
| _ when isEvalRef env sigma x ->
- let ref,u = destEvalRefU sigma x in
+ let ref,u = destEvalRefU sigma x in
(try
fst (red_elim_const env sigma ref u stack)
with Redelimination ->
- match reference_opt_value env sigma ref u with
- | Some d -> (d, stack)
- | None -> raise NotStepReducible)
+ match reference_opt_value env sigma ref u with
+ | Some d -> (d, stack)
+ | None -> raise NotStepReducible)
| _ -> raise NotStepReducible
in
applist (redrec (c,[]))
let error_cannot_recognize ref =
- user_err
+ user_err
(str "Cannot recognize a statement based on " ++
Nametab.pr_global_env Id.Set.empty ref ++ str".")
@@ -1306,16 +1306,16 @@ let reduce_to_ref_gen allow_product env sigma ref t =
match EConstr.kind sigma c with
| Prod (n,ty,t') ->
if allow_product then
- let open Context.Rel.Declaration in
+ let open Context.Rel.Declaration in
elimrec (push_rel (LocalAssum (n,ty)) env) t' ((LocalAssum (n,ty))::l)
else
error_cannot_recognize ref
| _ ->
- try
+ try
if GlobRef.equal (fst (global_of_constr sigma c)) ref
- then it_mkProd_or_LetIn t l
- else raise Not_found
- with Not_found ->
+ then it_mkProd_or_LetIn t l
+ else raise Not_found
+ with Not_found ->
try
let t' = nf_betaiota env sigma (one_step_reduce env sigma t) in
elimrec env t' l
diff --git a/pretyping/tacred.mli b/pretyping/tacred.mli
index c05a6cde18..be4c681cc7 100644
--- a/pretyping/tacred.mli
+++ b/pretyping/tacred.mli
@@ -92,7 +92,7 @@ val reduce_to_quantified_ref :
val reduce_to_atomic_ref :
env -> evar_map -> GlobRef.t -> types -> types
-val find_hnf_rectype :
+val find_hnf_rectype :
env -> evar_map -> types -> (inductive * EInstance.t) * constr list
val contextually : bool -> occurrences * constr_pattern ->
diff --git a/pretyping/typeclasses.ml b/pretyping/typeclasses.ml
index 544fd3d17d..1541e96635 100644
--- a/pretyping/typeclasses.ml
+++ b/pretyping/typeclasses.ml
@@ -64,8 +64,8 @@ type typeclass = {
(* The method implementations as projections. *)
cl_projs : (Name.t * (direction * hint_info) option
- * Constant.t option) list;
-
+ * Constant.t option) list;
+
cl_strict : bool;
cl_unique : bool;
@@ -124,7 +124,7 @@ let class_of_constr env sigma c =
try Some (dest_class_arity env sigma c)
with e when CErrors.noncritical e -> None
-let is_class_constr sigma c =
+let is_class_constr sigma c =
try let gr, u = Termops.global_of_constr sigma c in
GlobRef.Map.mem gr !classes
with Not_found -> false
@@ -135,7 +135,7 @@ let rec is_class_type evd c =
| Prod (_, _, t) -> is_class_type evd t
| Cast (t, _, _) -> is_class_type evd t
| _ -> is_class_constr evd c
-
+
let is_class_evar evd evi =
is_class_type evd evi.Evd.evar_concl
@@ -160,7 +160,7 @@ let load_class cl =
(** Build the subinstances hints. *)
let check_instance env sigma c =
- try
+ try
let (evd, c) = resolve_one_typeclass env sigma
(Retyping.get_type_of env sigma c) in
not (Evd.has_undefined evd)
@@ -168,8 +168,8 @@ let check_instance env sigma c =
let build_subclasses ~check env sigma glob { hint_priority = pri } =
let _id = Nametab.basename_of_global glob in
- let _next_id =
- let i = ref (-1) in
+ let _next_id =
+ let i = ref (-1) in
(fun () -> incr i;
Nameops.add_suffix _id ("_subinstance_" ^ string_of_int !i))
in
@@ -182,37 +182,37 @@ let build_subclasses ~check env sigma glob { hint_priority = pri } =
match class_of_constr env sigma ty with
| None -> []
| Some (rels, ((tc,u), args)) ->
- let instapp =
- Reductionops.whd_beta sigma (EConstr.of_constr (appvectc c (Context.Rel.to_extended_vect mkRel 0 rels)))
- in
- let instapp = EConstr.Unsafe.to_constr instapp in
- let projargs = Array.of_list (args @ [instapp]) in
- let projs = List.map_filter
- (fun (n, b, proj) ->
- match b with
- | None -> None
- | Some (Backward, _) -> None
- | Some (Forward, info) ->
- let proj = Option.get proj in
- let rels = List.map (fun d -> Termops.map_rel_decl EConstr.Unsafe.to_constr d) rels in
- let u = EConstr.EInstance.kind sigma u in
- let body = it_mkLambda_or_LetIn (mkApp (mkConstU (proj,u), projargs)) rels in
- if check && check_instance env sigma (EConstr.of_constr body) then None
- else
- let newpri =
- match pri, info.hint_priority with
- | Some p, Some p' -> Some (p + p')
- | Some p, None -> Some (p + 1)
- | _, _ -> None
- in
+ let instapp =
+ Reductionops.whd_beta sigma (EConstr.of_constr (appvectc c (Context.Rel.to_extended_vect mkRel 0 rels)))
+ in
+ let instapp = EConstr.Unsafe.to_constr instapp in
+ let projargs = Array.of_list (args @ [instapp]) in
+ let projs = List.map_filter
+ (fun (n, b, proj) ->
+ match b with
+ | None -> None
+ | Some (Backward, _) -> None
+ | Some (Forward, info) ->
+ let proj = Option.get proj in
+ let rels = List.map (fun d -> Termops.map_rel_decl EConstr.Unsafe.to_constr d) rels in
+ let u = EConstr.EInstance.kind sigma u in
+ let body = it_mkLambda_or_LetIn (mkApp (mkConstU (proj,u), projargs)) rels in
+ if check && check_instance env sigma (EConstr.of_constr body) then None
+ else
+ let newpri =
+ match pri, info.hint_priority with
+ | Some p, Some p' -> Some (p + p')
+ | Some p, None -> Some (p + 1)
+ | _, _ -> None
+ in
Some (GlobRef.ConstRef proj, { info with hint_priority = newpri }, body)) tc.cl_projs
- in
- let declare_proj hints (cref, info, body) =
- let path' = cref :: path in
- let ty = Retyping.get_type_of env sigma (EConstr.of_constr body) in
- let rest = aux pri body ty path' in
- hints @ (path', info, body) :: rest
- in List.fold_left declare_proj [] projs
+ in
+ let declare_proj hints (cref, info, body) =
+ let path' = cref :: path in
+ let ty = Retyping.get_type_of env sigma (EConstr.of_constr body) in
+ let rest = aux pri body ty path' in
+ hints @ (path', info, body) :: rest
+ in List.fold_left declare_proj [] projs
in
let term = Constr.mkRef (glob, inst) in
(*FIXME subclasses should now get substituted for each particular instance of
@@ -249,10 +249,10 @@ let instance_constructor (cl,u) args =
applist (mkIndU ind, pars))
| GlobRef.ConstRef cst ->
let cst = cst, u in
- let term = match args with
- | [] -> None
- | _ -> Some (List.last args)
- in
+ let term = match args with
+ | [] -> None
+ | _ -> Some (List.last args)
+ in
(term, applist (mkConstU cst, pars))
| _ -> assert false
@@ -263,7 +263,7 @@ let cmap_elements c = GlobRef.Map.fold (fun k v acc -> v :: acc) c []
let instances_of c =
try cmap_elements (GlobRef.Map.find c.cl_impl !instances) with Not_found -> []
-let all_instances () =
+let all_instances () =
GlobRef.Map.fold (fun k v acc ->
GlobRef.Map.fold (fun k v acc -> v :: acc) v acc)
!instances []
@@ -271,7 +271,7 @@ let all_instances () =
let instances env sigma r =
let cl = class_info env sigma r in instances_of cl
-let is_class gr =
+let is_class gr =
GlobRef.Map.exists (fun _ v -> GlobRef.equal v.cl_impl gr) !classes
open Evar_kinds
diff --git a/pretyping/typeclasses.mli b/pretyping/typeclasses.mli
index 787c722938..2715c1eda5 100644
--- a/pretyping/typeclasses.mli
+++ b/pretyping/typeclasses.mli
@@ -40,16 +40,16 @@ type typeclass = {
(** Context of definitions and properties on defs, will not be shared *)
cl_projs : (Name.t * (direction * hint_info) option * Constant.t option) list;
- (** The methods implementations of the typeclass as projections.
- Some may be undefinable due to sorting restrictions or simply undefined if
+ (** The methods implementations of the typeclass as projections.
+ Some may be undefinable due to sorting restrictions or simply undefined if
no name is provided. The [int option option] indicates subclasses whose hint has
the given priority. *)
- cl_strict : bool;
+ cl_strict : bool;
(** Whether we use matching or full unification during resolution *)
cl_unique : bool;
- (** Whether we can assume that instances are unique, which allows
+ (** Whether we can assume that instances are unique, which allows
no backtracking and sharing of resolution. *)
}
@@ -132,7 +132,7 @@ val solve_all_instances_hook : (env -> evar_map -> evar_filter -> bool -> bool -
val solve_one_instance_hook : (env -> evar_map -> EConstr.types -> bool -> evar_map * EConstr.constr) Hook.t
(** Build the subinstances hints for a given typeclass object.
- check tells if we should check for existence of the
+ check tells if we should check for existence of the
subinstances and add only the missing ones. *)
val build_subclasses : check:bool -> env -> evar_map -> GlobRef.t ->
diff --git a/pretyping/typing.ml b/pretyping/typing.ml
index 1a145fe1b2..a15134f58d 100644
--- a/pretyping/typing.ml
+++ b/pretyping/typing.ml
@@ -382,7 +382,7 @@ let rec execute env sigma cstr =
| Type u -> sigma, judge_of_type u
end
- | Proj (p, c) ->
+ | Proj (p, c) ->
let sigma, cj = execute env sigma c in
sigma, judge_of_projection env sigma p cj
diff --git a/pretyping/unification.ml b/pretyping/unification.ml
index 7147580b3d..48d5fac321 100644
--- a/pretyping/unification.ml
+++ b/pretyping/unification.ml
@@ -114,10 +114,10 @@ let abstract_scheme env evd c l lname_typ =
(* [occur_meta ta] test removed for support of eelim/ecase but consequences
are unclear...
if occur_meta ta then error "cannot find a type for the generalisation"
- else *)
+ else *)
if occur_meta evd a then mkLambda_name env (na,ta,t), evd
else
- let t', evd' = Find_subterm.subst_closed_term_occ env evd locc a t in
+ let t', evd' = Find_subterm.subst_closed_term_occ env evd locc a t in
mkLambda_name env (na,ta,t'), evd')
(c,evd)
(List.rev l)
@@ -215,21 +215,21 @@ let pose_all_metas_as_evars env evd t =
let solve_pattern_eqn_array (env,nb) f l c (sigma,metasubst,evarsubst : subst0) =
match EConstr.kind sigma f with
| Meta k ->
- (* We enforce that the Meta does not depend on the [nb]
- extra assumptions added by unification to the context *)
+ (* We enforce that the Meta does not depend on the [nb]
+ extra assumptions added by unification to the context *)
let env' = pop_rel_context nb env in
- let sigma,c = pose_all_metas_as_evars env' sigma c in
- let c = solve_pattern_eqn env sigma l c in
- let pb = (Conv,TypeNotProcessed) in
- if noccur_between sigma 1 nb c then
+ let sigma,c = pose_all_metas_as_evars env' sigma c in
+ let c = solve_pattern_eqn env sigma l c in
+ let pb = (Conv,TypeNotProcessed) in
+ if noccur_between sigma 1 nb c then
sigma,(k,lift (-nb) c,pb)::metasubst,evarsubst
- else
+ else
let l = List.map of_alias l in
error_cannot_unify_local env sigma (applist (f, l),c,c)
| Evar ev ->
let env' = pop_rel_context nb env in
- let sigma,c = pose_all_metas_as_evars env' sigma c in
- sigma,metasubst,(env,ev,solve_pattern_eqn env sigma l c)::evarsubst
+ let sigma,c = pose_all_metas_as_evars env' sigma c in
+ sigma,metasubst,(env,ev,solve_pattern_eqn env sigma l c)::evarsubst
| _ -> assert false
let push d (env,n) = (push_rel_assum d env,n+1)
@@ -479,7 +479,7 @@ let use_metas_pattern_unification sigma flags nb l =
|| flags.use_meta_bound_pattern_unification &&
Array.for_all (fun c -> isRel sigma c && destRel sigma c <= nb) l
-type key =
+type key =
| IsKey of CClosure.table_key
| IsProj of Projection.t * EConstr.constr
@@ -494,7 +494,7 @@ let unfold_projection env p stk =
let expand_key ts env sigma = function
| Some (IsKey k) -> Option.map EConstr.of_constr (expand_table_key env k)
- | Some (IsProj (p, c)) ->
+ | Some (IsProj (p, c)) ->
let red = Stack.zip sigma (whd_betaiota_deltazeta_for_iota_state ts env sigma
(c, unfold_projection env p []))
in if EConstr.eq_constr sigma (EConstr.mkProj (p, c)) red then None else Some red
@@ -504,7 +504,7 @@ let isApp_or_Proj sigma c =
match kind sigma c with
| App _ | Proj _ -> true
| _ -> false
-
+
type unirec_flags = {
at_top: bool;
with_types: bool;
@@ -522,7 +522,7 @@ let key_of env sigma b flags f =
|| Recordops.is_primitive_projection cst) ->
let u = EInstance.kind sigma u in
Some (IsKey (ConstKey (cst, u)))
- | Var id when is_transparent env (VarKey id) &&
+ | Var id when is_transparent env (VarKey id) &&
TransparentState.is_transparent_variable flags.modulo_delta id ->
Some (IsKey (VarKey id))
| Proj (p, c) when Projection.unfolded p
@@ -530,7 +530,7 @@ let key_of env sigma b flags f =
(TransparentState.is_transparent_constant flags.modulo_delta (Projection.constant p))) ->
Some (IsProj (p, c))
| _ -> None
-
+
let translate_key = function
| ConstKey (cst,u) -> ConstKey cst
@@ -538,9 +538,9 @@ let translate_key = function
| RelKey n -> RelKey n
let translate_key = function
- | IsKey k -> translate_key k
+ | IsKey k -> translate_key k
| IsProj (c, _) -> ConstKey (Projection.constant c)
-
+
let oracle_order env cf1 cf2 =
match cf1 with
| None ->
@@ -551,16 +551,16 @@ let oracle_order env cf1 cf2 =
match cf2 with
| None -> Some true
| Some k2 ->
- match k1, k2 with
- | IsProj (p, _), IsKey (ConstKey (p',_))
- when Constant.equal (Projection.constant p) p' ->
- Some (not (Projection.unfolded p))
- | IsKey (ConstKey (p,_)), IsProj (p', _)
- when Constant.equal p (Projection.constant p') ->
- Some (Projection.unfolded p')
- | _ ->
+ match k1, k2 with
+ | IsProj (p, _), IsKey (ConstKey (p',_))
+ when Constant.equal (Projection.constant p) p' ->
+ Some (not (Projection.unfolded p))
+ | IsKey (ConstKey (p,_)), IsProj (p', _)
+ when Constant.equal p (Projection.constant p') ->
+ Some (Projection.unfolded p')
+ | _ ->
Some (Conv_oracle.oracle_order (fun x -> x)
- (Environ.oracle env) false (translate_key k1) (translate_key k2))
+ (Environ.oracle env) false (translate_key k1) (translate_key k2))
let is_rigid_head sigma flags t =
match EConstr.kind sigma t with
@@ -588,20 +588,20 @@ let constr_cmp pb env sigma flags t u =
let cstrs =
if pb == Reduction.CONV then EConstr.eq_constr_universes env sigma t u
else EConstr.leq_constr_universes env sigma t u
- in
+ in
match cstrs with
| Some cstrs ->
begin try Some (Evd.add_universe_constraints sigma cstrs)
with Univ.UniverseInconsistency _ -> None
- | Evd.UniversesDiffer ->
- if is_rigid_head sigma flags t then
+ | Evd.UniversesDiffer ->
+ if is_rigid_head sigma flags t then
try Some (Evd.add_universe_constraints sigma (force_eqs cstrs))
with Univ.UniverseInconsistency _ -> None
else None
end
| None ->
None
-
+
let do_reduce ts (env, nb) sigma c =
Stack.zip sigma (whd_betaiota_deltazeta_for_iota_state
ts env sigma (c, Stack.empty))
@@ -653,7 +653,7 @@ let rec is_neutral env sigma ts t =
not (Environ.evaluable_constant c env) ||
not (is_transparent env (ConstKey c)) ||
not (TransparentState.is_transparent_constant ts c)
- | Var id ->
+ | Var id ->
not (Environ.evaluable_named id env) ||
not (is_transparent env (VarKey id)) ||
not (TransparentState.is_transparent_variable ts id)
@@ -676,7 +676,7 @@ let is_eta_constructor_app env sigma ts f l1 term =
let (_, projs, _, _) = info.(i) in
Array.length projs == Array.length l1 - mib.Declarations.mind_nparams ->
(* Check that the other term is neutral *)
- is_neutral env sigma ts term
+ is_neutral env sigma ts term
| _ -> false)
| _ -> false
@@ -687,10 +687,10 @@ let eta_constructor_app env sigma f l1 term =
(match get_projections env ind with
| Some projs ->
let npars = mib.Declarations.mind_nparams in
- let pars, l1' = Array.chop npars l1 in
- let arg = Array.append pars [|term|] in
+ let pars, l1' = Array.chop npars l1 in
+ let arg = Array.append pars [|term|] in
let l2 = Array.map (fun p -> mkApp (mkConstU (Projection.Repr.constant p,u), arg)) projs in
- l1', l2
+ l1', l2
| _ -> assert false)
| _ -> assert false
@@ -698,167 +698,167 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
let rec unirec_rec (curenv,nb as curenvnb) pb opt ((sigma,metasubst,evarsubst) as substn : subst0) curm curn =
let cM = Evarutil.whd_head_evar sigma curm
and cN = Evarutil.whd_head_evar sigma curn in
- let () =
+ let () =
if !debug_unification then
Feedback.msg_debug (
Termops.Internal.print_constr_env curenv sigma cM ++ str" ~= " ++
Termops.Internal.print_constr_env curenv sigma cN)
in
match (EConstr.kind sigma cM, EConstr.kind sigma cN) with
- | Meta k1, Meta k2 ->
+ | Meta k1, Meta k2 ->
if Int.equal k1 k2 then substn else
- let stM,stN = extract_instance_status pb in
- let sigma =
- if opt.with_types && flags.check_applied_meta_types then
- let tyM = Typing.meta_type sigma k1 in
- let tyN = Typing.meta_type sigma k2 in
- let l, r = if k2 < k1 then tyN, tyM else tyM, tyN in
- check_compatibility curenv CUMUL flags substn l r
- else sigma
- in
- if k2 < k1 then sigma,(k1,cN,stN)::metasubst,evarsubst
- else sigma,(k2,cM,stM)::metasubst,evarsubst
- | Meta k, _
+ let stM,stN = extract_instance_status pb in
+ let sigma =
+ if opt.with_types && flags.check_applied_meta_types then
+ let tyM = Typing.meta_type sigma k1 in
+ let tyN = Typing.meta_type sigma k2 in
+ let l, r = if k2 < k1 then tyN, tyM else tyM, tyN in
+ check_compatibility curenv CUMUL flags substn l r
+ else sigma
+ in
+ if k2 < k1 then sigma,(k1,cN,stN)::metasubst,evarsubst
+ else sigma,(k2,cM,stM)::metasubst,evarsubst
+ | Meta k, _
when not (occur_metavariable sigma k cN) (* helps early trying alternatives *) ->
- let sigma =
- if opt.with_types && flags.check_applied_meta_types then
- (try
+ let sigma =
+ if opt.with_types && flags.check_applied_meta_types then
+ (try
let tyM = Typing.meta_type sigma k in
let tyN = get_type_of curenv ~lax:true sigma cN in
check_compatibility curenv CUMUL flags substn tyN tyM
- with RetypeError _ ->
+ with RetypeError _ ->
(* Renounce, maybe metas/evars prevents typing *) sigma)
- else sigma
- in
- (* Here we check that [cN] does not contain any local variables *)
- if Int.equal nb 0 then
+ else sigma
+ in
+ (* Here we check that [cN] does not contain any local variables *)
+ if Int.equal nb 0 then
sigma,(k,cN,snd (extract_instance_status pb))::metasubst,evarsubst
else if noccur_between sigma 1 nb cN then
(sigma,
- (k,lift (-nb) cN,snd (extract_instance_status pb))::metasubst,
+ (k,lift (-nb) cN,snd (extract_instance_status pb))::metasubst,
evarsubst)
- else error_cannot_unify_local curenv sigma (m,n,cN)
- | _, Meta k
+ else error_cannot_unify_local curenv sigma (m,n,cN)
+ | _, Meta k
when not (occur_metavariable sigma k cM) (* helps early trying alternatives *) ->
- let sigma =
- if opt.with_types && flags.check_applied_meta_types then
+ let sigma =
+ if opt.with_types && flags.check_applied_meta_types then
(try
let tyM = get_type_of curenv ~lax:true sigma cM in
let tyN = Typing.meta_type sigma k in
check_compatibility curenv CUMUL flags substn tyM tyN
with RetypeError _ ->
(* Renounce, maybe metas/evars prevents typing *) sigma)
- else sigma
- in
- (* Here we check that [cM] does not contain any local variables *)
- if Int.equal nb 0 then
+ else sigma
+ in
+ (* Here we check that [cM] does not contain any local variables *)
+ if Int.equal nb 0 then
(sigma,(k,cM,fst (extract_instance_status pb))::metasubst,evarsubst)
- else if noccur_between sigma 1 nb cM
- then
+ else if noccur_between sigma 1 nb cM
+ then
(sigma,(k,lift (-nb) cM,fst (extract_instance_status pb))::metasubst,
evarsubst)
- else error_cannot_unify_local curenv sigma (m,n,cM)
- | Evar (evk,_ as ev), Evar (evk',_)
+ else error_cannot_unify_local curenv sigma (m,n,cM)
+ | Evar (evk,_ as ev), Evar (evk',_)
when is_evar_allowed flags evk
&& Evar.equal evk evk' ->
begin match constr_cmp cv_pb env sigma flags cM cN with
| Some sigma ->
sigma, metasubst, evarsubst
| None ->
- sigma,metasubst,((curenv,ev,cN)::evarsubst)
+ sigma,metasubst,((curenv,ev,cN)::evarsubst)
end
- | Evar (evk,_ as ev), _
+ | Evar (evk,_ as ev), _
when is_evar_allowed flags evk
- && not (occur_evar sigma evk cN) ->
- let cmvars = free_rels sigma cM and cnvars = free_rels sigma cN in
- if Int.Set.subset cnvars cmvars then
- sigma,metasubst,((curenv,ev,cN)::evarsubst)
- else error_cannot_unify_local curenv sigma (m,n,cN)
- | _, Evar (evk,_ as ev)
+ && not (occur_evar sigma evk cN) ->
+ let cmvars = free_rels sigma cM and cnvars = free_rels sigma cN in
+ if Int.Set.subset cnvars cmvars then
+ sigma,metasubst,((curenv,ev,cN)::evarsubst)
+ else error_cannot_unify_local curenv sigma (m,n,cN)
+ | _, Evar (evk,_ as ev)
when is_evar_allowed flags evk
- && not (occur_evar sigma evk cM) ->
- let cmvars = free_rels sigma cM and cnvars = free_rels sigma cN in
- if Int.Set.subset cmvars cnvars then
- sigma,metasubst,((curenv,ev,cM)::evarsubst)
- else error_cannot_unify_local curenv sigma (m,n,cN)
- | Sort s1, Sort s2 ->
- (try
+ && not (occur_evar sigma evk cM) ->
+ let cmvars = free_rels sigma cM and cnvars = free_rels sigma cN in
+ if Int.Set.subset cmvars cnvars then
+ sigma,metasubst,((curenv,ev,cM)::evarsubst)
+ else error_cannot_unify_local curenv sigma (m,n,cN)
+ | Sort s1, Sort s2 ->
+ (try
let s1 = ESorts.kind sigma s1 in
let s2 = ESorts.kind sigma s2 in
- let sigma' =
- if pb == CUMUL
- then Evd.set_leq_sort curenv sigma s1 s2
- else Evd.set_eq_sort curenv sigma s1 s2
- in (sigma', metasubst, evarsubst)
- with e when CErrors.noncritical e ->
+ let sigma' =
+ if pb == CUMUL
+ then Evd.set_leq_sort curenv sigma s1 s2
+ else Evd.set_eq_sort curenv sigma s1 s2
+ in (sigma', metasubst, evarsubst)
+ with e when CErrors.noncritical e ->
error_cannot_unify curenv sigma (m,n))
| Lambda (na,t1,c1), Lambda (__,t2,c2) ->
unirec_rec (push (na,t1) curenvnb) CONV {opt with at_top = true}
- (unirec_rec curenvnb CONV {opt with at_top = true; with_types = false} substn t1 t2) c1 c2
+ (unirec_rec curenvnb CONV {opt with at_top = true; with_types = false} substn t1 t2) c1 c2
| Prod (na,t1,c1), Prod (_,t2,c2) ->
unirec_rec (push (na,t1) curenvnb) pb {opt with at_top = true}
- (unirec_rec curenvnb CONV {opt with at_top = true; with_types = false} substn t1 t2) c1 c2
+ (unirec_rec curenvnb CONV {opt with at_top = true; with_types = false} substn t1 t2) c1 c2
| LetIn (_,a,_,c), _ -> unirec_rec curenvnb pb opt substn (subst1 a c) cN
| _, LetIn (_,a,_,c) -> unirec_rec curenvnb pb opt substn cM (subst1 a c)
(* Fast path for projections. *)
- | Proj (p1,c1), Proj (p2,c2) when Constant.equal
- (Projection.constant p1) (Projection.constant p2) ->
- (try unify_same_proj curenvnb cv_pb {opt with at_top = true}
- substn c1 c2
- with ex when precatchable_exception ex ->
- unify_not_same_head curenvnb pb opt substn cM cN)
+ | Proj (p1,c1), Proj (p2,c2) when Constant.equal
+ (Projection.constant p1) (Projection.constant p2) ->
+ (try unify_same_proj curenvnb cv_pb {opt with at_top = true}
+ substn c1 c2
+ with ex when precatchable_exception ex ->
+ unify_not_same_head curenvnb pb opt substn cM cN)
(* eta-expansion *)
| Lambda (na,t1,c1), _ when flags.modulo_eta ->
unirec_rec (push (na,t1) curenvnb) CONV {opt with at_top = true} substn
- c1 (mkApp (lift 1 cN,[|mkRel 1|]))
+ c1 (mkApp (lift 1 cN,[|mkRel 1|]))
| _, Lambda (na,t2,c2) when flags.modulo_eta ->
unirec_rec (push (na,t2) curenvnb) CONV {opt with at_top = true} substn
- (mkApp (lift 1 cM,[|mkRel 1|])) c2
-
- (* For records *)
- | App (f1, l1), _ when flags.modulo_eta &&
- (* This ensures cN is an evar, meta or irreducible constant/variable
- and not a constructor. *)
- is_eta_constructor_app curenv sigma flags.modulo_delta f1 l1 cN ->
- (try
- let l1', l2' = eta_constructor_app curenv sigma f1 l1 cN in
- let opt' = {opt with at_top = true; with_cs = false} in
- Array.fold_left2 (unirec_rec curenvnb CONV opt') substn l1' l2'
- with ex when precatchable_exception ex ->
- match EConstr.kind sigma cN with
- | App(f2,l2) when
- (isMeta sigma f2 && use_metas_pattern_unification sigma flags nb l2
- || use_evars_pattern_unification flags && isAllowedEvar sigma flags f2) ->
- unify_app_pattern false curenvnb pb opt substn cM f1 l1 cN f2 l2
- | _ -> raise ex)
-
- | _, App (f2, l2) when flags.modulo_eta &&
- is_eta_constructor_app curenv sigma flags.modulo_delta f2 l2 cM ->
- (try
- let l2', l1' = eta_constructor_app curenv sigma f2 l2 cM in
- let opt' = {opt with at_top = true; with_cs = false} in
- Array.fold_left2 (unirec_rec curenvnb CONV opt') substn l1' l2'
- with ex when precatchable_exception ex ->
- match EConstr.kind sigma cM with
- | App(f1,l1) when
- (isMeta sigma f1 && use_metas_pattern_unification sigma flags nb l1
- || use_evars_pattern_unification flags && isAllowedEvar sigma flags f1) ->
- unify_app_pattern true curenvnb pb opt substn cM f1 l1 cN f2 l2
- | _ -> raise ex)
+ (mkApp (lift 1 cM,[|mkRel 1|])) c2
+
+ (* For records *)
+ | App (f1, l1), _ when flags.modulo_eta &&
+ (* This ensures cN is an evar, meta or irreducible constant/variable
+ and not a constructor. *)
+ is_eta_constructor_app curenv sigma flags.modulo_delta f1 l1 cN ->
+ (try
+ let l1', l2' = eta_constructor_app curenv sigma f1 l1 cN in
+ let opt' = {opt with at_top = true; with_cs = false} in
+ Array.fold_left2 (unirec_rec curenvnb CONV opt') substn l1' l2'
+ with ex when precatchable_exception ex ->
+ match EConstr.kind sigma cN with
+ | App(f2,l2) when
+ (isMeta sigma f2 && use_metas_pattern_unification sigma flags nb l2
+ || use_evars_pattern_unification flags && isAllowedEvar sigma flags f2) ->
+ unify_app_pattern false curenvnb pb opt substn cM f1 l1 cN f2 l2
+ | _ -> raise ex)
+
+ | _, App (f2, l2) when flags.modulo_eta &&
+ is_eta_constructor_app curenv sigma flags.modulo_delta f2 l2 cM ->
+ (try
+ let l2', l1' = eta_constructor_app curenv sigma f2 l2 cM in
+ let opt' = {opt with at_top = true; with_cs = false} in
+ Array.fold_left2 (unirec_rec curenvnb CONV opt') substn l1' l2'
+ with ex when precatchable_exception ex ->
+ match EConstr.kind sigma cM with
+ | App(f1,l1) when
+ (isMeta sigma f1 && use_metas_pattern_unification sigma flags nb l1
+ || use_evars_pattern_unification flags && isAllowedEvar sigma flags f1) ->
+ unify_app_pattern true curenvnb pb opt substn cM f1 l1 cN f2 l2
+ | _ -> raise ex)
| Case (ci1,p1,c1,cl1), Case (ci2,p2,c2,cl2) ->
(try
if not (eq_ind ci1.ci_ind ci2.ci_ind) then error_cannot_unify curenv sigma (cM,cN);
- let opt' = {opt with at_top = true; with_types = false} in
- Array.fold_left2 (unirec_rec curenvnb CONV {opt with at_top = true})
- (unirec_rec curenvnb CONV opt'
- (unirec_rec curenvnb CONV opt' substn p1 p2) c1 c2)
+ let opt' = {opt with at_top = true; with_types = false} in
+ Array.fold_left2 (unirec_rec curenvnb CONV {opt with at_top = true})
+ (unirec_rec curenvnb CONV opt'
+ (unirec_rec curenvnb CONV opt' substn p1 p2) c1 c2)
cl1 cl2
- with ex when precatchable_exception ex ->
- reduce curenvnb pb opt substn cM cN)
+ with ex when precatchable_exception ex ->
+ reduce curenvnb pb opt substn cM cN)
| Fix ((ln1,i1),(lna1,tl1,bl1)), Fix ((ln2,i2),(_,tl2,bl2)) when
Int.equal i1 i2 && Array.equal Int.equal ln1 ln2 ->
@@ -880,68 +880,68 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
with ex when precatchable_exception ex ->
reduce curenvnb pb opt substn cM cN)
- | App (f1,l1), _ when
- (isMeta sigma f1 && use_metas_pattern_unification sigma flags nb l1
+ | App (f1,l1), _ when
+ (isMeta sigma f1 && use_metas_pattern_unification sigma flags nb l1
|| use_evars_pattern_unification flags && isAllowedEvar sigma flags f1) ->
- unify_app_pattern true curenvnb pb opt substn cM f1 l1 cN cN [||]
+ unify_app_pattern true curenvnb pb opt substn cM f1 l1 cN cN [||]
- | _, App (f2,l2) when
- (isMeta sigma f2 && use_metas_pattern_unification sigma flags nb l2
+ | _, App (f2,l2) when
+ (isMeta sigma f2 && use_metas_pattern_unification sigma flags nb l2
|| use_evars_pattern_unification flags && isAllowedEvar sigma flags f2) ->
- unify_app_pattern false curenvnb pb opt substn cM cM [||] cN f2 l2
+ unify_app_pattern false curenvnb pb opt substn cM cM [||] cN f2 l2
+
+ | App (f1,l1), App (f2,l2) ->
+ unify_app curenvnb pb opt substn cM f1 l1 cN f2 l2
- | App (f1,l1), App (f2,l2) ->
- unify_app curenvnb pb opt substn cM f1 l1 cN f2 l2
-
- | App (f1,l1), Proj(p2,c2) ->
- unify_app curenvnb pb opt substn cM f1 l1 cN cN [||]
+ | App (f1,l1), Proj(p2,c2) ->
+ unify_app curenvnb pb opt substn cM f1 l1 cN cN [||]
- | Proj (p1,c1), App(f2,l2) ->
- unify_app curenvnb pb opt substn cM cM [||] cN f2 l2
+ | Proj (p1,c1), App(f2,l2) ->
+ unify_app curenvnb pb opt substn cM cM [||] cN f2 l2
- | _ ->
+ | _ ->
unify_not_same_head curenvnb pb opt substn cM cN
and unify_app_pattern dir curenvnb pb opt (sigma, _, _ as substn) cM f1 l1 cN f2 l2 =
let f, l, t = if dir then f1, l1, cN else f2, l2, cM in
match is_unification_pattern curenvnb sigma f (Array.to_list l) t with
| None ->
- (match EConstr.kind sigma t with
- | App (f',l') ->
- if dir then unify_app curenvnb pb opt substn cM f1 l1 t f' l'
- else unify_app curenvnb pb opt substn t f' l' cN f2 l2
- | Proj _ -> unify_app curenvnb pb opt substn cM f1 l1 cN f2 l2
- | _ -> unify_not_same_head curenvnb pb opt substn cM cN)
+ (match EConstr.kind sigma t with
+ | App (f',l') ->
+ if dir then unify_app curenvnb pb opt substn cM f1 l1 t f' l'
+ else unify_app curenvnb pb opt substn t f' l' cN f2 l2
+ | Proj _ -> unify_app curenvnb pb opt substn cM f1 l1 cN f2 l2
+ | _ -> unify_not_same_head curenvnb pb opt substn cM cN)
| Some l ->
- solve_pattern_eqn_array curenvnb f l t substn
+ solve_pattern_eqn_array curenvnb f l t substn
and unify_app (curenv, nb as curenvnb) pb opt (sigma, metas, evars as substn : subst0) cM f1 l1 cN f2 l2 =
try
- let needs_expansion p c' =
- match EConstr.kind sigma c' with
- | Meta _ -> true
- | Evar _ -> true
- | Const (c, u) -> Constant.equal c (Projection.constant p)
- | _ -> false
+ let needs_expansion p c' =
+ match EConstr.kind sigma c' with
+ | Meta _ -> true
+ | Evar _ -> true
+ | Const (c, u) -> Constant.equal c (Projection.constant p)
+ | _ -> false
in
- let expand_proj c c' l =
- match EConstr.kind sigma c with
- | Proj (p, t) when not (Projection.unfolded p) && needs_expansion p c' ->
- (try destApp sigma (Retyping.expand_projection curenv sigma p t (Array.to_list l))
+ let expand_proj c c' l =
+ match EConstr.kind sigma c with
+ | Proj (p, t) when not (Projection.unfolded p) && needs_expansion p c' ->
+ (try destApp sigma (Retyping.expand_projection curenv sigma p t (Array.to_list l))
with RetypeError _ -> (* Unification can be called on ill-typed terms, due
- to FO and eta in particular, fail gracefully in that case *)
- (c, l))
- | _ -> (c, l)
+ to FO and eta in particular, fail gracefully in that case *)
+ (c, l))
+ | _ -> (c, l)
in
let f1, l1 = expand_proj f1 f2 l1 in
let f2, l2 = expand_proj f2 f1 l2 in
let opta = {opt with at_top = true; with_types = false} in
let optf = {opt with at_top = true; with_types = true} in
let (f1,l1,f2,l2) = adjust_app_array_size f1 l1 f2 l2 in
- if Array.length l1 == 0 then error_cannot_unify (fst curenvnb) sigma (cM,cN)
- else
- Array.fold_left2 (unirec_rec curenvnb CONV opta)
- (unirec_rec curenvnb CONV optf substn f1 f2) l1 l2
+ if Array.length l1 == 0 then error_cannot_unify (fst curenvnb) sigma (cM,cN)
+ else
+ Array.fold_left2 (unirec_rec curenvnb CONV opta)
+ (unirec_rec curenvnb CONV optf substn f1 f2) l1 l2
with ex when precatchable_exception ex ->
try reduce curenvnb pb {opt with with_types = false} substn cM cN
with ex when precatchable_exception ex ->
@@ -952,14 +952,14 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
and unify_same_proj (curenv, nb as curenvnb) cv_pb opt substn c1 c2 =
let substn = unirec_rec curenvnb CONV opt substn c1 c2 in
try (* Force unification of the types to fill in parameters *)
- let ty1 = get_type_of curenv ~lax:true sigma c1 in
- let ty2 = get_type_of curenv ~lax:true sigma c2 in
- unify_0_with_initial_metas substn true curenv cv_pb
+ let ty1 = get_type_of curenv ~lax:true sigma c1 in
+ let ty2 = get_type_of curenv ~lax:true sigma c2 in
+ unify_0_with_initial_metas substn true curenv cv_pb
{ flags with modulo_conv_on_closed_terms = Some TransparentState.full;
modulo_delta = TransparentState.full;
- modulo_eta = true;
- modulo_betaiota = true }
- ty1 ty2
+ modulo_eta = true;
+ modulo_betaiota = true }
+ ty1 ty2
with RetypeError _ -> substn
and unify_not_same_head curenvnb pb opt (sigma, metas, evars as substn : subst0) cM cN =
@@ -968,41 +968,41 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
match constr_cmp cv_pb env sigma flags cM cN with
| Some sigma -> (sigma, metas, evars)
| None ->
- try reduce curenvnb pb opt substn cM cN
- with ex when precatchable_exception ex ->
- let (f1,l1) =
- match EConstr.kind sigma cM with App (f,l) -> (f,l) | _ -> (cM,[||]) in
- let (f2,l2) =
- match EConstr.kind sigma cN with App (f,l) -> (f,l) | _ -> (cN,[||]) in
- expand curenvnb pb opt substn cM f1 l1 cN f2 l2
+ try reduce curenvnb pb opt substn cM cN
+ with ex when precatchable_exception ex ->
+ let (f1,l1) =
+ match EConstr.kind sigma cM with App (f,l) -> (f,l) | _ -> (cM,[||]) in
+ let (f2,l2) =
+ match EConstr.kind sigma cN with App (f,l) -> (f,l) | _ -> (cN,[||]) in
+ expand curenvnb pb opt substn cM f1 l1 cN f2 l2
and reduce curenvnb pb opt (sigma, metas, evars as substn) cM cN =
if flags.modulo_betaiota && not (subterm_restriction opt flags) then
let cM' = do_reduce flags.modulo_delta curenvnb sigma cM in
- if not (EConstr.eq_constr sigma cM cM') then
- unirec_rec curenvnb pb opt substn cM' cN
- else
- let cN' = do_reduce flags.modulo_delta curenvnb sigma cN in
- if not (EConstr.eq_constr sigma cN cN') then
- unirec_rec curenvnb pb opt substn cM cN'
- else error_cannot_unify (fst curenvnb) sigma (cM,cN)
+ if not (EConstr.eq_constr sigma cM cM') then
+ unirec_rec curenvnb pb opt substn cM' cN
+ else
+ let cN' = do_reduce flags.modulo_delta curenvnb sigma cN in
+ if not (EConstr.eq_constr sigma cN cN') then
+ unirec_rec curenvnb pb opt substn cM cN'
+ else error_cannot_unify (fst curenvnb) sigma (cM,cN)
else error_cannot_unify (fst curenvnb) sigma (cM,cN)
-
+
and expand (curenv,_ as curenvnb) pb opt (sigma,metasubst,evarsubst as substn : subst0) cM f1 l1 cN f2 l2 =
let res =
(* Try full conversion on meta-free terms. *)
(* Back to 1995 (later on called trivial_unify in 2002), the
- heuristic was to apply conversion on meta-free (but not
- evar-free!) terms in all cases (i.e. for apply but also for
- auto and rewrite, even though auto and rewrite did not use
- modulo conversion in the rest of the unification
- algorithm). By compatibility we need to support this
- separately from the main unification algorithm *)
+ heuristic was to apply conversion on meta-free (but not
+ evar-free!) terms in all cases (i.e. for apply but also for
+ auto and rewrite, even though auto and rewrite did not use
+ modulo conversion in the rest of the unification
+ algorithm). By compatibility we need to support this
+ separately from the main unification algorithm *)
(* The exploitation of known metas has been added in May 2007
- (it is used by apply and rewrite); it might now be redundant
- with the support for delta-expansion (which is used
- essentially for apply)... *)
- if subterm_restriction opt flags then None else
+ (it is used by apply and rewrite); it might now be redundant
+ with the support for delta-expansion (which is used
+ essentially for apply)... *)
+ if subterm_restriction opt flags then None else
match flags.modulo_conv_on_closed_terms with
| None -> None
| Some convflags ->
@@ -1014,16 +1014,16 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
| None -> (* some undefined Metas in cN *) None
| Some n1 ->
(* No subterm restriction there, too much incompatibilities *)
- let sigma =
- if opt.with_types then
- try (* Ensure we call conversion on terms of the same type *)
- let tyM = get_type_of curenv ~lax:true sigma m1 in
- let tyN = get_type_of curenv ~lax:true sigma n1 in
- check_compatibility curenv CUMUL flags substn tyM tyN
- with RetypeError _ ->
- (* Renounce, maybe metas/evars prevents typing *) sigma
- else sigma
- in
+ let sigma =
+ if opt.with_types then
+ try (* Ensure we call conversion on terms of the same type *)
+ let tyM = get_type_of curenv ~lax:true sigma m1 in
+ let tyN = get_type_of curenv ~lax:true sigma n1 in
+ check_compatibility curenv CUMUL flags substn tyM tyN
+ with RetypeError _ ->
+ (* Renounce, maybe metas/evars prevents typing *) sigma
+ else sigma
+ in
match infer_conv ~pb ~ts:convflags curenv sigma m1 n1 with
| Some sigma ->
Some (sigma, metasubst, evarsubst)
@@ -1036,41 +1036,41 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
| Some substn -> substn
| None ->
let cf1 = key_of curenv sigma opt flags f1 and cf2 = key_of curenv sigma opt flags f2 in
- match oracle_order curenv cf1 cf2 with
- | None -> error_cannot_unify curenv sigma (cM,cN)
- | Some true ->
- (match expand_key flags.modulo_delta curenv sigma cf1 with
- | Some c ->
- unirec_rec curenvnb pb opt substn
+ match oracle_order curenv cf1 cf2 with
+ | None -> error_cannot_unify curenv sigma (cM,cN)
+ | Some true ->
+ (match expand_key flags.modulo_delta curenv sigma cf1 with
+ | Some c ->
+ unirec_rec curenvnb pb opt substn
(whd_betaiotazeta sigma (mkApp(c,l1))) cN
- | None ->
- (match expand_key flags.modulo_delta curenv sigma cf2 with
- | Some c ->
- unirec_rec curenvnb pb opt substn cM
+ | None ->
+ (match expand_key flags.modulo_delta curenv sigma cf2 with
+ | Some c ->
+ unirec_rec curenvnb pb opt substn cM
(whd_betaiotazeta sigma (mkApp(c,l2)))
- | None ->
- error_cannot_unify curenv sigma (cM,cN)))
- | Some false ->
- (match expand_key flags.modulo_delta curenv sigma cf2 with
- | Some c ->
- unirec_rec curenvnb pb opt substn cM
+ | None ->
+ error_cannot_unify curenv sigma (cM,cN)))
+ | Some false ->
+ (match expand_key flags.modulo_delta curenv sigma cf2 with
+ | Some c ->
+ unirec_rec curenvnb pb opt substn cM
(whd_betaiotazeta sigma (mkApp(c,l2)))
- | None ->
- (match expand_key flags.modulo_delta curenv sigma cf1 with
- | Some c ->
- unirec_rec curenvnb pb opt substn
+ | None ->
+ (match expand_key flags.modulo_delta curenv sigma cf1 with
+ | Some c ->
+ unirec_rec curenvnb pb opt substn
(whd_betaiotazeta sigma (mkApp(c,l1))) cN
- | None ->
- error_cannot_unify curenv sigma (cM,cN)))
+ | None ->
+ error_cannot_unify curenv sigma (cM,cN)))
and canonical_projections (curenv, _ as curenvnb) pb opt cM cN (sigma,_,_ as substn) =
let f1 () =
if isApp_or_Proj sigma cM then
- let f1l1 = whd_nored_state sigma (cM,Stack.empty) in
- if is_open_canonical_projection curenv sigma f1l1 then
- let f2l2 = whd_nored_state sigma (cN,Stack.empty) in
- solve_canonical_projection curenvnb pb opt cM f1l1 cN f2l2 substn
- else error_cannot_unify (fst curenvnb) sigma (cM,cN)
+ let f1l1 = whd_nored_state sigma (cM,Stack.empty) in
+ if is_open_canonical_projection curenv sigma f1l1 then
+ let f2l2 = whd_nored_state sigma (cN,Stack.empty) in
+ solve_canonical_projection curenvnb pb opt cM f1l1 cN f2l2 substn
+ else error_cannot_unify (fst curenvnb) sigma (cM,cN)
else error_cannot_unify (fst curenvnb) sigma (cM,cN)
in
if not opt.with_cs ||
@@ -1078,16 +1078,16 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
| None -> true
| Some _ -> subterm_restriction opt flags
end then
- error_cannot_unify (fst curenvnb) sigma (cM,cN)
+ error_cannot_unify (fst curenvnb) sigma (cM,cN)
else
- try f1 () with e when precatchable_exception e ->
- if isApp_or_Proj sigma cN then
- let f2l2 = whd_nored_state sigma (cN, Stack.empty) in
- if is_open_canonical_projection curenv sigma f2l2 then
- let f1l1 = whd_nored_state sigma (cM, Stack.empty) in
- solve_canonical_projection curenvnb pb opt cN f2l2 cM f1l1 substn
- else error_cannot_unify (fst curenvnb) sigma (cM,cN)
- else error_cannot_unify (fst curenvnb) sigma (cM,cN)
+ try f1 () with e when precatchable_exception e ->
+ if isApp_or_Proj sigma cN then
+ let f2l2 = whd_nored_state sigma (cN, Stack.empty) in
+ if is_open_canonical_projection curenv sigma f2l2 then
+ let f1l1 = whd_nored_state sigma (cM, Stack.empty) in
+ solve_canonical_projection curenvnb pb opt cN f2l2 cM f1l1 substn
+ else error_cannot_unify (fst curenvnb) sigma (cM,cN)
+ else error_cannot_unify (fst curenvnb) sigma (cM,cN)
and solve_canonical_projection curenvnb pb opt cM f1l1 cN f2l2 (sigma,ms,es) =
let (ctx,t,c,bs,(params,params1),(us,us2),(ts,ts1),c1,(n,t2)) =
@@ -1097,44 +1097,44 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
if Reductionops.Stack.compare_shape ts ts1 then
let sigma = Evd.merge_context_set Evd.univ_flexible sigma ctx in
let (evd,ks,_) =
- List.fold_left
- (fun (evd,ks,m) b ->
- if match n with Some n -> Int.equal m n | None -> false then
+ List.fold_left
+ (fun (evd,ks,m) b ->
+ if match n with Some n -> Int.equal m n | None -> false then
(evd,t2::ks, m-1)
else
let mv = new_meta () in
let evd' = meta_declare mv (substl ks b) evd in
- (evd', mkMeta mv :: ks, m - 1))
- (sigma,[],List.length bs) bs
+ (evd', mkMeta mv :: ks, m - 1))
+ (sigma,[],List.length bs) bs
in
try
let opt' = {opt with with_types = false} in
let substn = Reductionops.Stack.fold2
- (fun s u1 u -> unirec_rec curenvnb pb opt' s u1 (substl ks u))
- (evd,ms,es) us2 us in
+ (fun s u1 u -> unirec_rec curenvnb pb opt' s u1 (substl ks u))
+ (evd,ms,es) us2 us in
let substn = Reductionops.Stack.fold2
- (fun s u1 u -> unirec_rec curenvnb pb opt' s u1 (substl ks u))
- substn params1 params in
+ (fun s u1 u -> unirec_rec curenvnb pb opt' s u1 (substl ks u))
+ substn params1 params in
let substn = Reductionops.Stack.fold2 (fun s u1 u2 -> unirec_rec curenvnb pb opt' s u1 u2) substn ts ts1 in
let app = mkApp (c, Array.rev_of_list ks) in
(* let substn = unirec_rec curenvnb pb b false substn t cN in *)
- unirec_rec curenvnb pb opt' substn c1 app
+ unirec_rec curenvnb pb opt' substn c1 app
with Reductionops.Stack.IncompatibleFold2 ->
- error_cannot_unify (fst curenvnb) sigma (cM,cN)
+ error_cannot_unify (fst curenvnb) sigma (cM,cN)
else error_cannot_unify (fst curenvnb) sigma (cM,cN)
in
-
+
if !debug_unification then Feedback.msg_debug (str "Starting unification");
let opt = { at_top = conv_at_top; with_types = false; with_cs = true } in
try
- let res =
+ let res =
if subterm_restriction opt flags ||
occur_meta_or_undefined_evar sigma m || occur_meta_or_undefined_evar sigma n
then
None
- else
+ else
let ans = match flags.modulo_conv_on_closed_terms with
- | Some convflags -> infer_conv ~pb:cv_pb ~ts:convflags env sigma m n
+ | Some convflags -> infer_conv ~pb:cv_pb ~ts:convflags env sigma m n
| _ -> constr_cmp cv_pb env sigma flags m n in
match ans with
| Some sigma -> ans
@@ -1144,9 +1144,9 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
let open TransparentState in
Id.Pred.subset dl.tr_var cv.tr_var && Cpred.subset dl.tr_cst cv.tr_cst
| None, dl -> TransparentState.is_empty dl)
- then error_cannot_unify env sigma (m, n) else None
- in
- let a = match res with
+ then error_cannot_unify env sigma (m, n) else None
+ in
+ let a = match res with
| Some sigma -> sigma, ms, es
| None -> unirec_rec (env,0) cv_pb opt subst m n in
if !debug_unification then Feedback.msg_debug (str "Leaving unification with success");
@@ -1183,14 +1183,14 @@ let rec unify_with_eta keptside flags env sigma c1 c2 =
(mkApp (lift 1 c1,[|mkRel 1|])) c2'
| _ ->
(keptside,unify_0 env sigma CONV flags c1 c2)
-
+
(* We solved problems [?n =_pb u] (i.e. [u =_(opp pb) ?n]) and [?n =_pb' u'],
we now compute the problem on [u =? u'] and decide which of u or u' is kept
Rem: the upper constraint is lost in case u <= ?n <= u' (and symmetrically
in the case u' <= ?n <= u)
*)
-
+
let merge_instances env sigma flags st1 st2 c1 c2 =
match (opp_status st1, st2) with
| (Conv, Conv) ->
@@ -1217,7 +1217,7 @@ let merge_instances env sigma flags st1 st2 c1 c2 =
(try (left, IsSuperType, unify_0 env sigma CUMUL flags c1 c2)
with e when CErrors.noncritical e ->
(right, IsSuperType, unify_0 env sigma CUMUL flags c2 c1))
-
+
(* Unification
*
* Procedure:
@@ -1304,7 +1304,7 @@ let w_coerce_to_type env evd c cty mvty =
fst (nat,nat)) and stops while it could have seen that it is rigid *)
let cty = Tacred.hnf_constr env evd cty in
try_to_coerce env evd c cty tycon
-
+
let w_coerce env evd mv c =
let cty = get_type_of env evd c in
let mvty = Typing.meta_type evd mv in
@@ -1319,7 +1319,7 @@ let unify_to_type env sigma flags c status u =
let unify_type env sigma flags mv status c =
let mvty = Typing.meta_type sigma mv in
let mvty = nf_meta sigma mvty in
- unify_to_type env sigma
+ unify_to_type env sigma
(set_flags_for_type flags)
c status mvty
@@ -1353,89 +1353,89 @@ let w_merge env with_types flags (evd,metas,evars : subst0) =
(* Process evars *)
match evars with
| (curenv,(evk,_ as ev),rhs)::evars' ->
- if Evd.is_defined evd evk then
- let v = mkEvar ev in
- let (evd,metas',evars'') =
- unify_0 curenv evd CONV flags rhs v in
- w_merge_rec evd (metas'@metas) (evars''@evars') eqns
- else begin
- (* This can make rhs' ill-typed if metas are *)
+ if Evd.is_defined evd evk then
+ let v = mkEvar ev in
+ let (evd,metas',evars'') =
+ unify_0 curenv evd CONV flags rhs v in
+ w_merge_rec evd (metas'@metas) (evars''@evars') eqns
+ else begin
+ (* This can make rhs' ill-typed if metas are *)
let rhs' = subst_meta_instances evd metas rhs in
match EConstr.kind evd rhs with
- | App (f,cl) when occur_meta evd rhs' ->
- if occur_evar evd evk rhs' then
+ | App (f,cl) when occur_meta evd rhs' ->
+ if occur_evar evd evk rhs' then
error_occur_check curenv evd evk rhs';
- if is_mimick_head evd flags.modulo_delta f then
- let evd' =
- mimick_undefined_evar evd flags f (Array.length cl) evk in
- w_merge_rec evd' metas evars eqns
- else
- let evd' =
- let evd', rhs'' = pose_all_metas_as_evars curenv evd rhs' in
+ if is_mimick_head evd flags.modulo_delta f then
+ let evd' =
+ mimick_undefined_evar evd flags f (Array.length cl) evk in
+ w_merge_rec evd' metas evars eqns
+ else
+ let evd' =
+ let evd', rhs'' = pose_all_metas_as_evars curenv evd rhs' in
try solve_simple_evar_eqn eflags curenv evd' ev rhs''
- with Retyping.RetypeError _ ->
- error_cannot_unify curenv evd' (mkEvar ev,rhs'')
- in w_merge_rec evd' metas evars' eqns
+ with Retyping.RetypeError _ ->
+ error_cannot_unify curenv evd' (mkEvar ev,rhs'')
+ in w_merge_rec evd' metas evars' eqns
| _ ->
- let evd', rhs'' = pose_all_metas_as_evars curenv evd rhs' in
- let evd' =
+ let evd', rhs'' = pose_all_metas_as_evars curenv evd rhs' in
+ let evd' =
try solve_simple_evar_eqn eflags curenv evd' ev rhs''
- with Retyping.RetypeError _ -> error_cannot_unify curenv evd' (mkEvar ev, rhs'')
- in
- w_merge_rec evd' metas evars' eqns
- end
+ with Retyping.RetypeError _ -> error_cannot_unify curenv evd' (mkEvar ev, rhs'')
+ in
+ w_merge_rec evd' metas evars' eqns
+ end
| [] ->
(* Process metas *)
match metas with
| (mv,c,(status,to_type))::metas ->
let ((evd,c),(metas'',evars'')),eqns =
- if with_types && to_type != TypeProcessed then
- begin match to_type with
- | CoerceToType ->
+ if with_types && to_type != TypeProcessed then
+ begin match to_type with
+ | CoerceToType ->
(* Some coercion may have to be inserted *)
- (w_coerce env evd mv c,([],[])),eqns
- | _ ->
+ (w_coerce env evd mv c,([],[])),eqns
+ | _ ->
(* No coercion needed: delay the unification of types *)
- ((evd,c),([],[])),(mv,status,c)::eqns
- end
- else
- ((evd,c),([],[])),eqns
- in
- if meta_defined evd mv then
- let {rebus=c'},(status',_) = meta_fvalue evd mv in
+ ((evd,c),([],[])),(mv,status,c)::eqns
+ end
+ else
+ ((evd,c),([],[])),eqns
+ in
+ if meta_defined evd mv then
+ let {rebus=c'},(status',_) = meta_fvalue evd mv in
let (take_left,st,(evd,metas',evars')) =
merge_instances env evd flags status' status c' c
- in
- let evd' =
+ in
+ let evd' =
if take_left then evd
else meta_reassign mv (c,(st,TypeProcessed)) evd
- in
+ in
w_merge_rec evd' (metas'@metas@metas'') (evars'@evars'') eqns
- else
+ else
let evd' =
if occur_meta_evd evd mv c then
if isMetaOf evd mv (whd_all env evd c) then evd
else error_cannot_unify env evd (mkMeta mv,c)
else
meta_assign mv (c,(status,TypeProcessed)) evd in
- w_merge_rec evd' (metas''@metas) evars'' eqns
+ w_merge_rec evd' (metas''@metas) evars'' eqns
| [] ->
- (* Process type eqns *)
- let rec process_eqns failures = function
- | (mv,status,c)::eqns ->
+ (* Process type eqns *)
+ let rec process_eqns failures = function
+ | (mv,status,c)::eqns ->
(match (try Inl (unify_type env evd flags mv status c)
- with e when CErrors.noncritical e -> Inr e)
- with
- | Inr e -> process_eqns (((mv,status,c),e)::failures) eqns
- | Inl (evd,metas,evars) ->
- w_merge_rec evd metas evars (List.map fst failures @ eqns))
- | [] ->
- (match failures with
- | [] -> evd
- | ((mv,status,c),e)::_ -> raise e)
- in process_eqns [] eqns
-
+ with e when CErrors.noncritical e -> Inr e)
+ with
+ | Inr e -> process_eqns (((mv,status,c),e)::failures) eqns
+ | Inl (evd,metas,evars) ->
+ w_merge_rec evd metas evars (List.map fst failures @ eqns))
+ | [] ->
+ (match failures with
+ | [] -> evd
+ | ((mv,status,c),e)::_ -> raise e)
+ in process_eqns [] eqns
+
and mimick_undefined_evar evd flags hdc nargs sp =
let ev = Evd.find_undefined evd sp in
let sp_env = reset_with_named_context (evar_filtered_hyps ev) env in
@@ -1448,7 +1448,7 @@ let w_merge env with_types flags (evd,metas,evars : subst0) =
then Evd.define sp c evd'''
else Evd.define sp (Evarutil.nf_evar evd''' c) evd''' in
- let check_types evd =
+ let check_types evd =
let metas = Evd.meta_list evd in
let eqns = List.fold_left (fun acc (mv, b) ->
match b with
@@ -1740,17 +1740,17 @@ let make_abstraction env evd ccl abs =
(make_eq_test env evd c)
env evd c ty occs check_occs ccl
-let keyed_unify env evd kop =
+let keyed_unify env evd kop =
if not !keyed_unification then fun cl -> true
- else
- match kop with
+ else
+ match kop with
| None -> fun _ -> true
| Some kop ->
fun cl ->
- let kc = Keys.constr_key (fun c -> EConstr.kind evd c) cl in
- match kc with
- | None -> false
- | Some kc -> Keys.equiv_keys kop kc
+ let kc = Keys.constr_key (fun c -> EConstr.kind evd c) cl in
+ match kc with
+ | None -> false
+ | Some kc -> Keys.equiv_keys kop kc
(* Tries to find an instance of term [cl] in term [op].
Unifies [cl] to every subterm of [op] until it finds a match.
@@ -1765,59 +1765,59 @@ let w_unify_to_subterm env evd ?(flags=default_unify_flags ()) (op,cl) =
(try
if !keyed_unification then
let f1, l1 = decompose_app_vect evd op in
- let f2, l2 = decompose_app_vect evd cl in
- w_typed_unify_array env evd flags f1 l1 f2 l2,cl
- else w_typed_unify env evd CONV flags op cl,cl
+ let f2, l2 = decompose_app_vect evd cl in
+ w_typed_unify_array env evd flags f1 l1 f2 l2,cl
+ else w_typed_unify env evd CONV flags op cl,cl
with ex when Pretype_errors.unsatisfiable_exception ex ->
- bestexn := Some ex; user_err Pp.(str "Unsat"))
+ bestexn := Some ex; user_err Pp.(str "Unsat"))
else user_err Pp.(str "Bound 1")
with ex when precatchable_exception ex ->
(match EConstr.kind evd cl with
- | App (f,args) ->
- let n = Array.length args in
- assert (n>0);
- let c1 = mkApp (f,Array.sub args 0 (n-1)) in
- let c2 = args.(n-1) in
- (try
- matchrec c1
- with ex when precatchable_exception ex ->
- matchrec c2)
+ | App (f,args) ->
+ let n = Array.length args in
+ assert (n>0);
+ let c1 = mkApp (f,Array.sub args 0 (n-1)) in
+ let c2 = args.(n-1) in
+ (try
+ matchrec c1
+ with ex when precatchable_exception ex ->
+ matchrec c2)
| Case(_,_,c,lf) -> (* does not search in the predicate *)
- (try
- matchrec c
- with ex when precatchable_exception ex ->
- iter_fail matchrec lf)
+ (try
+ matchrec c
+ with ex when precatchable_exception ex ->
+ iter_fail matchrec lf)
| LetIn(_,c1,_,c2) ->
- (try
- matchrec c1
- with ex when precatchable_exception ex ->
- matchrec c2)
+ (try
+ matchrec c1
+ with ex when precatchable_exception ex ->
+ matchrec c2)
- | Proj (p,c) -> matchrec c
+ | Proj (p,c) -> matchrec c
| Fix(_,(_,types,terms)) ->
- (try
- iter_fail matchrec types
- with ex when precatchable_exception ex ->
- iter_fail matchrec terms)
+ (try
+ iter_fail matchrec types
+ with ex when precatchable_exception ex ->
+ iter_fail matchrec terms)
| CoFix(_,(_,types,terms)) ->
- (try
- iter_fail matchrec types
- with ex when precatchable_exception ex ->
- iter_fail matchrec terms)
+ (try
+ iter_fail matchrec types
+ with ex when precatchable_exception ex ->
+ iter_fail matchrec terms)
| Prod (_,t,c) ->
- (try
- matchrec t
- with ex when precatchable_exception ex ->
- matchrec c)
+ (try
+ matchrec t
+ with ex when precatchable_exception ex ->
+ matchrec c)
| Lambda (_,t,c) ->
- (try
- matchrec t
- with ex when precatchable_exception ex ->
- matchrec c)
+ (try
+ matchrec t
+ with ex when precatchable_exception ex ->
+ matchrec c)
| Cast (_, _, _) (* Is this expected? *)
| Rel _ | Var _ | Meta _ | Evar _ | Sort _ | Const _ | Ind _
@@ -1856,36 +1856,36 @@ let w_unify_to_subterm_all env evd ?(flags=default_unify_flags ()) (op,cl) =
let rec matchrec cl =
let cl = strip_outer_cast evd cl in
(bind
- (if closed0 evd cl
- then return (fun () -> w_typed_unify env evd CONV flags op cl,cl)
+ (if closed0 evd cl
+ then return (fun () -> w_typed_unify env evd CONV flags op cl,cl)
else fail "Bound 1")
(match EConstr.kind evd cl with
- | App (f,args) ->
- let n = Array.length args in
- assert (n>0);
- let c1 = mkApp (f,Array.sub args 0 (n-1)) in
- let c2 = args.(n-1) in
- bind (matchrec c1) (matchrec c2)
+ | App (f,args) ->
+ let n = Array.length args in
+ assert (n>0);
+ let c1 = mkApp (f,Array.sub args 0 (n-1)) in
+ let c2 = args.(n-1) in
+ bind (matchrec c1) (matchrec c2)
| Case(_,_,c,lf) -> (* does not search in the predicate *)
- bind (matchrec c) (bind_iter matchrec lf)
+ bind (matchrec c) (bind_iter matchrec lf)
- | Proj (p,c) -> matchrec c
+ | Proj (p,c) -> matchrec c
| LetIn(_,c1,_,c2) ->
- bind (matchrec c1) (matchrec c2)
+ bind (matchrec c1) (matchrec c2)
| Fix(_,(_,types,terms)) ->
- bind (bind_iter matchrec types) (bind_iter matchrec terms)
+ bind (bind_iter matchrec types) (bind_iter matchrec terms)
| CoFix(_,(_,types,terms)) ->
- bind (bind_iter matchrec types) (bind_iter matchrec terms)
+ bind (bind_iter matchrec types) (bind_iter matchrec terms)
| Prod (_,t,c) ->
- bind (matchrec t) (matchrec c)
+ bind (matchrec t) (matchrec c)
| Lambda (_,t,c) ->
- bind (matchrec t) (matchrec c)
+ bind (matchrec t) (matchrec c)
| Cast (_, _, _) -> fail "Match_subterm" (* Is this expected? *)
@@ -1904,13 +1904,13 @@ let w_unify_to_subterm_list env evd flags hdmeta oplist t =
(fun op (evd,l) ->
let op = whd_meta evd op in
if isMeta evd op then
- if flags.allow_K_in_toplevel_higher_order_unification then (evd,op::l)
- else error_abstraction_over_meta env evd hdmeta (destMeta evd op)
+ if flags.allow_K_in_toplevel_higher_order_unification then (evd,op::l)
+ else error_abstraction_over_meta env evd hdmeta (destMeta evd op)
else
let allow_K = flags.allow_K_in_toplevel_higher_order_unification in
let flags =
if unsafe_occur_meta_or_existential op || !keyed_unification then
- (* This is up to delta for subterms w/o metas ... *)
+ (* This is up to delta for subterms w/o metas ... *)
flags
else
(* up to Nov 2014, unification was bypassed on evar/meta-free terms;
@@ -1918,29 +1918,29 @@ let w_unify_to_subterm_list env evd flags hdmeta oplist t =
unify pre-existing non frozen evars of the goal or of the
pattern *)
set_no_delta_flags flags in
- let t' = (strip_outer_cast evd op,t) in
+ let t' = (strip_outer_cast evd op,t) in
let (evd',cl) =
try
- if is_keyed_unification () then
- try (* First try finding a subterm w/o conversion on open terms *)
- let flags = set_no_delta_open_flags flags in
- w_unify_to_subterm env evd ~flags t'
- with e ->
- (* If this fails, try with full conversion *)
- w_unify_to_subterm env evd ~flags t'
- else w_unify_to_subterm env evd ~flags t'
- with PretypeError (env,_,NoOccurrenceFound _) when
+ if is_keyed_unification () then
+ try (* First try finding a subterm w/o conversion on open terms *)
+ let flags = set_no_delta_open_flags flags in
+ w_unify_to_subterm env evd ~flags t'
+ with e ->
+ (* If this fails, try with full conversion *)
+ w_unify_to_subterm env evd ~flags t'
+ else w_unify_to_subterm env evd ~flags t'
+ with PretypeError (env,_,NoOccurrenceFound _) when
allow_K ||
(* w_unify_to_subterm does not go through evars, so
the next step, which was already in <= 8.4, is
needed at least for compatibility of rewrite *)
dependent evd op t -> (evd,op)
in
- if not allow_K &&
+ if not allow_K &&
(* ensure we found a different instance *)
- List.exists (fun op -> EConstr.eq_constr evd' op cl) l
- then error_non_linear_unification env evd hdmeta cl
- else (evd',cl::l))
+ List.exists (fun op -> EConstr.eq_constr evd' op cl) l
+ then error_non_linear_unification env evd hdmeta cl
+ else (evd',cl::l))
oplist
(evd,[])
@@ -2008,29 +2008,29 @@ let w_unify env evd cv_pb ?(flags=default_unify_flags ()) ty1 ty2 =
match EConstr.kind evd hd1, not is_empty1, EConstr.kind evd hd2, not is_empty2 with
(* Pattern case *)
| (Meta _, true, Lambda _, _ | Lambda _, _, Meta _, true)
- when Int.equal (Array.length l1) (Array.length l2) ->
- (try
- w_typed_unify_array env evd flags hd1 l1 hd2 l2
- with ex when precatchable_exception ex ->
- try
- w_unify2 env evd flags false cv_pb ty1 ty2
- with PretypeError (env,_,NoOccurrenceFound _) as e -> raise e)
+ when Int.equal (Array.length l1) (Array.length l2) ->
+ (try
+ w_typed_unify_array env evd flags hd1 l1 hd2 l2
+ with ex when precatchable_exception ex ->
+ try
+ w_unify2 env evd flags false cv_pb ty1 ty2
+ with PretypeError (env,_,NoOccurrenceFound _) as e -> raise e)
(* Second order case *)
| (Meta _, true, _, _ | _, _, Meta _, true) ->
- (try
- w_unify2 env evd flags false cv_pb ty1 ty2
- with PretypeError (env,_,NoOccurrenceFound _) as e -> raise e
- | ex when precatchable_exception ex ->
- try
- w_typed_unify_array env evd flags hd1 l1 hd2 l2
- with ex' when precatchable_exception ex' ->
+ (try
+ w_unify2 env evd flags false cv_pb ty1 ty2
+ with PretypeError (env,_,NoOccurrenceFound _) as e -> raise e
+ | ex when precatchable_exception ex ->
+ try
+ w_typed_unify_array env evd flags hd1 l1 hd2 l2
+ with ex' when precatchable_exception ex' ->
(* Last chance, use pattern-matching with typed
dependencies (done late for compatibility) *)
- try
- w_unify2 env evd flags true cv_pb ty1 ty2
- with ex' when precatchable_exception ex' ->
- raise ex)
+ try
+ w_unify2 env evd flags true cv_pb ty1 ty2
+ with ex' when precatchable_exception ex' ->
+ raise ex)
(* General case: try first order *)
| _ -> w_typed_unify env evd cv_pb flags ty1 ty2
@@ -2040,7 +2040,7 @@ let w_unify env evd cv_pb ?(flags=default_unify_flags ()) ty1 ty2 =
let w_unify env evd cv_pb flags ty1 ty2 =
w_unify env evd cv_pb ~flags:flags ty1 ty2
-let w_unify =
+let w_unify =
if Flags.profile then
let wunifkey = CProfile.declare_profile "w_unify" in
CProfile.profile6 wunifkey w_unify
diff --git a/pretyping/unification.mli b/pretyping/unification.mli
index d7ddbcb721..e66234b4ae 100644
--- a/pretyping/unification.mli
+++ b/pretyping/unification.mli
@@ -121,7 +121,7 @@ val unify_0 : Environ.env ->
types ->
subst0
-val unify_0_with_initial_metas :
+val unify_0_with_initial_metas :
subst0 ->
bool ->
Environ.env ->
diff --git a/pretyping/vnorm.ml b/pretyping/vnorm.ml
index d15eb578c3..885fc8980d 100644
--- a/pretyping/vnorm.ml
+++ b/pretyping/vnorm.ml
@@ -50,7 +50,7 @@ let invert_tag cst tag reloc_tbl =
let tagj,arity = reloc_tbl.(j) in
let no_arity = Int.equal arity 0 in
if Int.equal tag tagj && (cst && no_arity || not (cst || no_arity)) then
- raise (Find_at j)
+ raise (Find_at j)
else ()
done;raise Not_found
with Find_at j -> (j+1)
@@ -161,9 +161,9 @@ and nf_whd env sigma whd typ =
let tag = btag b in
let (tag,ofs) =
if tag = Obj.last_non_constant_constructor_tag then
- match whd_val (bfield b 0) with
+ match whd_val (bfield b 0) with
| Vconstr_const tag -> (tag+Obj.last_non_constant_constructor_tag, 1)
- | _ -> assert false
+ | _ -> assert false
else (tag, 0) in
let capp,ctyp = construct_of_constr_block env tag typ in
let args = nf_bargs env sigma b ofs ctyp in
@@ -248,11 +248,11 @@ and nf_stk ?from:(from=0) env sigma c t stk =
| [] -> c
| Zapp vargs :: stk ->
if nargs vargs >= from then
- let t, args = nf_args ~from:from env sigma vargs t in
- nf_stk env sigma (mkApp(c,args)) t stk
+ let t, args = nf_args ~from:from env sigma vargs t in
+ nf_stk env sigma (mkApp(c,args)) t stk
else
- let rest = from - nargs vargs in
- nf_stk ~from:rest env sigma c t stk
+ let rest = from - nargs vargs in
+ nf_stk ~from:rest env sigma c t stk
| Zfix (f,vargs) :: stk ->
assert (from = 0) ;
let fa, typ = nf_fix_app env sigma f vargs in
@@ -273,8 +273,8 @@ and nf_stk ?from:(from=0) env sigma c t stk =
(* calcul des branches *)
let bsw = branch_of_switch (nb_rel env) sw in
let mkbranch i (n,v) =
- let decl,decl_with_letin,codom = btypes.(i) in
- let b = nf_val (Termops.push_rels_assum decl env) sigma v codom in
+ let decl,decl_with_letin,codom = btypes.(i) in
+ let b = nf_val (Termops.push_rels_assum decl env) sigma v codom in
Termops.it_mkLambda_or_LetIn_from_no_LetIn b decl_with_letin
in
let branchs = Array.mapi mkbranch bsw in
@@ -299,7 +299,7 @@ and nf_predicate env sigma ind mip params v pT =
let k = nb_rel env in
let vb = reduce_fun k f in
let body =
- nf_predicate (push_rel (LocalAssum (name,dom)) env) sigma ind mip params vb codom in
+ nf_predicate (push_rel (LocalAssum (name,dom)) env) sigma ind mip params vb codom in
mkLambda(name,dom,body)
| _ -> assert false
end
@@ -326,8 +326,8 @@ and nf_args env sigma vargs ?from:(f=0) t =
Array.init len
(fun i ->
let _,dom,codom = decompose_prod env !t in
- let c = nf_val env sigma (arg vargs (f+i)) dom in
- t := subst1 c codom; c) in
+ let c = nf_val env sigma (arg vargs (f+i)) dom in
+ t := subst1 c codom; c) in
!t,args
and nf_bargs env sigma b ofs t =
@@ -337,8 +337,8 @@ and nf_bargs env sigma b ofs t =
Array.init len
(fun i ->
let _,dom,codom = decompose_prod env !t in
- let c = nf_val env sigma (bfield b (i+ofs)) dom in
- t := subst1 c codom; c) in
+ let c = nf_val env sigma (bfield b (i+ofs)) dom in
+ t := subst1 c codom; c) in
args
and nf_fun env sigma f typ =