| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | (** This files implements typeclasses eauto *) |
| 12 | |
| 13 | open Names |
| 14 | open EConstr |
| 15 | open Hints |
| 16 | |
| 17 | val typeclasses_db : hint_db_name |
| 18 | |
| 19 | val check_typeclasses_db : ?loc:Loc.t -> unit -> unit |
| 20 | |
| 21 | val set_typeclasses_debug : bool -> unit |
| 22 | |
| 23 | val set_typeclasses_depth : int option -> unit |
| 24 | |
| 25 | type search_strategy = Dfs | Bfs |
| 26 | |
| 27 | val set_typeclasses_strategy : search_strategy -> unit |
| 28 | |
| 29 | val typeclasses_eauto : |
| 30 | ?only_classes:bool |
| 31 | (** Should non-class goals be shelved and resolved at the end. Default: false *) |
| 32 | -> ?best_effort:bool |
| 33 | (** Default: false. Allow some unresolved goals to remain in the result. We explore the |
| 34 | whole search space to find a complete solution but if that fails, |
| 35 | we return the first solution (if any) with only two kind of constraints: |
| 36 | - Stuck constraints which do not validate the modes declared |
| 37 | for their heads in the database are shelved. |
| 38 | - Constraints which validate a mode declaration for their class but have no solution |
| 39 | are left as subgoals. |
| 40 | This is useful to debug eauto calls and in typeclass resolution to give more informative |
| 41 | error messages. *) |
| 42 | -> ?st:TransparentState.t |
| 43 | (** Default: full. The transparent_state used when working with local hypotheses *) |
| 44 | -> ?strategy:search_strategy |
| 45 | (** Default: governed by a global flag, which itself defaults to depth-first search. |
| 46 | Is a traversing-strategy specified? *) |
| 47 | -> depth:(Int.t option) |
| 48 | (** Bounded or unbounded search *) |
| 49 | -> Hints.hint_db_name list |
| 50 | (** The list of hint databases to use *) |
| 51 | -> unit Proofview.tactic |
| 52 | |
| 53 | val head_of_constr : Id.t -> constr -> unit Proofview.tactic |
| 54 | |
| 55 | val not_evar : constr -> unit Proofview.tactic |
| 56 | |
| 57 | val is_ground : constr -> unit Proofview.tactic |
| 58 | |
| 59 | val autoapply : constr -> hint_db_name -> unit Proofview.tactic |
| 60 | |
| 61 | val resolve_one_typeclass : ?db:hint_db -> Environ.env -> Evd.evar_map -> types -> Evd.evar_map * constr |
| 62 | (** Tries to find a solution for the given type. Raises Not_found it it fails. *) |
| 63 | |
| 64 | val resolve_tc : constr -> unit Proofview.tactic |
| 65 | |
| 66 | type solver = { solver : |
| 67 | ?db:hint_db -> |
| 68 | Environ.env -> |
| 69 | Evd.evar_map -> |
| 70 | depth:int option -> |
| 71 | unique:bool -> |
| 72 | best_effort:bool -> |
| 73 | goals:Evar.t list -> |
| 74 | (bool * Evd.evar_map) |
| 75 | } |
| 76 | |
| 77 | |
| 78 | type condition = (Environ.env -> Evd.evar_map -> Evar.Set.t -> bool) |
| 79 | |
| 80 | |
| 81 | (** |
| 82 | A tc_solver is made of a solver and a condition telling when the |
| 83 | the solver should be executed instead of Rocq's one |
| 84 | *) |
| 85 | type tc_solver = solver * condition |
| 86 | |
| 87 | val register_solver : name:CString.Map.key -> ?override:bool -> tc_solver -> unit |
| 88 | val activate_solver : name:CString.Map.key -> unit |
| 89 | val deactivate_solver : name:CString.Map.key -> unit |
| 90 | |
| 91 | module Search : sig |
| 92 | val eauto_tac : |
| 93 | Hints.Modes.t * TransparentState.t |
| 94 | (** The transparent_state and modes used when working with local hypotheses *) |
| 95 | -> ?unique:bool |
| 96 | (** Should we force a unique solution *) |
| 97 | -> only_classes:bool |
| 98 | (** Should non-class goals be shelved and resolved at the end *) |
| 99 | -> best_effort:bool |
| 100 | (** If true, when considering a proof search problem where some |
| 101 | constraints obey mode declarations, we allow in some situations |
| 102 | to perform proof search on the rest of the goals and report these |
| 103 | remaining goals (if they remain unsolved) at the end. |
| 104 | The remaining goals are constraints that either do not match the mode declared |
| 105 | for their head (i.e. a class), so we cannot even try to solve them, |
| 106 | or that match it but have no solution (for a single run of the resolution). |
| 107 | This is an approximation: there might in general be other runs |
| 108 | of resolution that fail too and generate different instantiations of these goals. |
| 109 | However it is still sound: providing instances for the reported constraints |
| 110 | would provide a solution to the whole proof search problem. *) |
| 111 | -> ?strategy:search_strategy |
| 112 | (** Is a traversing-strategy specified? *) |
| 113 | -> depth:Int.t option |
| 114 | (** Bounded or unbounded search *) |
| 115 | -> dep:bool |
| 116 | (** Should the tactic be made backtracking on the initial goals, |
| 117 | whatever their internal dependencies are. *) |
| 118 | -> Hints.hint_db list |
| 119 | (** The list of hint databases to use *) |
| 120 | -> unit Proofview.tactic |
| 121 | (** Note: there might be stuck goals due to mode declarations |
| 122 | remaining even in case of success of the tactic. *) |
| 123 | end |