Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
An rcases
pattern can be one of the following, in a nested combination:
- A name like
foo
- The special keyword
rfl
(for pattern matching on equality usingsubst
) - A hyphen
-
, which clears the active hypothesis and any dependents. - A type ascription like
pat : ty
(parentheses are optional) - A tuple constructor like
⟨p1, p2, p3⟩
- An alternation / variant pattern
p1 | p2 | p3
Parentheses can be used for grouping; alternation is higher precedence than type ascription, so
p1 | p2 | p3 : ty
means (p1 | p2 | p3) : ty
.
N-ary alternations are treated as a group, so p1 | p2 | p3
is not the same as p1 | (p2 | p3)
,
and similarly for tuples. However, note that an n-ary alternation or tuple can match an n-ary
conjunction or disjunction, because if the number of patterns exceeds the number of constructors in
the type being destructed, the extra patterns will match on the last element, meaning that
p1 | p2 | p3
will act like p1 | (p2 | p3)
when matching a1 ∨ a2 ∨ a3
. If matching against a
type with 3 constructors, p1 | (p2 | p3)
will act like p1 | (p2 | p3) | _
instead.
- paren: Lean.Syntax → Lean.Elab.Tactic.RCases.RCasesPatt → Lean.Elab.Tactic.RCases.RCasesPatt
A parenthesized expression, used for hovers
- one: Lean.Syntax → Lean.Name → Lean.Elab.Tactic.RCases.RCasesPatt
A named pattern like
foo
- clear: Lean.Syntax → Lean.Elab.Tactic.RCases.RCasesPatt
A hyphen
-
, which clears the active hypothesis and any dependents. - explicit: Lean.Syntax → Lean.Elab.Tactic.RCases.RCasesPatt → Lean.Elab.Tactic.RCases.RCasesPatt
An explicit pattern
@pat
. - typed: Lean.Syntax → Lean.Elab.Tactic.RCases.RCasesPatt → Lean.Term → Lean.Elab.Tactic.RCases.RCasesPatt
A type ascription like
pat : ty
(parentheses are optional) - tuple: Lean.Syntax → List Lean.Elab.Tactic.RCases.RCasesPatt → Lean.Elab.Tactic.RCases.RCasesPatt
A tuple constructor like
⟨p1, p2, p3⟩
- alts: Lean.Syntax → List Lean.Elab.Tactic.RCases.RCasesPatt → Lean.Elab.Tactic.RCases.RCasesPatt
An alternation / variant pattern
p1 | p2 | p3
Instances For
Get the name from a pattern, if provided
Get the syntax node from which this pattern was parsed. Used for error messages
Equations
- (Lean.Elab.Tactic.RCases.RCasesPatt.paren a a_1).ref = a
- (Lean.Elab.Tactic.RCases.RCasesPatt.one a a_1).ref = a
- (Lean.Elab.Tactic.RCases.RCasesPatt.clear a).ref = a
- (Lean.Elab.Tactic.RCases.RCasesPatt.explicit a a_1).ref = a
- (Lean.Elab.Tactic.RCases.RCasesPatt.typed a a_1 a_2).ref = a
- (Lean.Elab.Tactic.RCases.RCasesPatt.tuple a a_1).ref = a
- (Lean.Elab.Tactic.RCases.RCasesPatt.alts a a_1).ref = a
Instances For
Interpret an rcases pattern as a tuple, where p
becomes ⟨p⟩
if p
is not already a tuple.
Equations
- (Lean.Elab.Tactic.RCases.RCasesPatt.paren ref p).asTuple = p.asTuple
- (Lean.Elab.Tactic.RCases.RCasesPatt.explicit ref p).asTuple = (true, p.asTuple.snd)
- (Lean.Elab.Tactic.RCases.RCasesPatt.tuple ref ps).asTuple = (false, ps)
- x.asTuple = (false, [x])
Instances For
Interpret an rcases pattern as an alternation, where non-alternations are treated as one alternative.
Equations
- (Lean.Elab.Tactic.RCases.RCasesPatt.paren ref p).asAlts = p.asAlts
- (Lean.Elab.Tactic.RCases.RCasesPatt.alts ref ps).asAlts = ps
- x.asAlts = [x]
Instances For
Convert a list of patterns to a tuple pattern, but mapping [p]
to p
instead of ⟨p⟩
.
Equations
- Lean.Elab.Tactic.RCases.RCasesPatt.typed? ref x none = x
- Lean.Elab.Tactic.RCases.RCasesPatt.typed? ref x (some ty) = Lean.Elab.Tactic.RCases.RCasesPatt.typed ref x ty
Instances For
Convert a list of patterns to a tuple pattern, but mapping [p]
to p
instead of ⟨p⟩
.
Equations
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple' [p] = p
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple' x = Lean.Elab.Tactic.RCases.RCasesPatt.tuple ((Option.map (fun (x : Lean.Elab.Tactic.RCases.RCasesPatt) => x.ref) x.head?).getD Lean.Syntax.missing) x
Instances For
Convert a list of patterns to an alternation pattern, but mapping [p]
to p
instead of
a unary alternation |p
.
Equations
Instances For
This function is used for producing rcases patterns based on a case tree. Suppose that we have
a list of patterns ps
that will match correctly against the branches of the case tree for one
constructor. This function will merge tuples at the end of the list, so that [a, b, ⟨c, d⟩]
becomes ⟨a, b, c, d⟩
instead of ⟨a, b, ⟨c, d⟩⟩
.
We must be careful to turn [a, ⟨⟩]
into ⟨a, ⟨⟩⟩
instead of ⟨a⟩
(which will not perform the
nested match).
Equations
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁Core [] = []
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁Core [Lean.Elab.Tactic.RCases.RCasesPatt.tuple ref []] = [Lean.Elab.Tactic.RCases.RCasesPatt.tuple ref []]
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁Core [Lean.Elab.Tactic.RCases.RCasesPatt.tuple ref ps] = ps
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁Core (p :: ps) = p :: Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁Core ps
Instances For
This function is used for producing rcases patterns based on a case tree. This is like
tuple₁Core
but it produces a pattern instead of a tuple pattern list, converting [n]
to n
instead of ⟨n⟩
and []
to _
, and otherwise just converting [a, b, c]
to ⟨a, b, c⟩
.
Equations
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁ [] = default
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁ [Lean.Elab.Tactic.RCases.RCasesPatt.one ref n] = Lean.Elab.Tactic.RCases.RCasesPatt.one ref n
- Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁ x = Lean.Elab.Tactic.RCases.RCasesPatt.tuple x.head!.ref (Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁Core x)
Instances For
This function is used for producing rcases patterns based on a case tree. Here we are given
the list of patterns to apply to each argument of each constructor after the main case, and must
produce a list of alternatives with the same effect. This function calls tuple₁
to make the
individual alternatives, and handles merging [a, b, c | d]
to a | b | c | d
instead of
a | b | (c | d)
.
Equations
- Lean.Elab.Tactic.RCases.RCasesPatt.alts₁Core [] = []
- Lean.Elab.Tactic.RCases.RCasesPatt.alts₁Core [[Lean.Elab.Tactic.RCases.RCasesPatt.alts ref ps]] = ps
- Lean.Elab.Tactic.RCases.RCasesPatt.alts₁Core (p :: ps) = Lean.Elab.Tactic.RCases.RCasesPatt.tuple₁ p :: Lean.Elab.Tactic.RCases.RCasesPatt.alts₁Core ps
Instances For
This function is used for producing rcases patterns based on a case tree. This is like
alts₁Core
, but it produces a cases pattern directly instead of a list of alternatives. We
specially translate the empty alternation to ⟨⟩
, and translate |(a | b)
to ⟨a | b⟩
(because we
don't have any syntax for unary alternation). Otherwise we can use the regular merging of
alternations at the last argument so that a | b | (c | d)
becomes a | b | c | d
.
Equations
- Lean.Elab.Tactic.RCases.RCasesPatt.alts₁ ref [[]] = Lean.Elab.Tactic.RCases.RCasesPatt.tuple Lean.Syntax.missing []
- Lean.Elab.Tactic.RCases.RCasesPatt.alts₁ ref [[Lean.Elab.Tactic.RCases.RCasesPatt.alts ref_1 ps]] = Lean.Elab.Tactic.RCases.RCasesPatt.tuple ref_1 ps
- Lean.Elab.Tactic.RCases.RCasesPatt.alts₁ ref x = Lean.Elab.Tactic.RCases.RCasesPatt.alts' ref (Lean.Elab.Tactic.RCases.RCasesPatt.alts₁Core x)
Instances For
parenthesize the message if the precedence is above tgt
Equations
- Lean.Elab.Tactic.RCases.RCasesPatt.instToMessageData.parenAbove tgt p m = if tgt < p then m.paren else m
Instances For
format an RCasesPatt
with the given precedence: 0 = lo, 1 = med, 2 = hi
Takes the number of fields of a single constructor and patterns to match its fields against
(not necessarily the same number). The returned lists each contain one element per field of the
constructor. The name
is the name which will be used in the top-level cases
tactic, and the
rcases_patt
is the pattern which the field will be matched against by subsequent cases
tactics.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Takes a list of constructor names, and an (alternation) list of patterns, and matches each
pattern against its constructor. It returns the list of names that will be passed to cases
,
and the list of (constructor name, patterns)
for each constructor, where patterns
is the
(conjunctive) list of patterns to apply to each constructor argument.
Equations
- One or more equations did not get rendered due to their size.
- Lean.Elab.Tactic.RCases.processConstructors ref params altVarNames [] x = pure (altVarNames, [])
Instances For
Like Lean.Meta.subst
, but preserves the FVarSubst
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
This will match a pattern pat
against a local hypothesis e
.
g
: The initial subgoalfs
: A running variable substitution, the result ofcases
operations upstream. The variablee
must be run through this map before locating it in the context ofg
, and the output variable substitutions will be end extensions of this one.clears
: The list of variables to clear in all subgoals generated from this point on. We defer clear operations because clearing too early can causecases
to fail. The actual clearing happens inRCases.finish
.e
: a local hypothesis, the scrutinee to match against.a
: opaque "user data" which is passed through all the goal calls at the end.pat
: the pattern to match againstcont
: A continuation. This is called on every goal generated by the result of the pattern match, with updated values forg
,fs
,clears
, anda
.
Runs rcasesContinue
on the first pattern in r
with a matching ctorName
.
The unprocessed patterns (subsequent to the matching pattern) are returned.
This will match a list of patterns against a list of hypotheses e
. The arguments are similar
to rcasesCore
, but the patterns and local variables are in pats
. Because the calls are all
nested in continuations, later arguments can be matched many times, once per goal produced by
earlier arguments. For example ⟨a | b, ⟨c, d⟩⟩
performs the ⟨c, d⟩
match twice, once on the
a
branch and once on b
.
Like tryClearMany
, but also clears dependent hypotheses if possible
Equations
- One or more equations did not get rendered due to their size.
Instances For
The terminating continuation used in rcasesCore
and rcasesContinue
. We specialize the type
α
to Array MVarId
to collect the list of goals, and given the list of clears
, it attempts to
clear them from the goal and adds the goal to the list.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Parses a Syntax
into the RCasesPatt
type used by the RCases
tactic.
Generalize all the arguments as specified in args
to fvars if they aren't already
Equations
- One or more equations did not get rendered due to their size.
Instances For
Given a list of targets of the form e
or h : e
, and a pattern, match all the targets
against the pattern. Returns the list of produced subgoals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The obtain
tactic in the no-target case. Given a type T
, create a goal |- T
and
and pattern match T
against the given pattern. Returns the list of goals, with the assumed goal
first followed by the goals produced by the pattern match.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Expand a rintroPat
into an equivalent list of rcasesPat
patterns.
Expand a list of rintroPat
into an equivalent list of rcasesPat
patterns.
This introduces the pattern pat
. It has the same arguments as rcasesCore
, plus:
ty?
: the nearest enclosing type ascription on the current pattern
This introduces the list of patterns pats
. It has the same arguments as rcasesCore
, plus:
ty?
: the nearest enclosing type ascription on the current pattern
Runs rintroContinue
on pats[i:]
The implementation of the rintro
tactic. It takes a list of patterns pats
and
an optional type ascription ty?
and introduces the patterns, resulting in zero or more goals.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.