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 := <Syntax.missing>; 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.
Instances For
- expr : Lean.Expr
- h? : Option Lean.Syntax
some h
if discriminant is annotated with theh :
notation.
Instances For
Equations
- Lean.Elab.Term.instInhabitedDiscr = { default := { expr := default, h? := default } }
- discrs : Array Lean.Elab.Term.Discr
- matchType : Lean.Expr
- isDep : Bool
true
when performing dependent elimination. We use this to decide whether we optimize the "match unit" case. SeeisMatchUnit?
. - alts : Array Lean.Elab.Term.MatchAltView
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Lean.Elab.Term.elabInaccessible stx expectedType? = do let e ← Lean.Elab.Term.elabTerm stx[1] expectedType? true pure (Lean.mkInaccessible e)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Remark: when performing dependent pattern matching, we often had to write code such as
def Vec.map' (f : α → β) (xs : Vec α n) : Vec β n :=
match n, xs with
| _, nil => nil
| _, cons a as => cons (f a) (map' f as)
We had to include n
and the _
s because the type of xs
depends on n
.
Moreover, nil
and cons a as
have different types.
This was quite tedious. So, we have implemented an automatic "discriminant refinement procedure".
The procedure is based on the observation that we get a type error whenenver we forget to include _
s
and the indices a discriminant depends on. So, we catch the exception, check whether the type of the discriminant
is an indexed family, and add their indices as new discriminants.
The current implementation, adds indices as they are found, and does not try to "sort" the new discriminants.
If the refinement process fails, we report the original error message.
Auxiliary structure for storing an type mismatch exception when processing the
pattern #idx
of some alternative.
- ex : Lean.Exception
- patternIdx : Nat
Instances For
Instances For
- userName : Lake.Name
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.
- explicitPatternVars : Array Lean.FVarId
Pattern 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.
Instances For
Equations
Instances For
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.
Instances For
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.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
- visitedFVars : Lean.FVarIdSet
- visitedMVars : Lean.MVarIdSet
Instances For
Equations
Instances For
Save pattern information in the info tree, and remove patternWithRef?
annotations.
Equations
Instances For
The Bool
context is true iff we are inside of an "inaccessible" pattern.
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.
Instances For
Equations
- Lean.Elab.Term.ToDepElimPattern.main.unpack packed k = Lean.Elab.Term.ToDepElimPattern.main.unpack.go k packed #[]
Instances For
Equations
- Lean.Elab.Term.withDepElimPatterns patternVarDecls ps matchType k = Lean.Elab.Term.ToDepElimPattern.main patternVarDecls ps matchType k
Instances For
- discrs : Array Lean.Elab.Term.Discr
- toClear : Array Lean.FVarId
FVarId
s of the variables that have been generalized. We store them to clear after in each branch. - matchType : Lean.Expr
- altViews : Array Lean.Elab.Term.MatchAltView
- refined : Bool
Instances For
Equations
- Lean.Elab.Term.mkMatcher input = liftM (Lean.Meta.Match.mkMatcher input)
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.
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.
- Lean.Elab.Term.elabNoMatch.loop stx [] discrsNew = pure { raw := Lean.Syntax.setArg stx 1 (Lean.Syntax.mkSep discrsNew (Lean.mkAtomFrom stx ", ")) }
Instances For
Equations
- One or more equations did not get rendered due to their size.