- inaccessible: Lean.Expr → Lean.Meta.Match.Pattern
- var: Lean.FVarId → Lean.Meta.Match.Pattern
- ctor: Lean.Name → List Lean.Level → List Lean.Expr → List Lean.Meta.Match.Pattern → Lean.Meta.Match.Pattern
- val: Lean.Expr → Lean.Meta.Match.Pattern
- arrayLit: Lean.Expr → List Lean.Meta.Match.Pattern → Lean.Meta.Match.Pattern
- as: Lean.FVarId → Lean.Meta.Match.Pattern → Lean.FVarId → Lean.Meta.Match.Pattern
Equations
- Lean.Meta.Match.instInhabitedPattern = { default := Lean.Meta.Match.Pattern.inaccessible default }
Equations
- Lean.Meta.Match.Pattern.toExpr p annotate = (fun visit => visit p) (Lean.Meta.Match.Pattern.toExpr.visit annotate)
partial def
Lean.Meta.Match.Pattern.toExpr.visit
(annotate : optParam Bool false)
(p : Lean.Meta.Match.Pattern)
:
def
Lean.Meta.Match.Pattern.replaceFVarId
(fvarId : Lean.FVarId)
(v : Lean.Expr)
(p : Lean.Meta.Match.Pattern)
:
Equations
- Lean.Meta.Match.Pattern.replaceFVarId fvarId v p = let s := { map := ∅ }; Lean.Meta.Match.Pattern.applyFVarSubst (Lean.Meta.FVarSubst.insert s fvarId v) p
- ref : Lean.Syntax
- fvarDecls : List Lean.LocalDecl
- patterns : List Lean.Meta.Match.Pattern
Equations
- Lean.Meta.Match.instantiateAltLHSMVars altLHS = do let a ← List.mapM Lean.Meta.instantiateLocalDeclMVars altLHS.fvarDecls let a_1 ← List.mapM Lean.Meta.Match.instantiatePatternMVars altLHS.patterns pure { ref := altLHS.ref, fvarDecls := a, patterns := a_1 }
- ref : Lean.Syntax
- idx : Nat
- rhs : Lean.Expr
- fvarDecls : List Lean.LocalDecl
- patterns : List Lean.Meta.Match.Pattern
Equations
- Lean.Meta.Match.instInhabitedAlt = { default := { ref := default, idx := default, rhs := default, fvarDecls := default, patterns := default } }
Equations
- Lean.Meta.Match.Alt.toMessageData alt = Lean.Meta.withExistingLocalDecls alt.fvarDecls (let msg := List.map (fun d => Lean.toMessageData "" ++ Lean.toMessageData (Lean.LocalDecl.toExpr d) ++ Lean.toMessageData ":(" ++ Lean.toMessageData (Lean.LocalDecl.type d) ++ Lean.toMessageData ")") alt.fvarDecls; let msg := Lean.toMessageData "" ++ Lean.toMessageData msg ++ Lean.toMessageData " |- " ++ Lean.toMessageData (List.map Lean.Meta.Match.Pattern.toMessageData alt.patterns) ++ Lean.toMessageData " => " ++ Lean.toMessageData alt.rhs ++ Lean.toMessageData ""; Lean.addMessageContext msg)
Equations
- Lean.Meta.Match.Alt.applyFVarSubst s alt = { ref := alt.ref, idx := alt.idx, rhs := Lean.Expr.applyFVarSubst s alt.rhs, fvarDecls := List.map (fun d => Lean.LocalDecl.applyFVarSubst s d) alt.fvarDecls, patterns := List.map (fun p => Lean.Meta.Match.Pattern.applyFVarSubst s p) alt.patterns }
def
Lean.Meta.Match.Alt.replaceFVarId
(fvarId : Lean.FVarId)
(v : Lean.Expr)
(alt : Lean.Meta.Match.Alt)
:
Equations
- Lean.Meta.Match.Alt.replaceFVarId fvarId v alt = { ref := alt.ref, idx := alt.idx, rhs := Lean.Expr.replaceFVarId alt.rhs fvarId v, fvarDecls := let decls := List.filter (fun d => Lean.LocalDecl.fvarId d != fvarId) alt.fvarDecls; List.map (Lean.replaceFVarIdAtLocalDecl fvarId v) decls, patterns := List.map (fun p => Lean.Meta.Match.Pattern.replaceFVarId fvarId v p) alt.patterns }
def
Lean.Meta.Match.Alt.checkAndReplaceFVarId
(fvarId : Lean.FVarId)
(v : Lean.Expr)
(alt : Lean.Meta.Match.Alt)
:
Equations
- Lean.Meta.Match.Alt.checkAndReplaceFVarId fvarId v alt = match List.find? (fun fvarDecl => Lean.LocalDecl.fvarId fvarDecl == fvarId) alt.fvarDecls with | none => Lean.throwErrorAt alt.ref (Lean.toMessageData "unknown free pattern variable") | some fvarDecl => do let vType ← Lean.Meta.inferType v let a ← Lean.Meta.isDefEqGuarded (Lean.LocalDecl.type fvarDecl) vType let _do_jp : PUnit → Lean.MetaM Lean.Meta.Match.Alt := fun y => pure (Lean.Meta.Match.Alt.replaceFVarId fvarId v alt) if a = true then do let y ← pure PUnit.unit _do_jp y else do let y ← Lean.Meta.withExistingLocalDecls alt.fvarDecls do let discr ← Lean.Meta.addPPExplicitToExposeDiff vType (Lean.LocalDecl.type fvarDecl) let x : Lean.Expr × Lean.Expr := discr match x with | (expectedType, givenType) => Lean.throwErrorAt alt.ref (Lean.toMessageData "type mismatch during dependent match-elimination at pattern variable '" ++ Lean.toMessageData (Lean.mkFVar (Lean.LocalDecl.fvarId fvarDecl)) ++ Lean.toMessageData "' with type" ++ Lean.toMessageData (Lean.indentExpr givenType) ++ Lean.toMessageData "\nexpected type" ++ Lean.toMessageData (Lean.indentExpr expectedType) ++ Lean.toMessageData "") _do_jp y
- var: Lean.FVarId → Lean.Meta.Match.Example
- underscore: Lean.Meta.Match.Example
- ctor: Lean.Name → List Lean.Meta.Match.Example → Lean.Meta.Match.Example
- val: Lean.Expr → Lean.Meta.Match.Example
- arrayLit: List Lean.Meta.Match.Example → Lean.Meta.Match.Example
partial def
Lean.Meta.Match.Example.replaceFVarId
(fvarId : Lean.FVarId)
(ex : Lean.Meta.Match.Example)
:
Equations
- mvarId : Lean.MVarId
- vars : List Lean.Expr
- alts : List Lean.Meta.Match.Alt
- examples : List Lean.Meta.Match.Example
Equations
- Lean.Meta.Match.instInhabitedProblem = { default := { mvarId := default, vars := default, alts := default, examples := default } }
Equations
- Lean.Meta.Match.withGoalOf p x = Lean.Meta.withMVarContext p.mvarId x
Equations
- Lean.Meta.Match.Problem.toMessageData p = Lean.Meta.Match.withGoalOf p do let alts ← List.mapM Lean.Meta.Match.Alt.toMessageData p.alts let vars ← List.mapM (fun x => do let xType ← Lean.Meta.inferType x pure (Lean.toMessageData "" ++ Lean.toMessageData x ++ Lean.toMessageData ":(" ++ Lean.toMessageData xType ++ Lean.toMessageData ")")) p.vars pure (Lean.toMessageData "remaining variables: " ++ Lean.toMessageData vars ++ Lean.toMessageData "\nalternatives:" ++ Lean.toMessageData (Lean.indentD (Lean.MessageData.joinSep alts (Lean.MessageData.ofFormat Lean.Format.line))) ++ Lean.toMessageData "\nexamples:" ++ Lean.toMessageData (Lean.Meta.Match.examplesToMessageData p.examples) ++ Lean.toMessageData "\n")
@[inline]
- matcher : Lean.Expr
- counterExamples : List Lean.Meta.Match.CounterExample
- unusedAltIdxs : List Nat
- addMatcher : Lean.MetaM Unit