fix: substEqs may close input goal

closes #1029
This commit is contained in:
Leonardo de Moura 2022-02-25 08:07:23 -08:00
parent 82e3789604
commit 4f7067fe7f
3 changed files with 6 additions and 4 deletions

View file

@ -127,8 +127,8 @@ private def mkInjectiveEqTheoremValue (ctorName : Name) (targetType : Expr) : Me
let (_, mvarId₂) ← intro1 mvarId₂
solveEqOfCtorEq ctorName mvarId₁ h
let mvarId₂ ← casesAnd mvarId₂
let mvarId₂ ← substEqs mvarId₂
applyRefl mvarId₂ (injTheoremFailureHeader ctorName)
if let some mvarId₂ ← substEqs mvarId₂ then
applyRefl mvarId₂ (injTheoremFailureHeader ctorName)
mkLambdaFVars xs mvar
private def mkInjectiveEqTheorem (ctorVal : ConstructorVal) : MetaM Unit := do

View file

@ -340,11 +340,11 @@ def casesAnd (mvarId : MVarId) : MetaM MVarId := do
let mvarIds ← casesRec mvarId fun localDecl => return (← instantiateMVars localDecl.type).isAppOfArity ``And 2
exactlyOne mvarIds
def substEqs (mvarId : MVarId) : MetaM MVarId := do
def substEqs (mvarId : MVarId) : MetaM (Option MVarId) := do
let mvarIds ← casesRec mvarId fun localDecl => do
let type ← instantiateMVars localDecl.type
return type.isEq || type.isHEq
exactlyOne mvarIds
ensureAtMostOne mvarIds
structure ByCasesSubgoal where
mvarId : MVarId

2
tests/lean/run/1029.lean Normal file
View file

@ -0,0 +1,2 @@
inductive Foo : Type
| mk : 0 = 1 → Foo → Foo