| 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 | open Names |
| 12 | open EConstr |
| 13 | open Evd |
| 14 | open Tactypes |
| 15 | open Locus |
| 16 | open Tactics |
| 17 | |
| 18 | (** {6 Elimination tactics. } *) |
| 19 | |
| 20 | (* |
| 21 | The general form of an induction principle is the following: |
| 22 | |
| 23 | forall prm1 prm2 ... prmp, (induction parameters) |
| 24 | forall Q1...,(Qi:Ti_1 -> Ti_2 ->...-> Ti_ni),...Qq, (predicates) |
| 25 | branch1, branch2, ... , branchr, (branches of the principle) |
| 26 | forall (x1:Ti_1) (x2:Ti_2) ... (xni:Ti_ni), (induction arguments) |
| 27 | (HI: I prm1..prmp x1...xni) (optional main induction arg) |
| 28 | -> (Qi x1...xni HI (f prm1...prmp x1...xni)).(conclusion) |
| 29 | ^^ ^^^^^^^^^^^^^^^^^^^^^^^^ |
| 30 | optional optional |
| 31 | even if HI argument added if principle |
| 32 | present above generated by functional induction |
| 33 | [indarg] [farg] |
| 34 | |
| 35 | HI is not present when the induction principle does not come directly from an |
| 36 | inductive type (like when it is generated by functional induction for |
| 37 | example). HI is present otherwise BUT may not appear in the conclusion |
| 38 | (dependent principle). HI and (f...) cannot be both present. |
| 39 | |
| 40 | Principles taken from functional induction have the final (f...). |
| 41 | *) |
| 42 | |
| 43 | (** [rel_contexts] and [rel_declaration] actually contain triples, and |
| 44 | lists are actually in reverse order to fit [compose_prod]. *) |
| 45 | type elim_scheme = { |
| 46 | elimt: types; |
| 47 | indref: GlobRef.t option; |
| 48 | params: rel_context; (** (prm1,tprm1);(prm2,tprm2)...(prmp,tprmp) *) |
| 49 | nparams: int; (** number of parameters *) |
| 50 | predicates: rel_context; (** (Qq, (Tq_1 -> Tq_2 ->...-> Tq_nq)), (Q1,...) *) |
| 51 | npredicates: int; (** Number of predicates *) |
| 52 | branches: rel_context; (** branchr,...,branch1 *) |
| 53 | nbranches: int; (** Number of branches *) |
| 54 | args: rel_context; (** (xni, Ti_ni) ... (x1, Ti_1) *) |
| 55 | nargs: int; (** number of arguments *) |
| 56 | indarg: rel_declaration option; (** Some (H,I prm1..prmp x1...xni) |
| 57 | if HI is in premisses, None otherwise *) |
| 58 | concl: types; (** Qi x1...xni HI (f...), HI and (f...) |
| 59 | are optional and mutually exclusive *) |
| 60 | indarg_in_concl: bool; (** true if HI appears at the end of conclusion *) |
| 61 | farg_in_concl: bool; (** true if (f...) appears at the end of conclusion *) |
| 62 | } |
| 63 | |
| 64 | val compute_elim_sig : evar_map -> types -> elim_scheme |
| 65 | |
| 66 | val induction : evars_flag -> clear_flag -> constr -> or_and_intro_pattern option -> |
| 67 | constr with_bindings option -> unit Proofview.tactic |
| 68 | |
| 69 | val destruct : evars_flag -> clear_flag -> constr -> or_and_intro_pattern option -> |
| 70 | constr with_bindings option -> unit Proofview.tactic |
| 71 | |
| 72 | (** {6 Generic case analysis / induction tactics. } *) |
| 73 | |
| 74 | (** Implements user-level "destruct" and "induction" *) |
| 75 | |
| 76 | val induction_destruct : rec_flag -> evars_flag -> |
| 77 | (delayed_open_constr_with_bindings Tactics.destruction_arg |
| 78 | * (intro_pattern_naming option * or_and_intro_pattern option) |
| 79 | * clause option) list * |
| 80 | constr with_bindings option -> unit Proofview.tactic |