feat: add isSimpCnstrTarget

This commit is contained in:
Leonardo de Moura 2022-02-25 17:18:50 -08:00
parent 7217ee7754
commit 5030e613a2

View file

@ -7,8 +7,25 @@ import Lean.Meta.Tactic.LinearArith.Nat
namespace Lean.Meta.Linear
/-- Quick filter simpCnstr? -/
private partial def isSimpCnstrTarget (e : Expr) : Bool :=
let f := e.getAppFn
if !f.isConst then
false
else
let n := f.constName!
if n == ``Eq || n == ``LT.lt || n == ``LE.le || n == ``GT.gt || n == ``GE.ge then
true
else if n == ``Not && e.getAppNumArgs == 1 then
isSimpCnstrTarget e.appArg!
else
false
def simpCnstr? (e : Expr) : MetaM (Option (Expr × Expr)) := do
-- TODO: add support for `Int` and arbitrary ordered comm rings
Nat.simpCnstr? e
if isSimpCnstrTarget e then
-- TODO: add support for `Int` and arbitrary ordered comm rings
Nat.simpCnstr? e
else
return none
end Lean.Meta.Linear