We treat @x
as atomic to avoid unnecessary extra local declarations from being
inserted into the local context. Recall that expandMatchAltsIntoMatch
uses @
modifier.
Thus this is kind of discriminant is quite common.
Remark: if the discriminat is Systax.missing
, we abort the elaboration of the match
-expression.
This can happen due to error recovery. Example
example : (p ∨ p) → p := fun h => match
If we don't abort, the elaborator loops because we will keep trying to expand
match
into
let d := ; match
Recall that Syntax.setArg stx i arg
is a no-op when i
is out-of-bounds.
Equations
- One or more equations did not get rendered due to their size.
- expr : Lean.Expr
some h
if discriminant is annotated with theh :
notation.h? : Option Lean.Syntax
Equations
- Lean.Elab.Term.instInhabitedDiscr = { default := { expr := default, h? := default } }
- discrs : Array Lean.Elab.Term.Discr
- matchType : Lean.Expr
- isDep : Bool
- alts : Array Lean.Elab.Term.MatchAltView
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Elab.Term.elabInaccessible stx expectedType? = do let e ← Lean.Elab.Term.elabTerm (Lean.Syntax.getOp stx 1) expectedType? true true pure (Lean.mkInaccessible e)
Equations
- One or more equations did not get rendered due to their size.
- ex : Lean.Exception
- patternIdx : Nat
When visiting an assigned metavariable, if it has an user-name. We save it here. We want to preserve these user-names when generating new pattern variables.
userName : Lean.NamePattern variables that were explicitly provided by the user. Recall that implicit parameters and
_
are elaborated as metavariables, and then converted into pattern variables by thenormalize
procedure.explicitPatternVars : Array Lean.FVarId
Return true iff e
is an explicit pattern variable provided by the user.
Equations
- One or more equations did not get rendered due to their size.
Normalize the pattern and collect all patterns variables (explicit and implicit).
This method is the one that decides where the inaccessible annotations must be inserted.
The pattern variables are both free variables (for explicit pattern variables) and metavariables (for implicit ones).
Recall that mkLambdaFVars
now allows us to abstract both free variables and metavariables.
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.
- visitedFVars : Lean.FVarIdSet
- visitedMVars : Lean.MVarIdSet
Save pattern information in the info tree, and remove patternWithRef?
annotations.
Main method for withDepElimPatterns
.
PatternVarDecls
: are the explicit pattern variables provided by the user.ps
: are the patterns provided by the user.matchType
: the expected typ for this branch. It depends on the explicit pattern variables and the implicit ones that are still represented as metavariables, and are found by this function.k
is the continuation that is executed in an updated local context with the all pattern variables (explicit and implicit). Note that,patternVarDecls
are all replaced since they may depend on implicit pattern variables (i.e., metavariables) that are converted into new free variables by this method.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Elab.Term.ToDepElimPattern.main.unpack packed k = Lean.Elab.Term.ToDepElimPattern.main.unpack.go k packed #[]
Equations
- Lean.Elab.Term.withDepElimPatterns patternVarDecls ps matchType k = Lean.Elab.Term.ToDepElimPattern.main patternVarDecls ps matchType k
- discrs : Array Lean.Elab.Term.Discr
FVarId
s of the variables that have been generalized. We store them to clear after in each branch.toClear : Array Lean.FVarId- matchType : Lean.Expr
- altViews : Array Lean.Elab.Term.MatchAltView
- refined : Bool
Equations
- Lean.Elab.Term.mkMatcher input = liftM (Lean.Meta.Match.mkMatcher input)
Equations
- One or more equations did not get rendered due to their size.
Pattern matching. match e, ... with | p, ... => f | ...
matches each given
term e
against each pattern p
of a match alternative. When all patterns
of an alternative match, the match
term evaluates to the value of the
corresponding right-hand side f
with the pattern variables bound to the
respective matched values.
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.
Empty match/ex falso. nomatch e
is of arbitrary type α : Sort u
if
Lean can show that an empty set of patterns is exhaustive given e
's type,
e.g. because it has no constructors.
Equations
- One or more equations did not get rendered due to their size.