Skip to content

Commit

Permalink
chore: classical logic lemmas needed for push_neg (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em authored Feb 9, 2024
1 parent ae4d2ee commit 257ae8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 9 additions & 0 deletions Std/Logic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,15 @@ theorem or_iff_not_imp_left : a ∨ b ↔ (¬a → b) :=
theorem or_iff_not_imp_right : a ∨ b ↔ (¬b → a) :=
Decidable.or_iff_not_imp_right

theorem not_imp : ¬(a → b) ↔ a ∧ ¬b :=
Decidable.not_imp

theorem not_and : ¬(a ∧ b) ↔ ¬a ∨ ¬b :=
Decidable.not_and

theorem not_iff : ¬(a ↔ b) ↔ (¬a ↔ b) :=
Decidable.not_iff

end Classical

/-! ## equality -/
Expand Down
13 changes: 7 additions & 6 deletions Std/Tactic/Omega/MinNatAbs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ so we keep it in the `Std/Tactic/Omega` directory
-/

open Classical

namespace List

Expand All @@ -30,6 +29,7 @@ We completely characterize the function via
-/
def nonzeroMinimum (xs : List Nat) : Nat := xs.filter (· ≠ 0) |>.minimum? |>.getD 0

open Classical in
@[simp] theorem nonzeroMinimum_eq_zero_iff {xs : List Nat} :
xs.nonzeroMinimum = 0 ↔ ∀ x ∈ xs, x = 0 := by
simp [nonzeroMinimum, Option.getD_eq_iff, minimum?_eq_none_iff, minimum?_eq_some_iff',
Expand Down Expand Up @@ -85,13 +85,14 @@ theorem nonzeroMinimum_eq_of_nonzero {xs : List Nat} (h : xs.nonzeroMinimum ≠
theorem nonzeroMinimum_le_iff {xs : List Nat} {y : Nat} :
xs.nonzeroMinimum ≤ y ↔ xs.nonzeroMinimum = 0 ∨ ∃ x ∈ xs, x ≤ y ∧ x ≠ 0 := by
refine ⟨fun h => ?_, fun h => ?_⟩
· rw [Decidable.or_iff_not_imp_right]
simp only [ne_eq, not_exists, not_and, not_not, nonzeroMinimum_eq_zero_iff]
· rw [Classical.or_iff_not_imp_right]
simp only [ne_eq, not_exists, not_and, Classical.not_not, nonzeroMinimum_eq_zero_iff]
intro w
apply nonzeroMinimum_eq_zero_iff.mp
by_cases p : xs.nonzeroMinimum = 0
· exact p
· exact w _ (nonzeroMinimum_mem p) h
if p : xs.nonzeroMinimum = 0 then
exact p
else
exact w _ (nonzeroMinimum_mem p) h
· match h with
| .inl h => simp [h]
| .inr ⟨x, m, le, ne⟩ => exact Nat.le_trans (nonzeroMinimum_le m ne) le
Expand Down

0 comments on commit 257ae8a

Please sign in to comment.