Skip to content

Commit

Permalink
fix: don't count parameters as minor premises
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 committed Sep 24, 2023
1 parent 7149f40 commit 9d01490
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Std/CodeAction/Misc.lean
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,14 @@ def removeAfterDoneAction : TacticCodeAction := fun params _ _ stk node => do
Similar to `getElabInfo`, but returns the names of binders instead of just the numbers;
intended for code actions which need to name the binders.
-/
def getElimNames (declName : Name) : MetaM (Array (Name × Array Name)) := do
def getElimNames (inductName declName : Name) : MetaM (Array (Name × Array Name)) := do
let inductVal ← getConstInfoInduct inductName
let decl ← getConstInfo declName
forallTelescopeReducing decl.type fun xs type => do
let motive := type.getAppFn
let targets := type.getAppArgs
let mut altsInfo := #[]
for i in [:xs.size] do
for i in [inductVal.numParams:xs.size] do
let x := xs[i]!
if x != motive && !targets.contains x then
let xDecl ← x.fvarId!.getDecl
Expand Down Expand Up @@ -280,7 +281,7 @@ def casesExpand : TacticCodeAction := fun params snap ctx _ node => do
doc.meta.text.utf8PosToLspPos stx'.getTailPos?.get!
else endPos
let elimName := if induction then mkRecName name else mkCasesOnName name
let ctors ← discrInfo.runMetaM ctx (getElimNames elimName)
let ctors ← discrInfo.runMetaM ctx (getElimNames name elimName)
let newText := if ctors.isEmpty then "" else Id.run do
let mut str := " with"
let indent := "\n".pushn ' ' (findIndentAndIsStart doc.meta.text.source tacPos).1
Expand Down

0 comments on commit 9d01490

Please sign in to comment.