Syntax#
Ltac2.Syntax
Hypotheses#
type hypothesis += | Named_hyp of ident(*
*)Named_hyp hselects hypothesish.| Nth_hyp of int(*
*)Nth_hyp nselects then-th hypothesis.
Bindings#
type bindings += | No_bindings(*An empty list of bindings.
*)| Implicit of constr list(*
*)Implicit [t₁; …; tₙ]binds free variables in left-to-right order of their first appearance in the relevant term.| Explicit of (hypothesis * constr) list(*
*)Explicit [(h₁, t₁); …; (hₙ, tₙ)]binds variableshᵢtotᵢ.
val term : constr -> constr_with_bindingsterm t adds default bindings to t.
Expected usage: { (term t) with bindings = … }.
Intropatterns#
An intropattern lets you specify the name to assign to variables and hypotheses introduced by tactics.
The type variable is used for statically distinguishing subtypes of intropatterns.
Tag for intropatterns used for naming hypotheses (e.g., in eqn: clauses).
Tag for intropatterns that split conjunctions/disjunctions, sometimes used in as clauses.
Tag for intropatterns that are used as rewrite orientations (i.e., (-->) and (<--)).
Tag for equality intropatterns.
Naming patterns#
val name : ident -> [> naming ] intropatternname ident uses the specified name.
val (??) : [> naming ] intropattern(??) lets Rocq generate a fresh name.
val (?:) : ident -> [> naming ] intropattern?:ident lets Rocq generate a fresh name that begins with ident.
Splitting patterns#
val (&) :
simple intropattern ->
simple intropattern ->
[> or_and ] intropatternp1 & p2 splits a hypothesis of the form A /\ B into p1: A and p2: B. Right-associative.
val and_pattern : simple intropattern list -> [> or_and ] intropatternand_pattern [p₁; …; pₙ] is equivalent to p₁ & … & pₙ.
val or_pattern : any intropattern list list -> [> or_and ] intropatternor_pattern [[p₁₁; …; p₁ₘ]; …; [pₙ₁; …; pₙₖ]] destructs a hypothesis whose inductive type has n constructors (e.g., A₁ ∨ … ∨ Aₙ) into n subgoals. In the i-th subgoal, the arguments of the i-th constructor are named by the patterns of the i-th inner list. Corresponds to [p₁₁ … p₁ₘ | … | pₙ₁ … pₙₖ] in Ltac.
Equality patterns#
These patterns can be used when the hypothesis is an equality.
val (-->) : [> orientation ] intropatternReplaces the LHS of the hypothesis with the RHS in the conclusion of the goal.
val (<--) : [> orientation ] intropatternReplaces the RHS of the hypothesis with the LHS in the conclusion of the goal.
val (@=) : any intropattern list -> [> equality ] intropatternApplies either Std.injection or Std.discriminate.
Other patterns#
val __ : [> simple ] intropatternWildcard intropattern that discards the matched pattern (unless it is required by another hypothesis).
val (@*) : [> other ] intropatternIntroduces one or more dependent premises from the result until there are no more.
val (@**) : [> other ] intropatternIntroduces one or more dependent or non-dependent premises from the result until there are no more premises.
val (%) : simple intropattern -> constr -> [> simple ] intropatternpattern%term first applies term with the Std.apply tactic on the hypothesis to be introduced, then it uses pattern.
Occurrences#
An occurrence is a subterm of a goal or hypothesis that matches a pattern.
type occurrences += | At : 'a list -> 'a occurrences(*
*)At lselects the specified occurrences.| Everywhere : 'a occurrences(*
*)Everywhereselects every occurrence (similar to Ltac's*).| Everywhere_but : int list -> int occurrences(*
*)Everywhere_but lselects every occurrence that is not inl(similar to Ltac'sat -l).| Nowhere : 'a occurrences(*
*)Nowhereselects no occurrence.
Clauses#
Selects whether an occurrence should apply to the type or value of the hypothesis.
type hypothesis_selector += val (|-) :
(hypothesis_selector * int occurrences) occurrences ->
int occurrences ->
clausehyps_occs |- goal_occs creates a clause that selects occurrences in the hypotheses according to hyps_occs, and occurrences in the goal according to goal_occs.
Examples:
Everywhere |- Everywherecorresponds to* |- *.Nowhere |- Everywherecorresponds to|- *.Nowhere |- Nowherecorresponds to|-.At [(Type_of h, Everywhere)] |- (At [1; 2])corresponds to(type of h) |- * at 1 2.
Move locations#
Specifies where to move a hypothesis for the Std.move tactic.
type move_location += Inversion kinds#
type inversion_kind += Rewrites#
type multiplicity += Type of rewriters for the Std.rewrite tactic.
val (==>) : ?n:multiplicity -> ?with_:bindings -> constr -> oriented_rewriter(==>) ?n e ?with_ rewrites using equality or equivalence e, of the form forall …, term₁ = term₂ or forall …, term₁ EQ term₂ for some equivalence relation EQ, by replacing term₁ with term₂.
val (<==) : ?n:multiplicity -> ?with_:bindings -> constr -> oriented_rewriter(<==) ?n e ?with_ rewrites using equality or equivalence e, of the form forall …, term₁ = term₂ or forall …, term₁ EQ term₂ for some equivalence relation EQ, by replacing term₂ with term₁.
Induction clauses#
module Induction_arg : sig ... endmodule Induction_clause : sig ... end