Skip to content

Commit

Permalink
feat(algebra/order): ne_iff_lt_iff_le
Browse files Browse the repository at this point in the history
 
 (#5731)




Co-authored-by: Rob Lewis <Rob.y.lewis@gmail.com>
  • Loading branch information
pechersky and robertylewis committed Jan 14, 2021
1 parent 159542a commit 8bc26d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
3 changes: 3 additions & 0 deletions src/algebra/order.lean
Expand Up @@ -134,6 +134,9 @@ alias eq_or_lt_of_le ← has_le.le.eq_or_lt
lemma ne.le_iff_lt [partial_order α] {a b : α} (h : a ≠ b) : a ≤ b ↔ a < b :=
⟨λ h', lt_of_le_of_ne h' h, λ h, h.le⟩

@[simp] lemma ne_iff_lt_iff_le [partial_order α] {a b : α} : (a ≠ b ↔ a < b) ↔ a ≤ b :=
⟨λ h, classical.by_cases le_of_eq (le_of_lt ∘ h.mp), λ h, ⟨lt_of_le_of_ne h, ne_of_lt⟩⟩

lemma lt_of_not_ge' [linear_order α] {a b : α} (h : ¬ b ≤ a) : a < b :=
((le_total _ _).resolve_right h).lt_of_not_le h

Expand Down
26 changes: 0 additions & 26 deletions src/data/buffer/parser/basic.lean
Expand Up @@ -36,32 +36,6 @@ For some `parse_result α`, give the position at which the result was provided,
| (done n _) := n
| (fail n _) := n

section lemmas

-- TODO: place in relevant files

variables {α : Type*} {P Q : α → Prop} {Q' : Prop} {x : α}

@[simp] lemma ne_iff_lt_iff_le {n m : ℕ} : (n ≠ m ↔ n < m) ↔ n ≤ m :=
begin
refine ⟨λ h, _, λ h, _⟩,
{ by_cases H : n = m,
{ exact le_of_eq H },
{ exact le_of_lt (h.mp H) } },
{ rcases eq_or_lt_of_le h with rfl|H,
{ simp },
{ simp [H, ne_of_lt] } }
end

lemma nat.le_of_sub_eq_pos {m n k : ℕ} (h : m - n = k) (hk : 0 < k) : n ≤ m :=
begin
contrapose! hk,
rw nat.sub_eq_zero_of_le (le_of_lt hk) at h,
rw h
end

end lemmas

namespace parser

section defn_lemmas
Expand Down

0 comments on commit 8bc26d1

Please sign in to comment.