diff options
| author | Emilio Jesus Gallego Arias | 2019-06-06 15:10:50 +0200 |
|---|---|---|
| committer | Emilio Jesus Gallego Arias | 2019-06-24 20:55:09 +0200 |
| commit | 9d65c49f05f946557df4c67b6e752f978e1e9352 (patch) | |
| tree | dcae68792a86c166f31b9e9706a0bbed63ef12c2 /tactics | |
| parent | b2aae7ba35a90e695d34f904c74f5156385344a9 (diff) | |
[api] Remove `polymorphic` type alias, use labels instead.
This is more in-line with attributes and the rest of the API, and
makes some code significantly clearer (as in `foo true false false`,
etc...)
Diffstat (limited to 'tactics')
| -rw-r--r-- | tactics/auto.ml | 18 | ||||
| -rw-r--r-- | tactics/auto.mli | 7 | ||||
| -rw-r--r-- | tactics/class_tactics.ml | 10 | ||||
| -rw-r--r-- | tactics/declare.ml | 18 | ||||
| -rw-r--r-- | tactics/declare.mli | 8 | ||||
| -rw-r--r-- | tactics/eauto.ml | 6 | ||||
| -rw-r--r-- | tactics/hints.ml | 52 | ||||
| -rw-r--r-- | tactics/hints.mli | 39 |
8 files changed, 84 insertions, 74 deletions
diff --git a/tactics/auto.ml b/tactics/auto.ml index 339d4de2a0..499e7a63d7 100644 --- a/tactics/auto.ml +++ b/tactics/auto.ml @@ -69,7 +69,7 @@ let auto_unif_flags = (* Try unification with the precompiled clause, then use registered Apply *) -let connect_hint_clenv poly (c, _, ctx) clenv gl = +let connect_hint_clenv ~poly (c, _, ctx) clenv gl = (* [clenv] has been generated by a hint-making function, so the only relevant data in its evarmap is the set of metas. The [evar_reset_evd] function below just replaces the metas of sigma by those coming from the clenv. *) @@ -95,22 +95,22 @@ let connect_hint_clenv poly (c, _, ctx) clenv gl = { clenv with evd = evd ; env = Proofview.Goal.env gl }, c in clenv, c -let unify_resolve poly flags ((c : raw_hint), clenv) = +let unify_resolve ~poly flags ((c : raw_hint), clenv) = Proofview.Goal.enter begin fun gl -> - let clenv, c = connect_hint_clenv poly c clenv gl in + let clenv, c = connect_hint_clenv ~poly c clenv gl in let clenv = clenv_unique_resolver ~flags clenv gl in Clenvtac.clenv_refine clenv end -let unify_resolve_nodelta poly h = unify_resolve poly auto_unif_flags h +let unify_resolve_nodelta poly h = unify_resolve ~poly auto_unif_flags h -let unify_resolve_gen poly = function +let unify_resolve_gen ~poly = function | None -> unify_resolve_nodelta poly - | Some flags -> unify_resolve poly flags + | Some flags -> unify_resolve ~poly flags let exact poly (c,clenv) = Proofview.Goal.enter begin fun gl -> - let clenv', c = connect_hint_clenv poly c clenv gl in + let clenv', c = connect_hint_clenv ~poly c clenv gl in Tacticals.New.tclTHEN (Proofview.Unsafe.tclEVARUNIVCONTEXT (Evd.evar_universe_context clenv'.evd)) (exact_check c) @@ -378,12 +378,12 @@ and my_find_search_delta sigma db_list local_db secvars hdc concl = and tac_of_hint dbg db_list local_db concl (flags, ({pat=p; code=t;poly=poly;db=dbname})) = let tactic = function - | Res_pf (c,cl) -> unify_resolve_gen poly flags (c,cl) + | Res_pf (c,cl) -> unify_resolve_gen ~poly flags (c,cl) | ERes_pf _ -> Proofview.Goal.enter (fun gl -> Tacticals.New.tclZEROMSG (str "eres_pf")) | Give_exact (c, cl) -> exact poly (c, cl) | Res_pf_THEN_trivial_fail (c,cl) -> Tacticals.New.tclTHEN - (unify_resolve_gen poly flags (c,cl)) + (unify_resolve_gen ~poly flags (c,cl)) (* With "(debug) trivial", we shouldn't end here, and with "debug auto" we don't display the details of inner trivial *) (trivial_fail_db (no_dbg dbg) (not (Option.is_empty flags)) db_list local_db) diff --git a/tactics/auto.mli b/tactics/auto.mli index a834b4b12d..5ae63be539 100644 --- a/tactics/auto.mli +++ b/tactics/auto.mli @@ -14,7 +14,6 @@ open Names open EConstr open Clenv open Pattern -open Decl_kinds open Hints open Tactypes @@ -24,11 +23,11 @@ val default_search_depth : int ref val auto_flags_of_state : TransparentState.t -> Unification.unify_flags -val connect_hint_clenv : polymorphic -> raw_hint -> clausenv -> - Proofview.Goal.t -> clausenv * constr +val connect_hint_clenv + : poly:bool -> raw_hint -> clausenv -> Proofview.Goal.t -> clausenv * constr (** Try unification with the precompiled clause, then use registered Apply *) -val unify_resolve : polymorphic -> Unification.unify_flags -> (raw_hint * clausenv) -> unit Proofview.tactic +val unify_resolve : poly:bool -> Unification.unify_flags -> (raw_hint * clausenv) -> unit Proofview.tactic (** [ConclPattern concl pat tacast]: if the term concl matches the pattern pat, (in sense of diff --git a/tactics/class_tactics.ml b/tactics/class_tactics.ml index b0fb47726a..303ddacb67 100644 --- a/tactics/class_tactics.ml +++ b/tactics/class_tactics.ml @@ -204,11 +204,11 @@ let clenv_unique_resolver_tac with_evars ~flags clenv' = end let unify_e_resolve poly flags = begin fun gls (c,_,clenv) -> - let clenv', c = connect_hint_clenv poly c clenv gls in + let clenv', c = connect_hint_clenv ~poly c clenv gls in clenv_unique_resolver_tac true ~flags clenv' end let unify_resolve poly flags = begin fun gls (c,_,clenv) -> - let clenv', _ = connect_hint_clenv poly c clenv gls in + let clenv', _ = connect_hint_clenv ~poly c clenv gls in clenv_unique_resolver_tac false ~flags clenv' end @@ -536,7 +536,7 @@ let make_resolve_hyp env sigma st flags only_classes pri decl = (List.map_append (fun (path,info,c) -> make_resolves env sigma ~name:(PathHints path) - (true,false,not !Flags.quiet) info false + (true,false,not !Flags.quiet) info ~poly:false (IsConstr (EConstr.of_constr c,Univ.ContextSet.empty))) hints) else [] @@ -544,8 +544,8 @@ let make_resolve_hyp env sigma st flags only_classes pri decl = (hints @ List.map_filter (fun f -> try Some (f (c, cty, Univ.ContextSet.empty)) with Failure _ | UserError _ -> None) - [make_exact_entry ~name env sigma pri false; - make_apply_entry ~name env sigma flags pri false]) + [make_exact_entry ~name env sigma pri ~poly:false; + make_apply_entry ~name env sigma flags pri ~poly:false]) else [] let make_hints g (modes,st) only_classes sign = diff --git a/tactics/declare.ml b/tactics/declare.ml index 02253e70bf..081c3a4b6a 100644 --- a/tactics/declare.ml +++ b/tactics/declare.ml @@ -98,7 +98,7 @@ let cache_constant ((sp,kn), obj) = assert (Constant.equal kn' (Constant.make1 kn)); Nametab.push (Nametab.Until 1) sp (ConstRef (Constant.make1 kn)); let cst = Global.lookup_constant kn' in - add_section_constant (Declareops.constant_is_polymorphic cst) kn' cst.const_hyps; + add_section_constant ~poly:(Declareops.constant_is_polymorphic cst) kn' cst.const_hyps; add_constant_kind (Constant.make1 kn) obj.cst_kind let discharge_constant ((sp, kn), obj) = @@ -264,7 +264,7 @@ let declare_definition ?(internal=UserIndividualRequest) (** Declaration of section variables and local definitions *) type section_variable_entry = | SectionLocalDef of Evd.side_effects Proof_global.proof_entry - | SectionLocalAssum of types Univ.in_universe_context_set * polymorphic * bool (** Implicit status *) + | SectionLocalAssum of types Univ.in_universe_context_set * bool (* polymorphic *) * bool (* Implicit status *) type variable_declaration = DirPath.t * section_variable_entry * logical_kind @@ -307,7 +307,7 @@ let cache_variable ((sp,_),o) = Explicit, de.proof_entry_opaque, poly, univs in Nametab.push (Nametab.Until 1) (restrict_path 0 sp) (VarRef id); - add_section_variable id impl poly ctx; + add_section_variable ~name:id ~kind:impl ~poly ctx; add_variable_data id (p,opaq,ctx,poly,mk) let discharge_variable (_,o) = match o with @@ -376,7 +376,7 @@ let cache_inductive ((sp,kn),mie) = let kn' = Global.add_mind id mie in assert (MutInd.equal kn' (MutInd.make1 kn)); let mind = Global.lookup_mind kn' in - add_section_kn (Declareops.inductive_is_polymorphic mind) kn' mind.mind_hyps; + add_section_kn ~poly:(Declareops.inductive_is_polymorphic mind) kn' mind.mind_hyps; List.iter (fun (sp, ref) -> Nametab.push (Nametab.Until 1) sp ref) names let discharge_inductive ((sp,kn),mie) = @@ -527,7 +527,7 @@ let input_universe_context : Univ.ContextSet.t -> Libobject.obj = ~cache:(fun (na, uctx) -> Global.push_context_set false uctx) ~discharge:(fun (_, x) -> Some x) -let declare_universe_context poly ctx = +let declare_universe_context ~poly ctx = if poly then (Global.push_context_set true ctx; Lib.add_section_context ctx) else @@ -607,7 +607,7 @@ let declare_univ_binders gr pl = in Lib.add_anonymous_leaf (input_univ_names (QualifiedUniv l, univs)) -let do_universe poly l = +let do_universe ~poly l = let in_section = Lib.sections_are_opened () in let () = if poly && not in_section then @@ -618,11 +618,11 @@ let do_universe poly l = let ctx = List.fold_left (fun ctx (_,qid) -> Univ.LSet.add (Univ.Level.make qid) ctx) Univ.LSet.empty l, Univ.Constraint.empty in - let () = declare_universe_context poly ctx in + let () = declare_universe_context ~poly ctx in let src = if poly then BoundUniv else UnqualifiedUniv in Lib.add_anonymous_leaf (input_univ_names (src, l)) -let do_constraint poly l = +let do_constraint ~poly l = let open Univ in let u_of_id x = let level = Pretyping.interp_known_glob_level (Evd.from_env (Global.env ())) x in @@ -649,4 +649,4 @@ let do_constraint poly l = Constraint.empty l in let uctx = ContextSet.add_constraints constraints ContextSet.empty in - declare_universe_context poly uctx + declare_universe_context ~poly uctx diff --git a/tactics/declare.mli b/tactics/declare.mli index bdb5af7430..247c92bc5b 100644 --- a/tactics/declare.mli +++ b/tactics/declare.mli @@ -24,7 +24,7 @@ open Decl_kinds type section_variable_entry = | SectionLocalDef of Evd.side_effects Proof_global.proof_entry - | SectionLocalAssum of types Univ.in_universe_context_set * polymorphic * bool (** Implicit status *) + | SectionLocalAssum of types Univ.in_universe_context_set * bool (* polymorphic *) * bool (* Implicit status *) type 'a constant_entry = | DefinitionEntry of 'a Proof_global.proof_entry @@ -94,7 +94,7 @@ val exists_name : Id.t -> bool (** Global universe contexts, names and constraints *) val declare_univ_binders : GlobRef.t -> UnivNames.universe_binders -> unit -val declare_universe_context : polymorphic -> Univ.ContextSet.t -> unit +val declare_universe_context : poly:bool -> Univ.ContextSet.t -> unit -val do_universe : polymorphic -> lident list -> unit -val do_constraint : polymorphic -> Glob_term.glob_constraint list -> unit +val do_universe : poly:bool -> lident list -> unit +val do_constraint : poly:bool -> Glob_term.glob_constraint list -> unit diff --git a/tactics/eauto.ml b/tactics/eauto.ml index ac6253cf40..cc3e78f3b8 100644 --- a/tactics/eauto.ml +++ b/tactics/eauto.ml @@ -113,7 +113,7 @@ let priority l = List.map snd (List.filter (fun (pr,_) -> Int.equal pr 0) l) let unify_e_resolve poly flags (c,clenv) = Proofview.Goal.enter begin fun gl -> - let clenv', c = connect_hint_clenv poly c clenv gl in + let clenv', c = connect_hint_clenv ~poly c clenv gl in let clenv' = clenv_unique_resolver ~flags clenv' gl in Proofview.tclTHEN (Proofview.Unsafe.tclEVARUNIVCONTEXT (Evd.evar_universe_context clenv'.evd)) @@ -131,7 +131,7 @@ let hintmap_of sigma secvars hdc concl = let e_exact poly flags (c,clenv) = Proofview.Goal.enter begin fun gl -> - let clenv', c = connect_hint_clenv poly c clenv gl in + let clenv', c = connect_hint_clenv ~poly c clenv gl in Tacticals.New.tclTHEN (Proofview.Unsafe.tclEVARUNIVCONTEXT (Evd.evar_universe_context clenv'.evd)) (e_give_exact c) @@ -168,7 +168,7 @@ and e_my_find_search env sigma db_list local_db secvars hdc concl = in (b, let tac = function - | Res_pf (term,cl) -> unify_resolve poly st (term,cl) + | Res_pf (term,cl) -> unify_resolve ~poly st (term,cl) | ERes_pf (term,cl) -> unify_e_resolve poly st (term,cl) | Give_exact (c,cl) -> e_exact poly st (c,cl) | Res_pf_THEN_trivial_fail (term,cl) -> diff --git a/tactics/hints.ml b/tactics/hints.ml index e824c4bd64..014e54158d 100644 --- a/tactics/hints.ml +++ b/tactics/hints.ml @@ -27,7 +27,6 @@ open Smartlocate open Termops open Inductiveops open Typing -open Decl_kinds open Typeclasses open Pattern open Patternops @@ -142,15 +141,22 @@ type raw_hint = constr * types * Univ.ContextSet.t type hint = (raw_hint * clausenv) hint_ast with_uid -type 'a with_metadata = { - pri : int; (* A number lower is higher priority *) - poly : polymorphic; (** Is the hint polymorpic and hence should be refreshed at each application *) - pat : constr_pattern option; (* A pattern for the concl of the Goal *) - name : hints_path_atom; (* A potential name to refer to the hint *) - db : string option; (** The database from which the hint comes *) - secvars : Id.Pred.t; (* The set of section variables the hint depends on *) - code : 'a; (* the tactic to apply when the concl matches pat *) -} +type 'a with_metadata = + { pri : int + (** A number lower is higher priority *) + ; poly : bool + (** Is the hint polymorpic and hence should be refreshed at each application *) + ; pat : constr_pattern option + (** A pattern for the concl of the Goal *) + ; name : hints_path_atom + (** A potential name to refer to the hint *) + ; db : string option + (** The database from which the hint comes *) + ; secvars : Id.Pred.t + (** The set of section variables the hint depends on *) + ; code : 'a + (** the tactic to apply when the concl matches pat *) + } type full_hint = hint with_metadata @@ -792,7 +798,7 @@ let secvars_of_constr env sigma c = let secvars_of_global env gr = secvars_of_idset (vars_of_global env gr) -let make_exact_entry env sigma info poly ?(name=PathAny) (c, cty, ctx) = +let make_exact_entry env sigma info ~poly ?(name=PathAny) (c, cty, ctx) = let secvars = secvars_of_constr env sigma c in let cty = strip_outer_cast sigma cty in match EConstr.kind sigma cty with @@ -813,7 +819,7 @@ let make_exact_entry env sigma info poly ?(name=PathAny) (c, cty, ctx) = db = None; secvars; code = with_uid (Give_exact (c, cty, ctx)); }) -let make_apply_entry env sigma (eapply,hnf,verbose) info poly ?(name=PathAny) (c, cty, ctx) = +let make_apply_entry env sigma (eapply,hnf,verbose) info ~poly ?(name=PathAny) (c, cty, ctx) = let cty = if hnf then hnf_constr env sigma cty else cty in match EConstr.kind sigma cty with | Prod _ -> @@ -887,18 +893,18 @@ let fresh_global_or_constr env sigma poly cr = else begin if isgr then warn_polymorphic_hint (pr_hint_term env sigma ctx cr); - Declare.declare_universe_context false ctx; + Declare.declare_universe_context ~poly:false ctx; (c, Univ.ContextSet.empty) end -let make_resolves env sigma flags info poly ?name cr = +let make_resolves env sigma flags info ~poly ?name cr = let c, ctx = fresh_global_or_constr env sigma poly cr in let cty = Retyping.get_type_of env sigma c in let try_apply f = try Some (f (c, cty, ctx)) with Failure _ -> None in let ents = List.map_filter try_apply - [make_exact_entry env sigma info poly ?name; - make_apply_entry env sigma flags info poly ?name] + [make_exact_entry env sigma info ~poly ?name; + make_apply_entry env sigma flags info ~poly ?name] in if List.is_empty ents then user_err ~hdr:"Hint" @@ -912,7 +918,7 @@ let make_resolve_hyp env sigma decl = let hname = NamedDecl.get_id decl in let c = mkVar hname in try - [make_apply_entry env sigma (true, true, false) empty_hint_info false + [make_apply_entry env sigma (true, true, false) empty_hint_info ~poly:false ~name:(PathHints [VarRef hname]) (c, NamedDecl.get_type decl, Univ.ContextSet.empty)] with @@ -1178,7 +1184,7 @@ let add_resolves env sigma clist local dbnames = let r = List.flatten (List.map (fun (pri, poly, hnf, path, gr) -> make_resolves env sigma (true,hnf,not !Flags.quiet) - pri poly ~name:path gr) clist) + pri ~poly ~name:path gr) clist) in let hint = make_hint ~local dbname (AddHints r) in Lib.add_anonymous_leaf (inAutoHint hint)) @@ -1238,8 +1244,8 @@ type hnf = bool type nonrec hint_info = hint_info type hints_entry = - | HintsResolveEntry of (hint_info * polymorphic * hnf * hints_path_atom * hint_term) list - | HintsImmediateEntry of (hints_path_atom * polymorphic * hint_term) list + | HintsResolveEntry of (hint_info * bool * hnf * hints_path_atom * hint_term) list + | HintsImmediateEntry of (hints_path_atom * bool * hint_term) list | HintsCutEntry of hints_path | HintsUnfoldEntry of evaluable_global_reference list | HintsTransparencyEntry of evaluable_global_reference hints_transparency_target * bool @@ -1286,7 +1292,7 @@ let prepare_hint check (poly,local) env init (sigma,c) = let diff = Univ.ContextSet.diff (Evd.universe_context_set sigma) (Evd.universe_context_set init) in if poly then IsConstr (c', diff) else if local then IsConstr (c', diff) - else (Declare.declare_universe_context false diff; + else (Declare.declare_universe_context ~poly:false diff; IsConstr (c', Univ.ContextSet.empty)) let project_hint ~poly pri l2r r = @@ -1318,7 +1324,7 @@ let project_hint ~poly pri l2r r = let info = {Typeclasses.hint_priority = pri; hint_pattern = None} in (info,false,true,PathAny, IsGlobRef (Globnames.ConstRef c)) -let interp_hints poly = +let interp_hints ~poly = fun h -> let env = Global.env () in let sigma = Evd.from_env env in @@ -1417,7 +1423,7 @@ let expand_constructor_hints env sigma lems = let constructor_hints env sigma eapply lems = let lems = expand_constructor_hints env sigma lems in List.map_append (fun (poly, lem) -> - make_resolves env sigma (eapply,true,false) empty_hint_info poly lem) lems + make_resolves env sigma (eapply,true,false) empty_hint_info ~poly lem) lems let make_local_hint_db env sigma ts eapply lems = let map c = c env sigma in diff --git a/tactics/hints.mli b/tactics/hints.mli index 839ef31189..4c82a068b1 100644 --- a/tactics/hints.mli +++ b/tactics/hints.mli @@ -12,7 +12,6 @@ open Util open Names open EConstr open Environ -open Decl_kinds open Evd open Tactypes open Clenv @@ -54,15 +53,22 @@ type 'a hints_path_atom_gen = type hints_path_atom = GlobRef.t hints_path_atom_gen type hint_db_name = string -type 'a with_metadata = private { - pri : int; (** A number between 0 and 4, 4 = lower priority *) - poly : polymorphic; (** Is the hint polymorpic and hence should be refreshed at each application *) - pat : constr_pattern option; (** A pattern for the concl of the Goal *) - name : hints_path_atom; (** A potential name to refer to the hint *) - db : hint_db_name option; - secvars : Id.Pred.t; (** The section variables this hint depends on, as a predicate *) - code : 'a; (** the tactic to apply when the concl matches pat *) -} +type 'a with_metadata = private + { pri : int + (** A number lower is higher priority *) + ; poly : bool + (** Is the hint polymorpic and hence should be refreshed at each application *) + ; pat : constr_pattern option + (** A pattern for the concl of the Goal *) + ; name : hints_path_atom + (** A potential name to refer to the hint *) + ; db : string option + (** The database from which the hint comes *) + ; secvars : Id.Pred.t + (** The set of section variables the hint depends on *) + ; code : 'a + (** the tactic to apply when the concl matches pat *) + } type full_hint = hint with_metadata @@ -176,9 +182,8 @@ type hint_term = | IsConstr of constr * Univ.ContextSet.t type hints_entry = - | HintsResolveEntry of - (hint_info * polymorphic * hnf * hints_path_atom * hint_term) list - | HintsImmediateEntry of (hints_path_atom * polymorphic * hint_term) list + | HintsResolveEntry of (hint_info * bool * hnf * hints_path_atom * hint_term) list + | HintsImmediateEntry of (hints_path_atom * bool * hint_term) list | HintsCutEntry of hints_path | HintsUnfoldEntry of evaluable_global_reference list | HintsTransparencyEntry of evaluable_global_reference hints_transparency_target * bool @@ -202,7 +207,7 @@ val current_db_names : unit -> String.Set.t val current_pure_db : unit -> hint_db list -val interp_hints : polymorphic -> hints_expr -> hints_entry +val interp_hints : poly:bool -> hints_expr -> hints_entry val add_hints : local:bool -> hint_db_name list -> hints_entry -> unit @@ -219,7 +224,7 @@ val prepare_hint : bool (* Check no remaining evars *) -> [hint_pattern] is the hint's desired pattern, it is inferred if not specified *) -val make_exact_entry : env -> evar_map -> hint_info -> polymorphic -> ?name:hints_path_atom -> +val make_exact_entry : env -> evar_map -> hint_info -> poly:bool -> ?name:hints_path_atom -> (constr * types * Univ.ContextSet.t) -> hint_entry (** [make_apply_entry (eapply,hnf,verbose) info (c,cty,ctx))]. @@ -237,7 +242,7 @@ val make_exact_entry : env -> evar_map -> hint_info -> polymorphic -> ?name:hint *) val make_apply_entry : - env -> evar_map -> bool * bool * bool -> hint_info -> polymorphic -> ?name:hints_path_atom -> + env -> evar_map -> bool * bool * bool -> hint_info -> poly:bool -> ?name:hints_path_atom -> (constr * types * Univ.ContextSet.t) -> hint_entry (** A constr which is Hint'ed will be: @@ -248,7 +253,7 @@ val make_apply_entry : has missing arguments. *) val make_resolves : - env -> evar_map -> bool * bool * bool -> hint_info -> polymorphic -> ?name:hints_path_atom -> + env -> evar_map -> bool * bool * bool -> hint_info -> poly:bool -> ?name:hints_path_atom -> hint_term -> hint_entry list (** [make_resolve_hyp hname htyp]. |
