Skip to content

Commit

Permalink
chore: clean up evalNot norm_num extension (#9532)
Browse files Browse the repository at this point in the history
* Uses `deriveBool`, which was added in #3892, and allows removal of some `have` lines.
* Changes an `if then else` into a match. This is more readable in my opinion.
  • Loading branch information
dwrensha committed Feb 6, 2024
1 parent a83ab19 commit f43e781
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions Mathlib/Tactic/NormNum/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -458,15 +458,10 @@ such that `norm_num` successfully recognises `a`. -/
@[norm_num ¬_] def evalNot : NormNumExt where eval {u α} e := do
let .app (.const ``Not _) (a : Q(Prop)) ← whnfR e | failure
guard <|← withNewMCtxDepth <| isDefEq α q(Prop)
let .isBool b p ← derive q($a) | failure
haveI' : u =QL 0 := ⟨⟩; haveI' : $α =Q Prop := ⟨⟩
haveI' : $e =Q ¬ $a := ⟨⟩
if b then
have p : Q($a) := p
return .isFalse q(not_not_intro $p)
else
have p : Q(¬ $a) := p
return .isTrue q($p)
let ⟨b, p⟩ ← deriveBool q($a)
match b with
| true => return .isFalse q(not_not_intro $p)
| false => return .isTrue q($p)

/-! # (In)equalities -/

Expand Down

0 comments on commit f43e781

Please sign in to comment.