feat: add support for HEq at injections tactic

This commit is contained in:
Leonardo de Moura 2022-02-23 17:31:17 -08:00
parent 07d1ec1926
commit 49c64040a2
3 changed files with 25 additions and 1 deletions

View file

@ -25,6 +25,19 @@ def matchEq? (e : Expr) : MetaM (Option (Expr × Expr × Expr)) :=
def matchHEq? (e : Expr) : MetaM (Option (Expr × Expr × Expr × Expr)) :=
matchHelper? e fun e => return Expr.heq? e
/--
Return `some (α, lhs, rhs)` if `e` is of the form `@Eq α lhs rhs` or `@HEq α lhs α rhs`
-/
def matchEqHEq? (e : Expr) : MetaM (Option (Expr × Expr × Expr)) := do
if let some r ← matchEq? e then
return some r
else if let some (α, lhs, β, rhs) ← matchHEq? e then
if (← isDefEq α β) then
return some (α, lhs, rhs)
return none
else
return none
def matchFalse (e : Expr) : MetaM Bool := do
testHelper e fun e => return e.isConstOf ``False

View file

@ -119,7 +119,7 @@ where
| d+1, fvarId :: fvarIds, mvarId => do
let cont := do
go (d+1) fvarIds mvarId
if let some (_, lhs, rhs) ← matchEq? (← getLocalDecl fvarId).type then
if let some (_, lhs, rhs) ← matchEqHEq? (← getLocalDecl fvarId).type then
let lhs ← whnf lhs
let rhs ← whnf rhs
if lhs.isNatLit && rhs.isNatLit then cont

View file

@ -0,0 +1,11 @@
inductive Vector (α : Type u): Nat → Type u where
| nil : Vector α 0
| cons (head : α) (tail : Vector α n) : Vector α (n+1)
namespace Vector
def nth : Vector α n → Fin n → α
| cons x xs, ⟨0, _⟩ => x
| cons x xs, ⟨k+1, h⟩ => xs.nth ⟨k, Nat.le_of_succ_le_succ h⟩
attribute [simp] nth