Skip to content

Commit fb29af6

Browse files
int-y1ChrisHughes24
andcommitted
feat: port Data.Fin.Tuple.Monotone (#1827)
Co-authored-by: ChrisHughes24 <chrishughes24@gmail.com>
1 parent e1e5bf4 commit fb29af6

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ import Mathlib.Data.Fin.Basic
257257
import Mathlib.Data.Fin.Fin2
258258
import Mathlib.Data.Fin.SuccPred
259259
import Mathlib.Data.Fin.Tuple.Basic
260+
import Mathlib.Data.Fin.Tuple.Monotone
260261
import Mathlib.Data.Fin.Tuple.Sort
261262
import Mathlib.Data.Fin.VecNotation
262263
import Mathlib.Data.FinEnum
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/-
2+
Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Yury G. Kudryashov
5+
6+
! This file was ported from Lean 3 source module data.fin.tuple.monotone
7+
! leanprover-community/mathlib commit e3d9ab8faa9dea8f78155c6c27d62a621f4c152d
8+
! Please do not edit these lines, except to modify the commit id
9+
! if you have ported upstream changes.
10+
-/
11+
import Mathlib.Data.Fin.VecNotation
12+
13+
/-!
14+
# Monotone finite sequences
15+
16+
In this file we prove `simp` lemmas that allow to simplify propositions like `Monotone ![a, b, c]`.
17+
-/
18+
19+
20+
open Set Fin Matrix Function
21+
22+
variable {α : Type _}
23+
24+
theorem lift_fun_vecCons {n : ℕ} (r : α → α → Prop) [IsTrans α r] {f : Fin (n + 1) → α} {a : α} :
25+
((· < ·) ⇒ r) (vecCons a f) (vecCons a f) ↔ r a (f 0) ∧ ((· < ·) ⇒ r) f f := by
26+
simp only [lift_fun_iff_succ r, forall_fin_succ, cons_val_succ, cons_val_zero, ← succ_castSucc,
27+
castSucc_zero]
28+
#align lift_fun_vec_cons lift_fun_vecCons
29+
30+
variable [Preorder α] {n : ℕ} {f : Fin (n + 1) → α} {a : α}
31+
32+
@[simp]
33+
theorem strictMono_vecCons : StrictMono (vecCons a f) ↔ a < f 0 ∧ StrictMono f :=
34+
lift_fun_vecCons (· < ·)
35+
#align strict_mono_vec_cons strictMono_vecCons
36+
37+
@[simp]
38+
theorem monotone_vecCons : Monotone (vecCons a f) ↔ a ≤ f 0 ∧ Monotone f := by
39+
simpa only [monotone_iff_forall_lt] using @lift_fun_vecCons α n (· ≤ ·) _ f a
40+
#align monotone_vec_cons monotone_vecCons
41+
42+
--Porting note: new lemma, in Lean3 would be proven by `Subsingleton.monotone`
43+
@[simp]
44+
theorem monotone_vecEmpty : Monotone (vecCons a vecEmpty)
45+
| ⟨0, _⟩, ⟨0, _⟩, _ => le_refl _
46+
47+
--Porting note: new lemma, in Lean3 would be proven by `Subsingleton.strictMono`
48+
@[simp]
49+
theorem strictMono_vecEmpty : StrictMono (vecCons a vecEmpty)
50+
| ⟨0, _⟩, ⟨0, _⟩, h => (irrefl _ h).elim
51+
52+
@[simp]
53+
theorem strictAnti_vecCons : StrictAnti (vecCons a f) ↔ f 0 < a ∧ StrictAnti f :=
54+
lift_fun_vecCons (· > ·)
55+
#align strict_anti_vec_cons strictAnti_vecCons
56+
57+
@[simp]
58+
theorem antitone_vecCons : Antitone (vecCons a f) ↔ f 0 ≤ a ∧ Antitone f :=
59+
@monotone_vecCons αᵒᵈ _ _ _ _
60+
#align antitone_vec_cons antitone_vecCons
61+
62+
--Porting note: new lemma, in Lean3 would be proven by `Subsingleton.antitone`
63+
@[simp]
64+
theorem antitone_vecEmpty : Antitone (vecCons a vecEmpty)
65+
| ⟨0, _⟩, ⟨0, _⟩, _ => le_refl _
66+
67+
--Porting note: new lemma, in Lean3 would be proven by `Subsingleton.strictAnti`
68+
@[simp]
69+
theorem strictAnti_vecEmpty : StrictAnti (vecCons a vecEmpty)
70+
| ⟨0, _⟩, ⟨0, _⟩, h => (irrefl _ h).elim
71+
72+
theorem StrictMono.vecCons (hf : StrictMono f) (ha : a < f 0) : StrictMono (vecCons a f) :=
73+
strictMono_vecCons.2 ⟨ha, hf⟩
74+
#align strict_mono.vec_cons StrictMono.vecCons
75+
76+
theorem StrictAnti.vecCons (hf : StrictAnti f) (ha : f 0 < a) : StrictAnti (vecCons a f) :=
77+
strictAnti_vecCons.2 ⟨ha, hf⟩
78+
#align strict_anti.vec_cons StrictAnti.vecCons
79+
80+
theorem Monotone.vecCons (hf : Monotone f) (ha : a ≤ f 0) : Monotone (vecCons a f) :=
81+
monotone_vecCons.2 ⟨ha, hf⟩
82+
#align monotone.vec_cons Monotone.vecCons
83+
84+
theorem Antitone.vecCons (hf : Antitone f) (ha : f 0 ≤ a) : Antitone (vecCons a f) :=
85+
antitone_vecCons.2 ⟨ha, hf⟩
86+
#align antitone.vec_cons Antitone.vecCons
87+
88+
example : Monotone ![1, 2, 2, 3] := by simp

0 commit comments

Comments
 (0)