Skip to content

Commit f17018b

Browse files
feat(Data/Finsupp/MonomialOrder) : lexicographic order on Unique (#20699)
Two lemmas for lexicographic order on a`Unique` type are added.
1 parent b848c8d commit f17018b

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

Mathlib/Data/Finsupp/Lex.lean

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ theorem lex_eq_invImage_dfinsupp_lex (r : α → α → Prop) (s : N → N → P
4646
instance [LT α] [LT N] : LT (Lex (α →₀ N)) :=
4747
fun f g ↦ Finsupp.Lex (· < ·) (· < ·) (ofLex f) (ofLex g)⟩
4848

49+
theorem lex_lt_iff [LT α] [LT N] {a b : Lex (α →₀ N)} :
50+
a < b ↔ ∃ i, (∀ j, j < i → ofLex a j = ofLex b j) ∧ ofLex a i < ofLex b i :=
51+
Finsupp.lex_def
52+
53+
theorem lex_lt_iff_of_unique [Preorder α] [LT N] [Unique α] {a b : Lex (α →₀ N)} :
54+
a < b ↔ ofLex a default < ofLex b default := by
55+
simp only [lex_lt_iff, Unique.exists_iff, and_iff_right_iff_imp]
56+
refine fun _ j hj ↦ False.elim (lt_irrefl j ?_)
57+
simpa only [Unique.uniq] using hj
58+
4959
theorem lex_lt_of_lt_of_preorder [Preorder N] (r) [IsStrictOrder α r] {x y : α →₀ N} (hlt : x < y) :
5060
∃ i, (∀ j, r j i → x j ≤ y j ∧ y j ≤ x j) ∧ x i < y i :=
5161
DFinsupp.lex_lt_of_lt_of_preorder r (id hlt : x.toDFinsupp < y.toDFinsupp)
@@ -104,6 +114,13 @@ theorem lt_of_forall_lt_of_lt (a b : Lex (α →₀ N)) (i : α) :
104114
(∀ j < i, ofLex a j = ofLex b j) → ofLex a i < ofLex b i → a < b :=
105115
fun h1 h2 ↦ ⟨i, h1, h2⟩
106116

117+
theorem lex_le_iff_of_unique [Unique α] {a b : Lex (α →₀ N)} :
118+
a ≤ b ↔ ofLex a default ≤ ofLex b default := by
119+
simp only [le_iff_eq_or_lt, EmbeddingLike.apply_eq_iff_eq]
120+
apply or_congr _ lex_lt_iff_of_unique
121+
conv_lhs => rw [← toLex_ofLex a, ← toLex_ofLex b, toLex_inj]
122+
simp only [Finsupp.ext_iff, Unique.forall_iff]
123+
107124
end NHasZero
108125

109126
section Covariants

Mathlib/Data/Finsupp/MonomialOrder.lean

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,6 @@ noncomputable instance {α N : Type*} [LinearOrder α] [OrderedCancelAddCommMono
113113
le_of_add_le_add_left a b c h := by simpa only [add_le_add_iff_left] using h
114114
add_le_add_left a b h c := by simpa only [add_le_add_iff_left] using h
115115

116-
theorem Finsupp.lex_lt_iff {α N : Type*} [LinearOrder α] [LinearOrder N] [Zero N]
117-
{a b : Lex (α →₀ N)} :
118-
a < b ↔ ∃ i, (∀ j, j< i → ofLex a j = ofLex b j) ∧ ofLex a i < ofLex b i :=
119-
Finsupp.lex_def
120-
121-
theorem Finsupp.lex_le_iff {α N : Type*} [LinearOrder α] [LinearOrder N] [Zero N]
122-
{a b : Lex (α →₀ N)} :
123-
a ≤ b ↔ a = b ∨ ∃ i, (∀ j, j< i → ofLex a j = ofLex b j) ∧ ofLex a i < ofLex b i := by
124-
rw [le_iff_eq_or_lt, Finsupp.lex_lt_iff]
125-
126116
/-- for the lexicographic ordering, X 0 * X 1 < X 0 ^ 2 -/
127117
example : toLex (Finsupp.single 0 2) > toLex (Finsupp.single 0 1 + Finsupp.single 1 1) := by
128118
use 0; simp
@@ -152,4 +142,12 @@ theorem MonomialOrder.lex_le_iff [WellFoundedGT σ] {c d : σ →₀ ℕ} :
152142
theorem MonomialOrder.lex_lt_iff [WellFoundedGT σ] {c d : σ →₀ ℕ} :
153143
c ≺[lex] d ↔ toLex c < toLex d := Iff.rfl
154144

145+
theorem MonomialOrder.lex_lt_iff_of_unique [Unique σ] {c d : σ →₀ ℕ} :
146+
c ≺[lex] d ↔ c default < d default := by
147+
simp only [MonomialOrder.lex_lt_iff, Finsupp.lex_lt_iff_of_unique, ofLex_toLex]
148+
149+
theorem MonomialOrder.lex_le_iff_of_unique [Unique σ] {c d : σ →₀ ℕ} :
150+
c ≼[lex] d ↔ c default ≤ d default := by
151+
simp only [MonomialOrder.lex_le_iff, Finsupp.lex_le_iff_of_unique, ofLex_toLex]
152+
155153
end Lex

0 commit comments

Comments
 (0)