Skip to content

Commit

Permalink
refactor(data/fin/basic): reformulate fin.strict_mono_iff_lt_succ (#…
Browse files Browse the repository at this point in the history
…14482)

Use `fin.succ_cast` and `fin.succ`. This way we lose the case `n = 0`
but the statement looks more natural in other cases. Also add versions
for `monotone`, `antitone`, and `strict_anti`.
  • Loading branch information
urkud committed Jun 4, 2022
1 parent cab5a45 commit 8a6a793
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 20 deletions.
3 changes: 1 addition & 2 deletions src/combinatorics/composition.lean
Expand Up @@ -207,8 +207,7 @@ a virtual point at the right of the last block, to make for a nice equiv with
`composition_as_set n`. -/
def boundary : fin (c.length + 1) ↪o fin (n+1) :=
order_embedding.of_strict_mono (λ i, ⟨c.size_up_to i, nat.lt_succ_of_le (c.size_up_to_le i)⟩) $
fin.strict_mono_iff_lt_succ.2 $ λ i hi, c.size_up_to_strict_mono $
lt_of_add_lt_add_right hi
fin.strict_mono_iff_lt_succ.2 $ λ ⟨i, hi⟩, c.size_up_to_strict_mono hi

@[simp] lemma boundary_zero : c.boundary 0 = 0 :=
by simp [boundary, fin.ext_iff]
Expand Down
53 changes: 36 additions & 17 deletions src/data/fin/basic.lean
Expand Up @@ -318,23 +318,6 @@ rel_embedding.ext $ funext_iff.1 $ strict_mono_unique f.strict_mono g.strict_mon

end

/-- A function `f` on `fin n` is strictly monotone if and only if `f i < f (i+1)` for all `i`. -/
lemma strict_mono_iff_lt_succ {α : Type*} [preorder α] {f : fin n → α} :
strict_mono f ↔ ∀ i (h : i + 1 < n), f ⟨i, lt_of_le_of_lt (nat.le_succ i) h⟩ < f ⟨i+1, h⟩ :=
begin
split,
{ assume H i hi,
apply H,
exact nat.lt_succ_self _ },
{ assume H,
have A : ∀ i j (h : i < j) (h' : j < n), f ⟨i, lt_trans h h'⟩ < f ⟨j, h'⟩,
{ assume i j h h',
induction h with k h IH,
{ exact H _ _ },
{ exact lt_trans (IH (nat.lt_of_succ_lt h')) (H _ _) } },
assume i j hij,
convert A (i : ℕ) (j : ℕ) hij j.2; ext; simp only [subtype.coe_eta] }
end

end order

Expand Down Expand Up @@ -1152,6 +1135,42 @@ end

end rec

lemma lift_fun_iff_succ {α : Type*} (r : α → α → Prop) [is_trans α r] {f : fin (n + 1) → α} :
((<) ⇒ r) f f ↔ ∀ i : fin n, r (f i.cast_succ) (f i.succ) :=
begin
split,
{ intros H i,
exact H i.cast_succ_lt_succ },
{ refine λ H i, fin.induction _ _,
{ exact λ h, (h.not_le (zero_le i)).elim },
{ intros j ihj hij,
rw [← le_cast_succ_iff] at hij,
rcases hij.eq_or_lt with rfl|hlt,
exacts [H j, trans (ihj hlt) (H j)] } }
end

/-- A function `f` on `fin (n + 1)` is strictly monotone if and only if `f i < f (i + 1)`
for all `i`. -/
lemma strict_mono_iff_lt_succ {α : Type*} [preorder α] {f : fin (n + 1) → α} :
strict_mono f ↔ ∀ i : fin n, f i.cast_succ < f i.succ :=
lift_fun_iff_succ (<)

/-- A function `f` on `fin (n + 1)` is monotone if and only if `f i ≤ f (i + 1)` for all `i`. -/
lemma monotone_iff_le_succ {α : Type*} [preorder α] {f : fin (n + 1) → α} :
monotone f ↔ ∀ i : fin n, f i.cast_succ ≤ f i.succ :=
monotone_iff_forall_lt.trans $ lift_fun_iff_succ (≤)

/-- A function `f` on `fin (n + 1)` is strictly antitone if and only if `f (i + 1) < f i`
for all `i`. -/
lemma strict_anti_iff_succ_lt {α : Type*} [preorder α] {f : fin (n + 1) → α} :
strict_anti f ↔ ∀ i : fin n, f i.succ < f i.cast_succ :=
lift_fun_iff_succ (>)

/-- A function `f` on `fin (n + 1)` is antitone if and only if `f (i + 1) ≤ f i` for all `i`. -/
lemma antitone_iff_succ_le {α : Type*} [preorder α] {f : fin (n + 1) → α} :
antitone f ↔ ∀ i : fin n, f i.succ ≤ f i.cast_succ :=
antitone_iff_forall_lt.trans $ lift_fun_iff_succ (≥)

section add_group

open nat int
Expand Down
2 changes: 1 addition & 1 deletion src/order/jordan_holder.lean
Expand Up @@ -163,7 +163,7 @@ theorem lt_succ (s : composition_series X) (i : fin s.length) :
lt_of_is_maximal (s.step _)

protected theorem strict_mono (s : composition_series X) : strict_mono s :=
fin.strict_mono_iff_lt_succ.2 (λ i h, s.lt_succ ⟨i, nat.lt_of_succ_lt_succ h⟩)
fin.strict_mono_iff_lt_succ.2 s.lt_succ

protected theorem injective (s : composition_series X) : function.injective s :=
s.strict_mono.injective
Expand Down

0 comments on commit 8a6a793

Please sign in to comment.