feat: improve SimpTheorem preprocessor
This commit is contained in:
parent
e8fb0c96ac
commit
4e310ac63d
3 changed files with 24 additions and 0 deletions
|
|
@ -139,6 +139,10 @@ theorem dite_congr {s : Decidable b} [Decidable c]
|
|||
|
||||
@[simp] theorem Bool.beq_to_eq (a b : Bool) : ((a == b) = true) = (a = b) := by cases a <;> cases b <;> decide
|
||||
@[simp] theorem Bool.not_beq_to_not_eq (a b : Bool) : ((!(a == b)) = true) = ¬(a = b) := by cases a <;> cases b <;> decide
|
||||
|
||||
theorem Bool.of_not_eq_true {b : Bool} : ¬ (b = true) → b = false := by cases b <;> decide
|
||||
theorem Bool.of_not_eq_false {b : Bool} : ¬ (b = false) → b = true := by cases b <;> decide
|
||||
|
||||
@[simp] theorem Bool.not_eq_true (b : Bool) : (¬ (b = true)) = (b = false) := by cases b <;> decide
|
||||
@[simp] theorem Bool.not_eq_false (b : Bool) : (¬ (b = false)) = (b = true) := by cases b <;> decide
|
||||
|
||||
|
|
|
|||
|
|
@ -153,12 +153,21 @@ where
|
|||
else if let some (_, lhs, rhs) := type.ne? then
|
||||
if inv then
|
||||
throwError "invalid '←' modifier in rewrite rule to 'False'"
|
||||
if rhs.isConstOf ``Bool.true then
|
||||
return [(← mkAppM ``Bool.of_not_eq_true #[e], ← mkEq lhs (mkConst ``Bool.false))]
|
||||
else if rhs.isConstOf ``Bool.false then
|
||||
return [(← mkAppM ``Bool.of_not_eq_false #[e], ← mkEq lhs (mkConst ``Bool.true))]
|
||||
let type ← mkEq (← mkEq lhs rhs) (mkConst ``False)
|
||||
let e ← mkEqFalse e
|
||||
return [(e, type)]
|
||||
else if let some p := type.not? then
|
||||
if inv then
|
||||
throwError "invalid '←' modifier in rewrite rule to 'False'"
|
||||
if let some (_, lhs, rhs) := p.eq? then
|
||||
if rhs.isConstOf ``Bool.true then
|
||||
return [(← mkAppM ``Bool.of_not_eq_true #[e], ← mkEq lhs (mkConst ``Bool.false))]
|
||||
else if rhs.isConstOf ``Bool.false then
|
||||
return [(← mkAppM ``Bool.of_not_eq_false #[e], ← mkEq lhs (mkConst ``Bool.true))]
|
||||
let type ← mkEq p (mkConst ``False)
|
||||
let e ← mkEqFalse e
|
||||
return [(e, type)]
|
||||
|
|
|
|||
11
tests/lean/run/simpBool.lean
Normal file
11
tests/lean/run/simpBool.lean
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
example (h : x ≠ true) : (x && y) = false := by
|
||||
simp [h]
|
||||
|
||||
example (h : ¬ (x = true)) : (x && y) = false := by
|
||||
simp [h]
|
||||
|
||||
example (h : x ≠ false) : (x && y) = y := by
|
||||
simp [h]
|
||||
|
||||
example (h : ¬ (x = false)) : (x && y) = y := by
|
||||
simp [h]
|
||||
Loading…
Add table
Reference in a new issue