data.list.cycle
⟷
Mathlib.Data.List.Cycle
The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
@@ -805,6 +805,19 @@ by rw [range_succ, ←coe_cons_eq_coe_append, chain_coe_cons, ←range_succ, cha
variables {r : α → α → Prop} {s : cycle α}
+theorem chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r₂ a b) (p : chain r₁ s) :
+ chain r₂ s :=
+begin
+ induction s using cycle.induction_on,
+ { triv },
+ { rw chain_coe_cons at ⊢ p,
+ exact p.imp H }
+end
+
+/-- As a function from a relation to a predicate, `chain` is monotonic. -/
+theorem chain_mono : monotone (chain : (α → α → Prop) → cycle α → Prop) :=
+λ a b hab s, chain.imp hab
+
theorem chain_of_pairwise : (∀ (a ∈ s) (b ∈ s), r a b) → chain r s :=
begin
induction s using cycle.induction_on with a l _,
@@ -845,6 +858,17 @@ theorem chain_iff_pairwise [is_trans α r] : chain r s ↔ ∀ (a ∈ s) (b ∈
{ exact trans (hs.2.2 b hb) (hs.1 c (or.inl hc)) }
end, cycle.chain_of_pairwise⟩
+theorem chain.eq_nil_of_irrefl [is_trans α r] [is_irrefl α r] (h : chain r s) : s = nil :=
+begin
+ induction s using cycle.induction_on with a l _ h,
+ { refl },
+ { have ha := mem_cons_self a l,
+ exact (irrefl_of r a $ chain_iff_pairwise.1 h a ha a ha).elim }
+end
+
+theorem chain.eq_nil_of_well_founded [is_well_founded α r] (h : chain r s) : s = nil :=
+chain.eq_nil_of_irrefl $ h.imp $ λ _ _, relation.trans_gen.single
+
theorem forall_eq_of_chain [is_trans α r] [is_antisymm α r]
(hs : chain r s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) : a = b :=
by { rw chain_iff_pairwise at hs, exact antisymm (hs a ha b hb) (hs b hb a ha) }
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
@@ -626,6 +626,10 @@ rfl
@[simp] lemma map_eq_nil {β : Type*} (f : α → β) (s : cycle α) : map f s = nil ↔ s = nil :=
quotient.induction_on' s (by simp)
+@[simp] lemma mem_map {β : Type*} {f : α → β} {b : β} {s : cycle α} :
+ b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
+quotient.induction_on' s (by simp)
+
/-- The `multiset` of lists that can make the cycle. -/
def lists (s : cycle α) : multiset (list α) :=
quotient.lift_on' s
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(no changes)
(first ported)
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -83,7 +83,7 @@ theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x
induction' xs with y ys IH
· cases x_mem
cases' ys with z zs
- · simp at x_mem x_ne ; contradiction
+ · simp at x_mem x_ne; contradiction
by_cases h : x = y
· rw [h, next_or_self_cons_cons, next_or_self_cons_cons]
· rw [next_or, next_or, IH] <;> simpa [h] using x_mem
@@ -99,7 +99,7 @@ theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x
· simpa using h
· by_cases hx : x = y
· simp [hx]
- · rw [next_or_cons_of_ne _ _ _ _ hx] at h
+ · rw [next_or_cons_of_ne _ _ _ _ hx] at h
simpa [hx] using IH h
#align list.mem_of_next_or_ne List.mem_of_nextOr_ne
-/
@@ -204,7 +204,7 @@ theorem next_ne_head_ne_getLast (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
next (y :: l) x h = next l x (by simpa [hy] using h) :=
by
rw [next, next, next_or_cons_of_ne _ _ _ _ hy, next_or_eq_next_or_of_mem_of_ne]
- · rwa [last_cons] at hx
+ · rwa [last_cons] at hx
· simpa [hy] using h
#align list.next_ne_head_ne_last List.next_ne_head_ne_getLast
-/
@@ -231,7 +231,7 @@ theorem next_getLast_cons (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
suffices k.succ = l.length by simpa [this] using hk
cases' l with hd tl
· simpa using hk
- · rw [nodup_iff_nth_le_inj] at hl
+ · rw [nodup_iff_nth_le_inj] at hl
rw [length, Nat.succ_inj]
apply hl
simpa [init_eq_take, nth_le_take', last_eq_nth_le] using hk'
@@ -333,7 +333,7 @@ theorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
by
intro H
suffices n.succ = 0 by simpa
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn Nat.succ_pos' _
simpa using H
rcases hn'.eq_or_lt with (hn'' | hn'')
@@ -350,7 +350,7 @@ theorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
· rw [last_eq_nth_le]
intro H
suffices n.succ = l.length.succ by exact absurd hn'' this.ge.not_lt
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn _ _
· simp
· simpa using H
@@ -368,8 +368,8 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
· simp
· rcases n with (_ | _ | n)
· simpa [last_eq_nth_le, Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)]
- · simp only [mem_cons_iff, nodup_cons] at h
- push_neg at h
+ · simp only [mem_cons_iff, nodup_cons] at h
+ push_neg at h
simp [add_comm, prev_cons_cons_of_ne, h.left.left.symm]
· rw [prev_ne_cons_cons]
· convert hl _ _ h.of_cons _ using 1
@@ -380,7 +380,7 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
rw [this]
congr
simp only [Nat.add_succ_sub_one, add_zero, length]
- simp only [length, Nat.succ_lt_succ_iff] at hn
+ simp only [length, Nat.succ_lt_succ_iff] at hn
set k := l.length
rw [Nat.succ_add, ← Nat.add_succ, Nat.add_mod_right, Nat.succ_add, ← Nat.add_succ _ k,
Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt]
@@ -388,12 +388,12 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
· exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn)
· intro H
suffices n.succ.succ = 0 by simpa
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn Nat.succ_pos' _
simpa using H
· intro H
suffices n.succ.succ = 1 by simpa
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn (Nat.succ_lt_succ Nat.succ_pos') _
simpa using H
#align list.prev_nth_le List.prev_nthLe
@@ -714,7 +714,7 @@ theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
by
induction' s using Quot.inductionOn with l
simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, Nat.lt_add_one_iff,
- length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h
+ length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h
rcases h with (rfl | ⟨z, rfl⟩) <;> simp
#align cycle.subsingleton.congr Cycle.Subsingleton.congr
-/
@@ -738,7 +738,7 @@ theorem nontrivial_coe_nodup_iff {l : List α} (hl : l.Nodup) :
· simp only [mem_cons_iff, exists_prop, mem_coe_iff, List.length, Ne.def, Nat.succ_le_succ_iff,
zero_le, iff_true_iff]
refine' ⟨hd, hd', _, by simp⟩
- simp only [not_or, mem_cons_iff, nodup_cons] at hl
+ simp only [not_or, mem_cons_iff, nodup_cons] at hl
exact hl.left.left
#align cycle.nontrivial_coe_nodup_iff Cycle.nontrivial_coe_nodup_iff
-/
@@ -757,7 +757,7 @@ theorem length_nontrivial {s : Cycle α} (h : Nontrivial s) : 2 ≤ length s :=
induction' s using Quot.inductionOn with l
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simpa using hx
- · simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy
+ · simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy
simpa [hx, hy] using hxy
· simp [bit0]
#align cycle.length_nontrivial Cycle.length_nontrivial
@@ -807,7 +807,7 @@ theorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬S
by
rw [length_subsingleton_iff]
induction s using Quotient.inductionOn'
- simp only [mk'_eq_coe, nodup_coe_iff] at h
+ simp only [mk'_eq_coe, nodup_coe_iff] at h
simp [h, Nat.succ_le_iff]
#align cycle.nodup.nontrivial_iff Cycle.Nodup.nontrivial_iff
-/
@@ -1087,13 +1087,13 @@ def Chain (r : α → α → Prop) (c : Cycle α) : Prop :=
· unfold chain._match_1
cases' hab with n hn
induction' n with d hd generalizing a b l m
- · simp only [rotate_zero] at hn
+ · simp only [rotate_zero] at hn
rw [hn.1, hn.2]
· cases' l with c s
- · simp only [rotate_singleton] at hn
+ · simp only [rotate_singleton] at hn
rw [hn.1, hn.2]
· rw [Nat.succ_eq_one_add, ← rotate_rotate, rotate_cons_succ, rotate_zero, cons_append] at
- hn
+ hn
rw [← hd c _ _ _ hn]
simp [and_comm]
#align cycle.chain Cycle.Chain
@@ -1185,13 +1185,13 @@ theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s :=
pairwise_append.2
⟨pairwise_of_forall_mem_list fun b hb c hc => hs b (Hl hb) c (Hl hc),
pairwise_singleton r a, fun b hb c hc => _⟩⟩
- · rw [mem_append] at hb
+ · rw [mem_append] at hb
cases hb
· exact hs a Ha b (Hl hb)
- · rw [mem_singleton] at hb
+ · rw [mem_singleton] at hb
rw [hb]
exact hs a Ha a Ha
- · rw [mem_singleton] at hc
+ · rw [mem_singleton] at hc
rw [hc]
exact hs b (Hl hb) a Ha
#align cycle.chain_of_pairwise Cycle.chain_of_pairwise
@@ -1203,10 +1203,10 @@ theorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈
induction' s using Cycle.induction_on with a l _
exact fun _ b hb => hb.elim
intro hs b hb c hc
- rw [Cycle.chain_coe_cons, chain_iff_pairwise] at hs
+ rw [Cycle.chain_coe_cons, chain_iff_pairwise] at hs
simp only [pairwise_append, pairwise_cons, mem_append, mem_singleton, List.not_mem_nil,
- IsEmpty.forall_iff, imp_true_iff, pairwise.nil, forall_eq, true_and_iff] at hs
- simp only [mem_coe_iff, mem_cons_iff] at hb hc
+ IsEmpty.forall_iff, imp_true_iff, pairwise.nil, forall_eq, true_and_iff] at hs
+ simp only [mem_coe_iff, mem_cons_iff] at hb hc
rcases hb with (rfl | hb) <;> rcases hc with (rfl | hc)
· exact hs.1 c (Or.inr rfl)
· exact hs.1 c (Or.inl hc)
@@ -1233,7 +1233,7 @@ theorem Chain.eq_nil_of_well_founded [IsWellFounded α r] (h : Chain r s) : s =
#print Cycle.forall_eq_of_chain /-
theorem forall_eq_of_chain [IsTrans α r] [IsAntisymm α r] (hs : Chain r s) {a b : α} (ha : a ∈ s)
- (hb : b ∈ s) : a = b := by rw [chain_iff_pairwise] at hs ;
+ (hb : b ∈ s) : a = b := by rw [chain_iff_pairwise] at hs;
exact antisymm (hs a ha b hb) (hs b hb a ha)
#align cycle.forall_eq_of_chain Cycle.forall_eq_of_chain
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/65a1391a0106c9204fe45bc73a039f056558cb83
@@ -232,7 +232,7 @@ theorem next_getLast_cons (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
cases' l with hd tl
· simpa using hk
· rw [nodup_iff_nth_le_inj] at hl
- rw [length, Nat.succ_inj']
+ rw [length, Nat.succ_inj]
apply hl
simpa [init_eq_take, nth_le_take', last_eq_nth_le] using hk'
#align list.next_last_cons List.next_getLast_cons
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce64cd319bb6b3e82f31c2d38e79080d377be451
@@ -3,9 +3,9 @@ Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
-import Mathbin.Data.Multiset.Sort
-import Mathbin.Data.Fintype.List
-import Mathbin.Data.List.Rotate
+import Data.Multiset.Sort
+import Data.Fintype.List
+import Data.List.Rotate
#align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49"
mathlib commit https://github.com/leanprover-community/mathlib/commit/63721b2c3eba6c325ecf8ae8cca27155a4f6306f
@@ -448,7 +448,7 @@ theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
#print List.prev_reverse_eq_next /-
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- prev l.reverse x (mem_reverse'.mpr hx) = next l x hx :=
+ prev l.reverse x (mem_reverse.mpr hx) = next l x hx :=
by
obtain ⟨k, hk, rfl⟩ := nth_le_of_mem hx
have lpos : 0 < l.length := k.zero_le.trans_lt hk
@@ -469,7 +469,7 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l)
#print List.next_reverse_eq_prev /-
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- next l.reverse x (mem_reverse'.mpr hx) = prev l x hx :=
+ next l.reverse x (mem_reverse.mpr hx) = prev l x hx :=
by
convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
exact (reverse_reverse l).symm
@@ -636,7 +636,7 @@ theorem reverse_coe (l : List α) : (l : Cycle α).reverse = l.reverse :=
#print Cycle.mem_reverse_iff /-
@[simp]
theorem mem_reverse_iff {a : α} {s : Cycle α} : a ∈ s.reverse ↔ a ∈ s :=
- Quot.inductionOn s fun _ => mem_reverse'
+ Quot.inductionOn s fun _ => mem_reverse
#align cycle.mem_reverse_iff Cycle.mem_reverse_iff
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/8ea5598db6caeddde6cb734aa179cc2408dbd345
@@ -2,16 +2,13 @@
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-
-! This file was ported from Lean 3 source module data.list.cycle
-! leanprover-community/mathlib commit 7413128c3bcb3b0818e3e18720abc9ea3100fb49
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathbin.Data.Multiset.Sort
import Mathbin.Data.Fintype.List
import Mathbin.Data.List.Rotate
+#align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49"
+
/-!
# Cycles of a list
mathlib commit https://github.com/leanprover-community/mathlib/commit/9fb8964792b4237dac6200193a0d533f1b3f7423
@@ -201,6 +201,7 @@ theorem next_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) : next (x :: z :: l)
#align list.next_cons_cons_eq List.next_cons_cons_eq
-/
+#print List.next_ne_head_ne_getLast /-
theorem next_ne_head_ne_getLast (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
(hx : x ≠ getLast (y :: l) (cons_ne_nil _ _)) :
next (y :: l) x h = next l x (by simpa [hy] using h) :=
@@ -209,6 +210,7 @@ theorem next_ne_head_ne_getLast (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
· rwa [last_cons] at hx
· simpa [hy] using h
#align list.next_ne_head_ne_last List.next_ne_head_ne_getLast
+-/
#print List.next_cons_concat /-
theorem next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l)
@@ -220,6 +222,7 @@ theorem next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l)
#align list.next_cons_concat List.next_cons_concat
-/
+#print List.next_getLast_cons /-
theorem next_getLast_cons (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
(hx : x = getLast (y :: l) (cons_ne_nil _ _)) (hl : Nodup l) : next (y :: l) x h = y :=
by
@@ -236,6 +239,7 @@ theorem next_getLast_cons (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
apply hl
simpa [init_eq_take, nth_le_take', last_eq_nth_le] using hk'
#align list.next_last_cons List.next_getLast_cons
+-/
#print List.prev_getLast_cons' /-
theorem prev_getLast_cons' (y : α) (h : x ∈ y :: l) (hx : x = y) :
@@ -291,8 +295,6 @@ theorem prev_ne_cons_cons (y z : α) (h : x ∈ y :: z :: l) (hy : x ≠ y) (hz
#align list.prev_ne_cons_cons List.prev_ne_cons_cons
-/
-include h
-
#print List.next_mem /-
theorem next_mem : l.next x h ∈ l :=
nextOr_mem (nthLe_mem _ _ _)
@@ -835,10 +837,12 @@ theorem nil_toMultiset : nil.toMultiset = (0 : Multiset α) :=
#align cycle.nil_to_multiset Cycle.nil_toMultiset
-/
+#print Cycle.card_toMultiset /-
@[simp]
theorem card_toMultiset (s : Cycle α) : s.toMultiset.card = s.length :=
Quotient.inductionOn' s (by simp)
#align cycle.card_to_multiset Cycle.card_toMultiset
+-/
#print Cycle.toMultiset_eq_nil /-
@[simp]
mathlib commit https://github.com/leanprover-community/mathlib/commit/5f25c089cb34db4db112556f23c50d12da81b297
@@ -370,7 +370,7 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
· rcases n with (_ | _ | n)
· simpa [last_eq_nth_le, Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)]
· simp only [mem_cons_iff, nodup_cons] at h
- push_neg at h
+ push_neg at h
simp [add_comm, prev_cons_cons_of_ne, h.left.left.symm]
· rw [prev_ne_cons_cons]
· convert hl _ _ h.of_cons _ using 1
@@ -472,7 +472,7 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l)
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
next l.reverse x (mem_reverse'.mpr hx) = prev l x hx :=
by
- convert(prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
+ convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
exact (reverse_reverse l).symm
#align list.next_reverse_eq_prev List.next_reverse_eq_prev
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/cca40788df1b8755d5baf17ab2f27dacc2e17acb
@@ -86,7 +86,7 @@ theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x
induction' xs with y ys IH
· cases x_mem
cases' ys with z zs
- · simp at x_mem x_ne; contradiction
+ · simp at x_mem x_ne ; contradiction
by_cases h : x = y
· rw [h, next_or_self_cons_cons, next_or_self_cons_cons]
· rw [next_or, next_or, IH] <;> simpa [h] using x_mem
@@ -102,7 +102,7 @@ theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x
· simpa using h
· by_cases hx : x = y
· simp [hx]
- · rw [next_or_cons_of_ne _ _ _ _ hx] at h
+ · rw [next_or_cons_of_ne _ _ _ _ hx] at h
simpa [hx] using IH h
#align list.mem_of_next_or_ne List.mem_of_nextOr_ne
-/
@@ -206,7 +206,7 @@ theorem next_ne_head_ne_getLast (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
next (y :: l) x h = next l x (by simpa [hy] using h) :=
by
rw [next, next, next_or_cons_of_ne _ _ _ _ hy, next_or_eq_next_or_of_mem_of_ne]
- · rwa [last_cons] at hx
+ · rwa [last_cons] at hx
· simpa [hy] using h
#align list.next_ne_head_ne_last List.next_ne_head_ne_getLast
@@ -231,7 +231,7 @@ theorem next_getLast_cons (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
suffices k.succ = l.length by simpa [this] using hk
cases' l with hd tl
· simpa using hk
- · rw [nodup_iff_nth_le_inj] at hl
+ · rw [nodup_iff_nth_le_inj] at hl
rw [length, Nat.succ_inj']
apply hl
simpa [init_eq_take, nth_le_take', last_eq_nth_le] using hk'
@@ -334,7 +334,7 @@ theorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
by
intro H
suffices n.succ = 0 by simpa
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn Nat.succ_pos' _
simpa using H
rcases hn'.eq_or_lt with (hn'' | hn'')
@@ -351,7 +351,7 @@ theorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
· rw [last_eq_nth_le]
intro H
suffices n.succ = l.length.succ by exact absurd hn'' this.ge.not_lt
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn _ _
· simp
· simpa using H
@@ -369,8 +369,8 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
· simp
· rcases n with (_ | _ | n)
· simpa [last_eq_nth_le, Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)]
- · simp only [mem_cons_iff, nodup_cons] at h
- push_neg at h
+ · simp only [mem_cons_iff, nodup_cons] at h
+ push_neg at h
simp [add_comm, prev_cons_cons_of_ne, h.left.left.symm]
· rw [prev_ne_cons_cons]
· convert hl _ _ h.of_cons _ using 1
@@ -381,7 +381,7 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
rw [this]
congr
simp only [Nat.add_succ_sub_one, add_zero, length]
- simp only [length, Nat.succ_lt_succ_iff] at hn
+ simp only [length, Nat.succ_lt_succ_iff] at hn
set k := l.length
rw [Nat.succ_add, ← Nat.add_succ, Nat.add_mod_right, Nat.succ_add, ← Nat.add_succ _ k,
Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt]
@@ -389,12 +389,12 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
· exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn)
· intro H
suffices n.succ.succ = 0 by simpa
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn Nat.succ_pos' _
simpa using H
· intro H
suffices n.succ.succ = 1 by simpa
- rw [nodup_iff_nth_le_inj] at h
+ rw [nodup_iff_nth_le_inj] at h
refine' h _ _ hn (Nat.succ_lt_succ Nat.succ_pos') _
simpa using H
#align list.prev_nth_le List.prev_nthLe
@@ -715,7 +715,7 @@ theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
by
induction' s using Quot.inductionOn with l
simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, Nat.lt_add_one_iff,
- length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h
+ length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h
rcases h with (rfl | ⟨z, rfl⟩) <;> simp
#align cycle.subsingleton.congr Cycle.Subsingleton.congr
-/
@@ -723,7 +723,7 @@ theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
#print Cycle.Nontrivial /-
/-- A `s : cycle α` that is made up of at least two unique elements. -/
def Nontrivial (s : Cycle α) : Prop :=
- ∃ (x y : α)(h : x ≠ y), x ∈ s ∧ y ∈ s
+ ∃ (x y : α) (h : x ≠ y), x ∈ s ∧ y ∈ s
#align cycle.nontrivial Cycle.Nontrivial
-/
@@ -739,7 +739,7 @@ theorem nontrivial_coe_nodup_iff {l : List α} (hl : l.Nodup) :
· simp only [mem_cons_iff, exists_prop, mem_coe_iff, List.length, Ne.def, Nat.succ_le_succ_iff,
zero_le, iff_true_iff]
refine' ⟨hd, hd', _, by simp⟩
- simp only [not_or, mem_cons_iff, nodup_cons] at hl
+ simp only [not_or, mem_cons_iff, nodup_cons] at hl
exact hl.left.left
#align cycle.nontrivial_coe_nodup_iff Cycle.nontrivial_coe_nodup_iff
-/
@@ -758,7 +758,7 @@ theorem length_nontrivial {s : Cycle α} (h : Nontrivial s) : 2 ≤ length s :=
induction' s using Quot.inductionOn with l
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simpa using hx
- · simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy
+ · simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy
simpa [hx, hy] using hxy
· simp [bit0]
#align cycle.length_nontrivial Cycle.length_nontrivial
@@ -808,7 +808,7 @@ theorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬S
by
rw [length_subsingleton_iff]
induction s using Quotient.inductionOn'
- simp only [mk'_eq_coe, nodup_coe_iff] at h
+ simp only [mk'_eq_coe, nodup_coe_iff] at h
simp [h, Nat.succ_le_iff]
#align cycle.nodup.nontrivial_iff Cycle.Nodup.nontrivial_iff
-/
@@ -1086,13 +1086,13 @@ def Chain (r : α → α → Prop) (c : Cycle α) : Prop :=
· unfold chain._match_1
cases' hab with n hn
induction' n with d hd generalizing a b l m
- · simp only [rotate_zero] at hn
+ · simp only [rotate_zero] at hn
rw [hn.1, hn.2]
· cases' l with c s
- · simp only [rotate_singleton] at hn
+ · simp only [rotate_singleton] at hn
rw [hn.1, hn.2]
· rw [Nat.succ_eq_one_add, ← rotate_rotate, rotate_cons_succ, rotate_zero, cons_append] at
- hn
+ hn
rw [← hd c _ _ _ hn]
simp [and_comm]
#align cycle.chain Cycle.Chain
@@ -1156,7 +1156,7 @@ theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r
Chain r₂ s := by
induction s using Cycle.induction_on
· triv
- · rw [chain_coe_cons] at p⊢
+ · rw [chain_coe_cons] at p ⊢
exact p.imp H
#align cycle.chain.imp Cycle.Chain.imp
-/
@@ -1184,13 +1184,13 @@ theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s :=
pairwise_append.2
⟨pairwise_of_forall_mem_list fun b hb c hc => hs b (Hl hb) c (Hl hc),
pairwise_singleton r a, fun b hb c hc => _⟩⟩
- · rw [mem_append] at hb
+ · rw [mem_append] at hb
cases hb
· exact hs a Ha b (Hl hb)
- · rw [mem_singleton] at hb
+ · rw [mem_singleton] at hb
rw [hb]
exact hs a Ha a Ha
- · rw [mem_singleton] at hc
+ · rw [mem_singleton] at hc
rw [hc]
exact hs b (Hl hb) a Ha
#align cycle.chain_of_pairwise Cycle.chain_of_pairwise
@@ -1202,10 +1202,10 @@ theorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈
induction' s using Cycle.induction_on with a l _
exact fun _ b hb => hb.elim
intro hs b hb c hc
- rw [Cycle.chain_coe_cons, chain_iff_pairwise] at hs
+ rw [Cycle.chain_coe_cons, chain_iff_pairwise] at hs
simp only [pairwise_append, pairwise_cons, mem_append, mem_singleton, List.not_mem_nil,
- IsEmpty.forall_iff, imp_true_iff, pairwise.nil, forall_eq, true_and_iff] at hs
- simp only [mem_coe_iff, mem_cons_iff] at hb hc
+ IsEmpty.forall_iff, imp_true_iff, pairwise.nil, forall_eq, true_and_iff] at hs
+ simp only [mem_coe_iff, mem_cons_iff] at hb hc
rcases hb with (rfl | hb) <;> rcases hc with (rfl | hc)
· exact hs.1 c (Or.inr rfl)
· exact hs.1 c (Or.inl hc)
@@ -1232,7 +1232,7 @@ theorem Chain.eq_nil_of_well_founded [IsWellFounded α r] (h : Chain r s) : s =
#print Cycle.forall_eq_of_chain /-
theorem forall_eq_of_chain [IsTrans α r] [IsAntisymm α r] (hs : Chain r s) {a b : α} (ha : a ∈ s)
- (hb : b ∈ s) : a = b := by rw [chain_iff_pairwise] at hs;
+ (hb : b ∈ s) : a = b := by rw [chain_iff_pairwise] at hs ;
exact antisymm (hs a ha b hb) (hs b hb a ha)
#align cycle.forall_eq_of_chain Cycle.forall_eq_of_chain
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -201,9 +201,6 @@ theorem next_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) : next (x :: z :: l)
#align list.next_cons_cons_eq List.next_cons_cons_eq
-/
-/- warning: list.next_ne_head_ne_last -> List.next_ne_head_ne_getLast is a dubious translation:
-<too large>
-Case conversion may be inaccurate. Consider using '#align list.next_ne_head_ne_last List.next_ne_head_ne_getLastₓ'. -/
theorem next_ne_head_ne_getLast (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
(hx : x ≠ getLast (y :: l) (cons_ne_nil _ _)) :
next (y :: l) x h = next l x (by simpa [hy] using h) :=
@@ -223,12 +220,6 @@ theorem next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l)
#align list.next_cons_concat List.next_cons_concat
-/
-/- warning: list.next_last_cons -> List.next_getLast_cons is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (l : List.{u1} α) (x : α) (y : α) (h : Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x (List.cons.{u1} α y l)), (Ne.{succ u1} α x y) -> (Eq.{succ u1} α x (List.getLast.{u1} α (List.cons.{u1} α y l) (List.cons_ne_nil.{u1} α y l))) -> (List.Nodup.{u1} α l) -> (Eq.{succ u1} α (List.next.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (List.cons.{u1} α y l) x h) y)
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (l : List.{u1} α) (x : α), (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l) -> (forall (h : α) (hy : Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x (List.cons.{u1} α h l)), (Ne.{succ u1} α x h) -> (Eq.{succ u1} α x (List.getLast.{u1} α (List.cons.{u1} α h l) (List.cons_ne_nil.{u1} α h l))) -> (List.Nodup.{u1} α l) -> (Eq.{succ u1} α (List.next.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (List.cons.{u1} α h l) x hy) h))
-Case conversion may be inaccurate. Consider using '#align list.next_last_cons List.next_getLast_consₓ'. -/
theorem next_getLast_cons (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
(hx : x = getLast (y :: l) (cons_ne_nil _ _)) (hl : Nodup l) : next (y :: l) x h = y :=
by
@@ -844,12 +835,6 @@ theorem nil_toMultiset : nil.toMultiset = (0 : Multiset α) :=
#align cycle.nil_to_multiset Cycle.nil_toMultiset
-/
-/- warning: cycle.card_to_multiset -> Cycle.card_toMultiset is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} (s : Cycle.{u1} α), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Cycle.toMultiset.{u1} α s)) (Cycle.length.{u1} α s)
-but is expected to have type
- forall {α : Type.{u1}} (s : Cycle.{u1} α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Cycle.toMultiset.{u1} α s)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Cycle.toMultiset.{u1} α s)) (Cycle.length.{u1} α s)
-Case conversion may be inaccurate. Consider using '#align cycle.card_to_multiset Cycle.card_toMultisetₓ'. -/
@[simp]
theorem card_toMultiset (s : Cycle α) : s.toMultiset.card = s.length :=
Quotient.inductionOn' s (by simp)
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -86,8 +86,7 @@ theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x
induction' xs with y ys IH
· cases x_mem
cases' ys with z zs
- · simp at x_mem x_ne
- contradiction
+ · simp at x_mem x_ne; contradiction
by_cases h : x = y
· rw [h, next_or_self_cons_cons, next_or_self_cons_cons]
· rw [next_or, next_or, IH] <;> simpa [h] using x_mem
@@ -596,9 +595,7 @@ instance : Inhabited (Cycle α) :=
@[elab_as_elim]
theorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)
(HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=
- Quotient.inductionOn' s fun l => by
- apply List.recOn l <;> simp
- assumption'
+ Quotient.inductionOn' s fun l => by apply List.recOn l <;> simp; assumption'
#align cycle.induction_on Cycle.induction_on
-/
@@ -919,10 +916,7 @@ theorem lists_coe (l : List α) : lists (l : Cycle α) = ↑l.cyclicPermutations
#print Cycle.mem_lists_iff_coe_eq /-
@[simp]
theorem mem_lists_iff_coe_eq {s : Cycle α} {l : List α} : l ∈ s.lists ↔ (l : Cycle α) = s :=
- Quotient.inductionOn' s fun l =>
- by
- rw [Lists, Quotient.liftOn'_mk'']
- simp
+ Quotient.inductionOn' s fun l => by rw [Lists, Quotient.liftOn'_mk'']; simp
#align cycle.mem_lists_iff_coe_eq Cycle.mem_lists_iff_coe_eq
-/
@@ -960,9 +954,7 @@ instance {s : Cycle α} : Decidable (Nodup s) :=
#print Cycle.fintypeNodupCycle /-
instance fintypeNodupCycle [Fintype α] : Fintype { s : Cycle α // s.Nodup } :=
Fintype.ofSurjective (fun l : { l : List α // l.Nodup } => ⟨l.val, by simpa using l.prop⟩)
- fun ⟨s, hs⟩ => by
- induction s using Quotient.inductionOn'
- exact ⟨⟨s, hs⟩, by simp⟩
+ fun ⟨s, hs⟩ => by induction s using Quotient.inductionOn'; exact ⟨⟨s, hs⟩, by simp⟩
#align cycle.fintype_nodup_cycle Cycle.fintypeNodupCycle
-/
@@ -1051,18 +1043,14 @@ theorem next_reverse_eq_prev (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈
#print Cycle.next_mem /-
@[simp]
-theorem next_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.next hs x hx ∈ s :=
- by
- induction s using Quot.inductionOn
- apply next_mem
+theorem next_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.next hs x hx ∈ s := by
+ induction s using Quot.inductionOn; apply next_mem
#align cycle.next_mem Cycle.next_mem
-/
#print Cycle.prev_mem /-
-theorem prev_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.prev hs x hx ∈ s :=
- by
- rw [← next_reverse_eq_prev, ← mem_reverse_iff]
- apply next_mem
+theorem prev_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.prev hs x hx ∈ s := by
+ rw [← next_reverse_eq_prev, ← mem_reverse_iff]; apply next_mem
#align cycle.prev_mem Cycle.prev_mem
-/
@@ -1259,8 +1247,7 @@ theorem Chain.eq_nil_of_well_founded [IsWellFounded α r] (h : Chain r s) : s =
#print Cycle.forall_eq_of_chain /-
theorem forall_eq_of_chain [IsTrans α r] [IsAntisymm α r] (hs : Chain r s) {a b : α} (ha : a ∈ s)
- (hb : b ∈ s) : a = b := by
- rw [chain_iff_pairwise] at hs
+ (hb : b ∈ s) : a = b := by rw [chain_iff_pairwise] at hs;
exact antisymm (hs a ha b hb) (hs b hb a ha)
#align cycle.forall_eq_of_chain Cycle.forall_eq_of_chain
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/917c3c072e487b3cccdbfeff17e75b40e45f66cb
@@ -203,10 +203,7 @@ theorem next_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) : next (x :: z :: l)
-/
/- warning: list.next_ne_head_ne_last -> List.next_ne_head_ne_getLast is a dubious translation:
-lean 3 declaration is
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (l : List.{u1} α) (x : α) (y : α) (h : Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x (List.cons.{u1} α y l)) (hy : Ne.{succ u1} α x y), (Ne.{succ u1} α x (List.getLast.{u1} α (List.cons.{u1} α y l) (List.cons_ne_nil.{u1} α y l))) -> (Eq.{succ u1} α (List.next.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (List.cons.{u1} α y l) x h) (List.next.{u1} α (fun (a : α) (b : α) => _inst_1 a b) l x (Eq.mpr.{0} (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (id_tag Tactic.IdTag.simp (Eq.{1} Prop (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)) (rfl.{1} Prop (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l))) (Eq.mp.{0} (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x (List.cons.{u1} α y l)) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (Eq.trans.{1} Prop (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x (List.cons.{u1} α y l)) (Or False (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (Eq.trans.{1} Prop (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x (List.cons.{u1} α y l)) (Or (Eq.{succ u1} α x y) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)) (Or False (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)) (propext (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x (List.cons.{u1} α y l)) (Or (Eq.{succ u1} α x y) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)) (List.mem_cons.{u1} α x y l)) ((fun (a : Prop) (a_1 : Prop) (e_1 : Eq.{1} Prop a a_1) (b : Prop) (b_1 : Prop) (e_2 : Eq.{1} Prop b b_1) => congr.{1, 1} Prop Prop (Or a) (Or a_1) b b_1 (congr_arg.{1, 1} Prop (Prop -> Prop) a a_1 Or e_1) e_2) (Eq.{succ u1} α x y) False (propext (Eq.{succ u1} α x y) False (iff_false_intro (Eq.{succ u1} α x y) hy)) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (rfl.{1} Prop (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)))) (propext (Or False (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)) (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l) (false_or_iff (Membership.Mem.{u1, u1} α (List.{u1} α) (List.hasMem.{u1} α) x l)))) h))))
-but is expected to have type
- forall {α : Type.{u1}} [_inst_1 : DecidableEq.{succ u1} α] (l : List.{u1} α) (x : α), (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l) -> (forall (h : α) (hy : Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x (List.cons.{u1} α h l)) (hx : Ne.{succ u1} α x h), (Ne.{succ u1} α x (List.getLast.{u1} α (List.cons.{u1} α h l) (List.cons_ne_nil.{u1} α h l))) -> (Eq.{succ u1} α (List.next.{u1} α (fun (a : α) (b : α) => _inst_1 a b) (List.cons.{u1} α h l) x hy) (List.next.{u1} α (fun (a : α) (b : α) => _inst_1 a b) l x (Eq.mp.{0} (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x (List.cons.{u1} α h l)) (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l) (Eq.trans.{1} Prop (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x (List.cons.{u1} α h l)) (Or False (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l)) (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l) (Eq.trans.{1} Prop (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x (List.cons.{u1} α h l)) (Or (Eq.{succ u1} α x h) (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l)) (Or False (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l)) (Std.Data.List.Lemmas._auxLemma.2.{u1} α x h l) (congrFun.{1, 1} Prop (fun (b : Prop) => Prop) (Or (Eq.{succ u1} α x h)) (Or False) (congrArg.{1, 1} Prop (Prop -> Prop) (Eq.{succ u1} α x h) False Or (eq_false (Eq.{succ u1} α x h) hx)) (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l))) (false_or (Membership.mem.{u1, u1} α (List.{u1} α) (List.instMembershipList.{u1} α) x l))) hy))))
+<too large>
Case conversion may be inaccurate. Consider using '#align list.next_ne_head_ne_last List.next_ne_head_ne_getLastₓ'. -/
theorem next_ne_head_ne_getLast (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
(hx : x ≠ getLast (y :: l) (cons_ne_nil _ _)) :
mathlib commit https://github.com/leanprover-community/mathlib/commit/92c69b77c5a7dc0f7eeddb552508633305157caa
@@ -1181,6 +1181,7 @@ theorem chain_range_succ (r : ℕ → ℕ → Prop) (n : ℕ) :
variable {r : α → α → Prop} {s : Cycle α}
+#print Cycle.Chain.imp /-
theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r₂ a b) (p : Chain r₁ s) :
Chain r₂ s := by
induction s using Cycle.induction_on
@@ -1188,11 +1189,14 @@ theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r
· rw [chain_coe_cons] at p⊢
exact p.imp H
#align cycle.chain.imp Cycle.Chain.imp
+-/
+#print Cycle.chain_mono /-
/-- As a function from a relation to a predicate, `chain` is monotonic. -/
theorem chain_mono : Monotone (Chain : (α → α → Prop) → Cycle α → Prop) := fun a b hab s =>
Chain.imp hab
#align cycle.chain_mono Cycle.chain_mono
+-/
#print Cycle.chain_of_pairwise /-
theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s :=
@@ -1240,6 +1244,7 @@ theorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈
#align cycle.chain_iff_pairwise Cycle.chain_iff_pairwise
-/
+#print Cycle.Chain.eq_nil_of_irrefl /-
theorem Chain.eq_nil_of_irrefl [IsTrans α r] [IsIrrefl α r] (h : Chain r s) : s = nil :=
by
induction' s using Cycle.induction_on with a l _ h
@@ -1247,10 +1252,13 @@ theorem Chain.eq_nil_of_irrefl [IsTrans α r] [IsIrrefl α r] (h : Chain r s) :
· have ha := mem_cons_self a l
exact (irrefl_of r a <| chain_iff_pairwise.1 h a ha a ha).elim
#align cycle.chain.eq_nil_of_irrefl Cycle.Chain.eq_nil_of_irrefl
+-/
+#print Cycle.Chain.eq_nil_of_well_founded /-
theorem Chain.eq_nil_of_well_founded [IsWellFounded α r] (h : Chain r s) : s = nil :=
Chain.eq_nil_of_irrefl <| h.imp fun _ _ => Relation.TransGen.single
#align cycle.chain.eq_nil_of_well_founded Cycle.Chain.eq_nil_of_well_founded
+-/
#print Cycle.forall_eq_of_chain /-
theorem forall_eq_of_chain [IsTrans α r] [IsAntisymm α r] (hs : Chain r s) {a b : α} (ha : a ∈ s)
mathlib commit https://github.com/leanprover-community/mathlib/commit/92c69b77c5a7dc0f7eeddb552508633305157caa
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
! This file was ported from Lean 3 source module data.list.cycle
-! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
+! leanprover-community/mathlib commit 7413128c3bcb3b0818e3e18720abc9ea3100fb49
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -1181,6 +1181,19 @@ theorem chain_range_succ (r : ℕ → ℕ → Prop) (n : ℕ) :
variable {r : α → α → Prop} {s : Cycle α}
+theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r₂ a b) (p : Chain r₁ s) :
+ Chain r₂ s := by
+ induction s using Cycle.induction_on
+ · triv
+ · rw [chain_coe_cons] at p⊢
+ exact p.imp H
+#align cycle.chain.imp Cycle.Chain.imp
+
+/-- As a function from a relation to a predicate, `chain` is monotonic. -/
+theorem chain_mono : Monotone (Chain : (α → α → Prop) → Cycle α → Prop) := fun a b hab s =>
+ Chain.imp hab
+#align cycle.chain_mono Cycle.chain_mono
+
#print Cycle.chain_of_pairwise /-
theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s :=
by
@@ -1227,6 +1240,18 @@ theorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈
#align cycle.chain_iff_pairwise Cycle.chain_iff_pairwise
-/
+theorem Chain.eq_nil_of_irrefl [IsTrans α r] [IsIrrefl α r] (h : Chain r s) : s = nil :=
+ by
+ induction' s using Cycle.induction_on with a l _ h
+ · rfl
+ · have ha := mem_cons_self a l
+ exact (irrefl_of r a <| chain_iff_pairwise.1 h a ha a ha).elim
+#align cycle.chain.eq_nil_of_irrefl Cycle.Chain.eq_nil_of_irrefl
+
+theorem Chain.eq_nil_of_well_founded [IsWellFounded α r] (h : Chain r s) : s = nil :=
+ Chain.eq_nil_of_irrefl <| h.imp fun _ _ => Relation.TransGen.single
+#align cycle.chain.eq_nil_of_well_founded Cycle.Chain.eq_nil_of_well_founded
+
#print Cycle.forall_eq_of_chain /-
theorem forall_eq_of_chain [IsTrans α r] [IsAntisymm α r] (hs : Chain r s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) : a = b := by
mathlib commit https://github.com/leanprover-community/mathlib/commit/0148d455199ed64bf8eb2f493a1e7eb9211ce170
@@ -896,11 +896,13 @@ theorem map_eq_nil {β : Type _} (f : α → β) (s : Cycle α) : map f s = nil
#align cycle.map_eq_nil Cycle.map_eq_nil
-/
+#print Cycle.mem_map /-
@[simp]
theorem mem_map {β : Type _} {f : α → β} {b : β} {s : Cycle α} :
b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
Quotient.inductionOn' s (by simp)
#align cycle.mem_map Cycle.mem_map
+-/
#print Cycle.lists /-
/-- The `multiset` of lists that can make the cycle. -/
mathlib commit https://github.com/leanprover-community/mathlib/commit/728baa2f54e6062c5879a3e397ac6bac323e506f
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
! This file was ported from Lean 3 source module data.list.cycle
-! leanprover-community/mathlib commit fac369018417f980cec5fcdafc766a69f88d8cfe
+! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -896,6 +896,12 @@ theorem map_eq_nil {β : Type _} (f : α → β) (s : Cycle α) : map f s = nil
#align cycle.map_eq_nil Cycle.map_eq_nil
-/
+@[simp]
+theorem mem_map {β : Type _} {f : α → β} {b : β} {s : Cycle α} :
+ b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
+ Quotient.inductionOn' s (by simp)
+#align cycle.mem_map Cycle.mem_map
+
#print Cycle.lists /-
/-- The `multiset` of lists that can make the cycle. -/
def lists (s : Cycle α) : Multiset (List α) :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/ce7e9d53d4bbc38065db3b595cd5bd73c323bc1d
@@ -485,7 +485,7 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l)
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
next l.reverse x (mem_reverse'.mpr hx) = prev l x hx :=
by
- convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
+ convert(prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
exact (reverse_reverse l).symm
#align list.next_reverse_eq_prev List.next_reverse_eq_prev
-/
mathlib commit https://github.com/leanprover-community/mathlib/commit/3180fab693e2cee3bff62675571264cb8778b212
@@ -854,7 +854,7 @@ theorem nil_toMultiset : nil.toMultiset = (0 : Multiset α) :=
lean 3 declaration is
forall {α : Type.{u1}} (s : Cycle.{u1} α), Eq.{1} Nat (coeFn.{succ u1, succ u1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (fun (_x : AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) => (Multiset.{u1} α) -> Nat) (AddMonoidHom.hasCoeToFun.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.orderedCancelAddCommMonoid.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.card.{u1} α) (Cycle.toMultiset.{u1} α s)) (Cycle.length.{u1} α s)
but is expected to have type
- forall {α : Type.{u1}} (s : Cycle.{u1} α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.398 : Multiset.{u1} α) => Nat) (Cycle.toMultiset.{u1} α s)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.398 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Cycle.toMultiset.{u1} α s)) (Cycle.length.{u1} α s)
+ forall {α : Type.{u1}} (s : Cycle.{u1} α), Eq.{1} ((fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) (Cycle.toMultiset.{u1} α s)) (FunLike.coe.{succ u1, succ u1, 1} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) (fun (_x : Multiset.{u1} α) => (fun (x._@.Mathlib.Algebra.Hom.Group._hyg.403 : Multiset.{u1} α) => Nat) _x) (AddHomClass.toFunLike.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddZeroClass.toAdd.{u1} (Multiset.{u1} α) (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α))))))) (AddZeroClass.toAdd.{0} Nat (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (AddMonoidHomClass.toAddHomClass.{u1, u1, 0} (AddMonoidHom.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)) (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid) (AddMonoidHom.addMonoidHomClass.{u1, 0} (Multiset.{u1} α) Nat (AddMonoid.toAddZeroClass.{u1} (Multiset.{u1} α) (AddRightCancelMonoid.toAddMonoid.{u1} (Multiset.{u1} α) (AddCancelMonoid.toAddRightCancelMonoid.{u1} (Multiset.{u1} α) (AddCancelCommMonoid.toAddCancelMonoid.{u1} (Multiset.{u1} α) (OrderedCancelAddCommMonoid.toCancelAddCommMonoid.{u1} (Multiset.{u1} α) (Multiset.instOrderedCancelAddCommMonoidMultiset.{u1} α)))))) (AddMonoid.toAddZeroClass.{0} Nat Nat.addMonoid)))) (Multiset.card.{u1} α) (Cycle.toMultiset.{u1} α s)) (Cycle.length.{u1} α s)
Case conversion may be inaccurate. Consider using '#align cycle.card_to_multiset Cycle.card_toMultisetₓ'. -/
@[simp]
theorem card_toMultiset (s : Cycle α) : s.toMultiset.card = s.length :=
mathlib commit https://github.com/leanprover-community/mathlib/commit/bd9851ca476957ea4549eb19b40e7b5ade9428cc
@@ -187,7 +187,7 @@ theorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠
· rw [← Option.some_inj] at hk'
rw [← get?_eq_get, dropLast_eq_take, get?_take, get?_zero, head?_cons,
Option.some_inj] at hk'
- exact hy (Eq.symm hk')
+ · exact hy (Eq.symm hk')
rw [Nat.zero_eq, length_cons, Nat.pred_succ]
exact length_pos_of_mem (by assumption)
suffices k.succ = l.length by simp [this] at hk
@@ -199,9 +199,9 @@ theorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠
⟨tl.length, by simp⟩ ?_
rw [← Option.some_inj] at hk'
rw [← get?_eq_get, dropLast_eq_take, get?_take, get?, get?_eq_get, Option.some_inj] at hk'
- rw [hk']
- simp only [getLast_eq_get, length_cons, ge_iff_le, Nat.succ_sub_succ_eq_sub,
- nonpos_iff_eq_zero, add_eq_zero_iff, and_false, tsub_zero, get_cons_succ]
+ · rw [hk']
+ simp only [getLast_eq_get, length_cons, ge_iff_le, Nat.succ_sub_succ_eq_sub,
+ nonpos_iff_eq_zero, add_eq_zero_iff, and_false, tsub_zero, get_cons_succ]
simpa using hk
#align list.next_last_cons List.next_getLast_cons
@@ -289,14 +289,14 @@ theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),
· simp [getLast_eq_get]
· exact hn.of_cons
· rw [next_ne_head_ne_getLast _ _ _ _ _ hx']
- simp only [get_cons_succ]
- rw [next_get (y::l), ← get_cons_succ (a := x)]
- congr
- dsimp
- rw [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'),
- Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 (Nat.succ_lt_succ_iff.2 hi'))]
- · simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi']
- · exact hn.of_cons
+ · simp only [get_cons_succ]
+ rw [next_get (y::l), ← get_cons_succ (a := x)]
+ · congr
+ dsimp
+ rw [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'),
+ Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 (Nat.succ_lt_succ_iff.2 hi'))]
+ · simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi']
+ · exact hn.of_cons
· rw [getLast_eq_get]
intro h
have := nodup_iff_injective_get.1 hn h
@@ -956,7 +956,7 @@ theorem chain_map {β : Type*} {r : α → α → Prop} (f : β → α) {s : Cyc
Chain r (s.map f) ↔ Chain (fun a b => r (f a) (f b)) s :=
Quotient.inductionOn' s fun l => by
cases' l with a l
- rfl
+ · rfl
dsimp only [Chain, ← mk''_eq_coe, Quotient.liftOn'_mk'', Cycle.map, Quotient.map', Quot.map,
Quotient.mk'', Quotient.liftOn', Quotient.liftOn, Quot.liftOn_mk, List.map]
rw [← concat_eq_append, ← List.map_concat, List.chain_map f]
@@ -985,7 +985,7 @@ theorem chain_mono : Monotone (Chain : (α → α → Prop) → Cycle α → Pro
theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s := by
induction' s using Cycle.induction_on with a l _
- exact fun _ => Cycle.Chain.nil r
+ · exact fun _ => Cycle.Chain.nil r
intro hs
have Ha : a ∈ (a :: l : Cycle α) := by simp
have Hl : ∀ {b} (_hb : b ∈ l), b ∈ (a :: l : Cycle α) := @fun b hb => by simp [hb]
Most of them go back to the port.
@@ -304,7 +304,7 @@ theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),
· rw [get_cons_succ]; exact get_mem _ _ _
set_option linter.deprecated false in
-@[deprecated next_get]
+@[deprecated next_get] -- 2023-01-27
theorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
next l (l.nthLe n hn) (nthLe_mem _ _ _) =
l.nthLe ((n + 1) % l.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) :=
Data.{Nat,Int}{.Order}.Basic
in group vs ring instances (#11924)
Scatter the content of Data.Nat.Basic
across:
Data.Nat.Defs
for the lemmas having no dependenciesAlgebra.Group.Nat
for the monoid instances and the few miscellaneous lemmas needing them.Algebra.Ring.Nat
for the semiring instance and the few miscellaneous lemmas following it.Similarly, scatter
Data.Int.Basic
across Data.Int.Defs
, Algebra.Group.Int
, Algebra.Ring.Int
Data.Nat.Order.Basic
across Data.Nat.Defs
, Algebra.Order.Group.Nat
, Algebra.Order.Ring.Nat
Data.Int.Order.Basic
across Data.Int.Defs
, Algebra.Order.Group.Int
, Algebra.Order.Ring.Int
Also move a few lemmas from Data.Nat.Order.Lemmas
to Data.Nat.Defs
.
Before
After
@@ -3,6 +3,7 @@ Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
+import Mathlib.Algebra.Order.Ring.CharZero
import Mathlib.Data.Fintype.List
import Mathlib.Data.List.Rotate
@@ -624,7 +624,7 @@ theorem nontrivial_coe_nodup_iff {l : List α} (hl : l.Nodup) :
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simp
· simp
- · simp only [mem_cons, exists_prop, mem_coe_iff, List.length, Ne.def, Nat.succ_le_succ_iff,
+ · simp only [mem_cons, exists_prop, mem_coe_iff, List.length, Ne, Nat.succ_le_succ_iff,
zero_le, iff_true_iff]
refine' ⟨hd, hd', _, by simp⟩
simp only [not_or, mem_cons, nodup_cons] at hl
Std defines triv
, a slight variation on trivial
. It appears that Mathlib doesn't care about the distinction (any more?) and so we can consolidate on a single tactic.
https://github.com/leanprover/std4/pull/712 separately replaces triv
in Std with an error explaining to use trivial
.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@@ -972,7 +972,7 @@ variable {r : α → α → Prop} {s : Cycle α}
theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r₂ a b) (p : Chain r₁ s) :
Chain r₂ s := by
induction s using Cycle.induction_on
- · triv
+ · trivial
· rw [chain_coe_cons] at p ⊢
exact p.imp H
#align cycle.chain.imp Cycle.Chain.imp
@@ -453,7 +453,7 @@ namespace Cycle
variable {α : Type*}
--- Porting note: new definition
+-- Porting note (#11445): new definition
/-- The coercion from `List α` to `Cycle α` -/
@[coe] def ofList : List α → Cycle α :=
Quot.mk _
@@ -261,7 +261,7 @@ theorem prev_mem (h : x ∈ l) : l.prev x h ∈ l := by
· exact mem_cons_of_mem _ (hl _ _)
#align list.prev_mem List.prev_mem
--- Porting note: new theorem
+-- Porting note (#10756): new theorem
theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),
next l (l.get i) (get_mem _ _ _) = l.get ⟨(i + 1) % l.length,
Nat.mod_lt _ (i.1.zero_le.trans_lt i.2)⟩
@@ -846,7 +846,7 @@ nonrec theorem prev_reverse_eq_next (s : Cycle α) : ∀ (hs : Nodup s) (x : α)
Quotient.inductionOn' s prev_reverse_eq_next
#align cycle.prev_reverse_eq_next Cycle.prev_reverse_eq_next
--- Porting note: new theorem
+-- Porting note (#10756): new theorem
@[simp]
nonrec theorem prev_reverse_eq_next' (s : Cycle α) (hs : Nodup s.reverse) (x : α)
(hx : x ∈ s.reverse) :
@@ -859,7 +859,7 @@ theorem next_reverse_eq_prev (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈
simp [← prev_reverse_eq_next]
#align cycle.next_reverse_eq_prev Cycle.next_reverse_eq_prev
--- Porting note: new theorem
+-- Porting note (#10756): new theorem
@[simp]
theorem next_reverse_eq_prev' (s : Cycle α) (hs : Nodup s.reverse) (x : α) (hx : x ∈ s.reverse) :
s.reverse.next hs x hx = s.prev (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx) := by
Homogenises porting notes via capitalisation and addition of whitespace.
It makes the following changes:
@@ -261,7 +261,7 @@ theorem prev_mem (h : x ∈ l) : l.prev x h ∈ l := by
· exact mem_cons_of_mem _ (hl _ _)
#align list.prev_mem List.prev_mem
---Porting note: new theorem
+-- Porting note: new theorem
theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),
next l (l.get i) (get_mem _ _ _) = l.get ⟨(i + 1) % l.length,
Nat.mod_lt _ (i.1.zero_le.trans_lt i.2)⟩
@@ -453,7 +453,7 @@ namespace Cycle
variable {α : Type*}
---Porting note: new definition
+-- Porting note: new definition
/-- The coercion from `List α` to `Cycle α` -/
@[coe] def ofList : List α → Cycle α :=
Quot.mk _
@@ -840,26 +840,26 @@ nonrec def prev : ∀ (s : Cycle α) (_hs : Nodup s) (x : α) (_hx : x ∈ s),
(by rw [heq_iff_eq] at hxy; subst x; simpa using isRotated_prev_eq h h₁ _)
#align cycle.prev Cycle.prev
---Porting note: removed `simp` and added `prev_reverse_eq_next'` with `simp` attribute
+-- Porting note: removed `simp` and added `prev_reverse_eq_next'` with `simp` attribute
nonrec theorem prev_reverse_eq_next (s : Cycle α) : ∀ (hs : Nodup s) (x : α) (hx : x ∈ s),
s.reverse.prev (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.next hs x hx :=
Quotient.inductionOn' s prev_reverse_eq_next
#align cycle.prev_reverse_eq_next Cycle.prev_reverse_eq_next
---Porting note: new theorem
+-- Porting note: new theorem
@[simp]
nonrec theorem prev_reverse_eq_next' (s : Cycle α) (hs : Nodup s.reverse) (x : α)
(hx : x ∈ s.reverse) :
s.reverse.prev hs x hx = s.next (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx) :=
prev_reverse_eq_next s (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx)
---Porting note: removed `simp` and added `next_reverse_eq_prev'` with `simp` attribute
+-- Porting note: removed `simp` and added `next_reverse_eq_prev'` with `simp` attribute
theorem next_reverse_eq_prev (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) :
s.reverse.next (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.prev hs x hx := by
simp [← prev_reverse_eq_next]
#align cycle.next_reverse_eq_prev Cycle.next_reverse_eq_prev
---Porting note: new theorem
+-- Porting note: new theorem
@[simp]
theorem next_reverse_eq_prev' (s : Cycle α) (hs : Nodup s.reverse) (x : α) (hx : x ∈ s.reverse) :
s.reverse.next hs x hx = s.prev (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx) := by
Fin.eq_of_veq
and Fin.veq_of_eq
(#10626)
We have Fin.eq_of_val_eq
and Fin.val_eq_of_eq
in Lean core now.
Also slightly shake the tree.
@@ -194,7 +194,8 @@ theorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠
· simp at hk
· rw [nodup_iff_injective_get] at hl
rw [length, Nat.succ_inj']
- refine' Fin.veq_of_eq (@hl ⟨k, Nat.lt_of_succ_lt <| by simpa using hk⟩ ⟨tl.length, by simp⟩ _)
+ refine Fin.val_eq_of_eq <| @hl ⟨k, Nat.lt_of_succ_lt <| by simpa using hk⟩
+ ⟨tl.length, by simp⟩ ?_
rw [← Option.some_inj] at hk'
rw [← get?_eq_get, dropLast_eq_take, get?_take, get?, get?_eq_get, Option.some_inj] at hk'
rw [hk']
@@ -275,7 +276,7 @@ theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),
intro H
suffices (i + 1 : ℕ) = 0 by simpa
rw [nodup_iff_injective_get] at hn
- refine' Fin.veq_of_eq (@hn ⟨i + 1, hi⟩ ⟨0, by simp⟩ _)
+ refine' Fin.val_eq_of_eq (@hn ⟨i + 1, hi⟩ ⟨0, by simp⟩ _)
simpa using H
have hi' : i ≤ l.length := Nat.le_of_lt_succ (Nat.succ_lt_succ_iff.1 hi)
rcases hi'.eq_or_lt with (hi' | hi')
@@ -217,7 +217,7 @@ theorem prev_cons_cons_eq' (y z : α) (h : x ∈ y :: z :: l) (hx : x = y) :
prev (y :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) := by rw [prev, dif_pos hx]
#align list.prev_cons_cons_eq' List.prev_cons_cons_eq'
---@[simp] Porting note: `simp` can prove it
+--@[simp] Porting note (#10618): `simp` can prove it
theorem prev_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) :
prev (x :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) :=
prev_cons_cons_eq' l x x z h rfl
@@ -938,7 +938,7 @@ theorem chain_coe_cons (r : α → α → Prop) (a : α) (l : List α) :
Iff.rfl
#align cycle.chain_coe_cons Cycle.chain_coe_cons
---@[simp] Porting note: `simp` can prove it
+--@[simp] Porting note (#10618): `simp` can prove it
theorem chain_singleton (r : α → α → Prop) (a : α) : Chain r [a] ↔ r a a := by
rw [chain_coe_cons, nil_append, List.chain_singleton]
#align cycle.chain_singleton Cycle.chain_singleton
@@ -3,7 +3,6 @@ Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
-import Mathlib.Data.Multiset.Sort
import Mathlib.Data.Fintype.List
import Mathlib.Data.List.Rotate
∃ x ∈ s, _
instead of ∃ (x) (_ : x ∈ s), _
(#9184)
Search for [∀∃].*(_
and manually replace some occurrences with more readable versions.
In case of ∀
, the new expressions are defeq to the old ones.
In case of ∃
, they differ by exists_prop
.
In some rare cases, golf proofs that needed fixing.
@@ -94,7 +94,7 @@ theorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (
theorem nextOr_mem {xs : List α} {x d : α} (hd : d ∈ xs) : nextOr xs x d ∈ xs := by
revert hd
- suffices ∀ (xs' : List α) (_ : ∀ x ∈ xs, x ∈ xs') (_ : d ∈ xs'), nextOr xs x d ∈ xs' by
+ suffices ∀ xs' : List α, (∀ x ∈ xs, x ∈ xs') → d ∈ xs' → nextOr xs x d ∈ xs' by
exact this xs fun _ => id
intro xs' hxs' hd
induction' xs with y ys ih
@@ -132,7 +132,7 @@ so it will match on first hit, ignoring later duplicates.
* `prev [1, 2, 3, 4, 2] 2 _ = 1`
* `prev [1, 1, 2] 1 _ = 2`
-/
-def prev : ∀ (l : List α) (x : α) (_h : x ∈ l), α
+def prev : ∀ l : List α, ∀ x ∈ l, α
| [], _, h => by simp at h
| [y], _, _ => y
| y :: z :: xs, x, h =>
@@ -614,7 +614,7 @@ theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
/-- A `s : Cycle α` that is made up of at least two unique elements. -/
def Nontrivial (s : Cycle α) : Prop :=
- ∃ (x y : α) (_h : x ≠ y), x ∈ s ∧ y ∈ s
+ ∃ x y : α, x ≠ y ∧ x ∈ s ∧ y ∈ s
#align cycle.nontrivial Cycle.Nontrivial
@[simp]
@@ -410,7 +410,7 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l)
length_reverse, Nat.mod_eq_of_lt (tsub_lt_self lpos Nat.succ_pos'),
tsub_tsub_cancel_of_le (Nat.succ_le_of_lt lpos)]
rw [← nthLe_reverse]
- · simp [tsub_tsub_cancel_of_le (Nat.le_pred_of_lt hk)]
+ · simp [tsub_tsub_cancel_of_le (Nat.le_sub_one_of_lt hk)]
· simpa using (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
· simpa
#align list.prev_reverse_eq_next List.prev_reverse_eq_next
Removes nonterminal simps on lines looking like simp [...]
@@ -199,7 +199,8 @@ theorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠
rw [← Option.some_inj] at hk'
rw [← get?_eq_get, dropLast_eq_take, get?_take, get?, get?_eq_get, Option.some_inj] at hk'
rw [hk']
- simp [getLast_eq_get]
+ simp only [getLast_eq_get, length_cons, ge_iff_le, Nat.succ_sub_succ_eq_sub,
+ nonpos_iff_eq_zero, add_eq_zero_iff, and_false, tsub_zero, get_cons_succ]
simpa using hk
#align list.next_last_cons List.next_getLast_cons
Type _
and Sort _
(#6499)
We remove all possible occurences of Type _
and Sort _
in favor of Type*
and Sort*
.
This has nice performance benefits.
@@ -27,7 +27,7 @@ is different.
namespace List
-variable {α : Type _} [DecidableEq α]
+variable {α : Type*} [DecidableEq α]
/-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/
def nextOr : ∀ (_ : List α) (_ _ : α), α
@@ -444,13 +444,13 @@ open List
/-- `Cycle α` is the quotient of `List α` by cyclic permutation.
Duplicates are allowed.
-/
-def Cycle (α : Type _) : Type _ :=
+def Cycle (α : Type*) : Type _ :=
Quotient (IsRotated.setoid α)
#align cycle Cycle
namespace Cycle
-variable {α : Type _}
+variable {α : Type*}
--Porting note: new definition
/-- The coercion from `List α` to `Cycle α` -/
@@ -707,27 +707,27 @@ theorem toMultiset_eq_nil {s : Cycle α} : s.toMultiset = 0 ↔ s = Cycle.nil :=
#align cycle.to_multiset_eq_nil Cycle.toMultiset_eq_nil
/-- The lift of `list.map`. -/
-def map {β : Type _} (f : α → β) : Cycle α → Cycle β :=
+def map {β : Type*} (f : α → β) : Cycle α → Cycle β :=
Quotient.map' (List.map f) fun _ _ h => h.map _
#align cycle.map Cycle.map
@[simp]
-theorem map_nil {β : Type _} (f : α → β) : map f nil = nil :=
+theorem map_nil {β : Type*} (f : α → β) : map f nil = nil :=
rfl
#align cycle.map_nil Cycle.map_nil
@[simp]
-theorem map_coe {β : Type _} (f : α → β) (l : List α) : map f ↑l = List.map f l :=
+theorem map_coe {β : Type*} (f : α → β) (l : List α) : map f ↑l = List.map f l :=
rfl
#align cycle.map_coe Cycle.map_coe
@[simp]
-theorem map_eq_nil {β : Type _} (f : α → β) (s : Cycle α) : map f s = nil ↔ s = nil :=
+theorem map_eq_nil {β : Type*} (f : α → β) (s : Cycle α) : map f s = nil ↔ s = nil :=
Quotient.inductionOn' s (by simp)
#align cycle.map_eq_nil Cycle.map_eq_nil
@[simp]
-theorem mem_map {β : Type _} {f : α → β} {b : β} {s : Cycle α} :
+theorem mem_map {β : Type*} {f : α → β} {b : β} {s : Cycle α} :
b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
Quotient.inductionOn' s (by simp)
#align cycle.mem_map Cycle.mem_map
@@ -950,7 +950,7 @@ theorem chain_ne_nil (r : α → α → Prop) {l : List α} :
rw [← coe_cons_eq_coe_append, chain_coe_cons, getLast_append_singleton])
#align cycle.chain_ne_nil Cycle.chain_ne_nil
-theorem chain_map {β : Type _} {r : α → α → Prop} (f : β → α) {s : Cycle β} :
+theorem chain_map {β : Type*} {r : α → α → Prop} (f : β → α) {s : Cycle β} :
Chain r (s.map f) ↔ Chain (fun a b => r (f a) (f b)) s :=
Quotient.inductionOn' s fun l => by
cases' l with a l
Various adaptations to changes when Fin
API was moved to Std. One notable change is that many lemmas are now stated in terms of i ≠ 0
(for i : Fin n
) rather then i.1 ≠ 0
, and as a consequence many Fin.vne_of_ne
applications have been added or removed, mostly removed.
Co-authored-by: Scott Morrison <scott.morrison@gmail.com> Co-authored-by: Wojciech Nawrocki <wjnawrocki@protonmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -397,7 +397,7 @@ theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- prev l.reverse x (mem_reverse'.mpr hx) = next l x hx := by
+ prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
have lpos : 0 < l.length := k.zero_le.trans_lt hk
have key : l.length - 1 - k < l.length :=
@@ -415,8 +415,8 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l)
#align list.prev_reverse_eq_next List.prev_reverse_eq_next
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- next l.reverse x (mem_reverse'.mpr hx) = prev l x hx := by
- convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x ((mem_reverse _ _).mpr hx)).symm
+ next l.reverse x (mem_reverse.mpr hx) = prev l x hx := by
+ convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
exact (reverse_reverse l).symm
#align list.next_reverse_eq_prev List.next_reverse_eq_prev
@@ -552,7 +552,7 @@ theorem reverse_coe (l : List α) : (l : Cycle α).reverse = l.reverse :=
@[simp]
theorem mem_reverse_iff {a : α} {s : Cycle α} : a ∈ s.reverse ↔ a ∈ s :=
- Quot.inductionOn s fun _ => mem_reverse'
+ Quot.inductionOn s fun _ => mem_reverse
#align cycle.mem_reverse_iff Cycle.mem_reverse_iff
@[simp]
@@ -2,16 +2,13 @@
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-
-! This file was ported from Lean 3 source module data.list.cycle
-! leanprover-community/mathlib commit 7413128c3bcb3b0818e3e18720abc9ea3100fb49
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
-/
import Mathlib.Data.Multiset.Sort
import Mathlib.Data.Fintype.List
import Mathlib.Data.List.Rotate
+#align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49"
+
/-!
# Cycles of a list
@@ -686,7 +686,7 @@ theorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬S
/-- The `s : Cycle α` as a `Multiset α`.
-/
def toMultiset (s : Cycle α) : Multiset α :=
- Quotient.liftOn' s (↑) fun _ _ h => Multiset.coe_eq_coe.mpr h.perm
+ Quotient.liftOn' s (↑) fun _ _ h => Multiset.coe_eq_coe.mpr h.perm
#align cycle.to_multiset Cycle.toMultiset
@[simp]
This PR is the result of running
find . -type f -name "*.lean" -exec sed -i -E 's/^( +)\. /\1· /' {} \;
find . -type f -name "*.lean" -exec sed -i -E 'N;s/^( +·)\n +(.*)$/\1 \2/;P;D' {} \;
which firstly replaces .
focusing dots with ·
and secondly removes isolated instances of such dots, unifying them with the following line. A new rule is placed in the style linter to verify this.
@@ -73,8 +73,8 @@ theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x
by_cases h : x = y
· rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons]
· rw [nextOr, nextOr, IH]
- . simpa [h] using x_mem
- . simpa using x_ne
+ · simpa [h] using x_mem
+ · simpa using x_ne
#align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne
theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs := by
@@ -285,24 +285,24 @@ theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),
· subst hi'
rw [next_getLast_cons]
· simp [hi', get]
- . rw [get_cons_succ]; exact get_mem _ _ _
- . exact hx'
- . simp [getLast_eq_get]
- . exact hn.of_cons
- . rw [next_ne_head_ne_getLast _ _ _ _ _ hx']
+ · rw [get_cons_succ]; exact get_mem _ _ _
+ · exact hx'
+ · simp [getLast_eq_get]
+ · exact hn.of_cons
+ · rw [next_ne_head_ne_getLast _ _ _ _ _ hx']
simp only [get_cons_succ]
rw [next_get (y::l), ← get_cons_succ (a := x)]
congr
dsimp
rw [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'),
Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 (Nat.succ_lt_succ_iff.2 hi'))]
- . simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi']
- . exact hn.of_cons
- . rw [getLast_eq_get]
+ · simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi']
+ · exact hn.of_cons
+ · rw [getLast_eq_get]
intro h
have := nodup_iff_injective_get.1 hn h
simp at this; simp [this] at hi'
- . rw [get_cons_succ]; exact get_mem _ _ _
+ · rw [get_cons_succ]; exact get_mem _ _ _
set_option linter.deprecated false in
@[deprecated next_get]
@@ -414,7 +414,7 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l)
rw [← nthLe_reverse]
· simp [tsub_tsub_cancel_of_le (Nat.le_pred_of_lt hk)]
· simpa using (Nat.sub_le _ _).trans_lt (tsub_lt_self lpos Nat.succ_pos')
- . simpa
+ · simpa
#align list.prev_reverse_eq_next List.prev_reverse_eq_next
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
at
and goals (#5387)
Changes are of the form
some_tactic at h⊢
-> some_tactic at h ⊢
some_tactic at h
-> some_tactic at h
@@ -325,7 +325,7 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
List.nthLe, Nat.succ_add_sub_one, zero_add, getLast_eq_get,
Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)]
· simp only [mem_cons, nodup_cons] at h
- push_neg at h
+ push_neg at h
simp only [List.prev_cons_cons_of_ne _ _ _ _ h.left.left.symm, Nat.zero_eq, List.length,
List.nthLe, add_comm, eq_self_iff_true, Nat.succ_add_sub_one, Nat.mod_self, zero_add,
List.get]
@@ -975,7 +975,7 @@ theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r
Chain r₂ s := by
induction s using Cycle.induction_on
· triv
- · rw [chain_coe_cons] at p⊢
+ · rw [chain_coe_cons] at p ⊢
exact p.imp H
#align cycle.chain.imp Cycle.Chain.imp
@@ -616,7 +616,7 @@ theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
/-- A `s : Cycle α` that is made up of at least two unique elements. -/
def Nontrivial (s : Cycle α) : Prop :=
- ∃ (x y : α)(_h : x ≠ y), x ∈ s ∧ y ∈ s
+ ∃ (x y : α) (_h : x ≠ y), x ∈ s ∧ y ∈ s
#align cycle.nontrivial Cycle.Nontrivial
@[simp]
@@ -21,7 +21,7 @@ This relation is defined as `IsRotated`.
Based on this, we define the quotient of lists by the rotation relation, called `Cycle`.
We also define a representation of concrete cycles, available when viewing them in a goal state or
-via `#eval`, when over representatble types. For example, the cycle `(2 1 4 3)` will be shown
+via `#eval`, when over representable types. For example, the cycle `(2 1 4 3)` will be shown
as `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation
is different.
fix-comments.py
on all files.@@ -110,7 +110,7 @@ theorem nextOr_mem {xs : List α} {x d : α} (hd : d ∈ xs) : nextOr xs x d ∈
· exact ih fun _ h => hxs' _ (mem_cons_of_mem _ h)
#align list.next_or_mem List.nextOr_mem
-/-- Given an element `x : α` of `l : list α` such that `x ∈ l`, get the next
+/-- Given an element `x : α` of `l : List α` such that `x ∈ l`, get the next
element of `l`. This works from head to tail, (including a check for last element)
so it will match on first hit, ignoring later duplicates.
@@ -125,7 +125,7 @@ def next (l : List α) (x : α) (h : x ∈ l) : α :=
nextOr l x (l.get ⟨0, length_pos_of_mem h⟩)
#align list.next List.next
-/-- Given an element `x : α` of `l : list α` such that `x ∈ l`, get the previous
+/-- Given an element `x : α` of `l : List α` such that `x ∈ l`, get the previous
element of `l`. This works from head to tail, (including a check for last element)
so it will match on first hit, ignoring later duplicates.
by
s! (#3825)
This PR puts, with one exception, every single remaining by
that lies all by itself on its own line to the previous line, thus matching the current behaviour of start-port.sh
. The exception is when the by
begins the second or later argument to a tuple or anonymous constructor; see https://github.com/leanprover-community/mathlib4/pull/3825#discussion_r1186702599.
Essentially this is s/\n *by$/ by/g
, but with manual editing to satisfy the linter's max-100-char-line requirement. The Python style linter is also modified to catch these "isolated by
s".
@@ -64,8 +64,7 @@ theorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) :
/-- `nextOr` does not depend on the default value, if the next value appears. -/
theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x ∈ xs)
- (x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' :=
- by
+ (x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' := by
induction' xs with y ys IH
· cases x_mem
cases' ys with z zs
@@ -78,8 +77,7 @@ theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x
. simpa using x_ne
#align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne
-theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs :=
- by
+theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs := by
induction' xs with y ys IH
· simp at h
cases' ys with z zs
@@ -90,8 +88,7 @@ theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x
simpa [hx] using IH h
#align list.mem_of_next_or_ne List.mem_of_nextOr_ne
-theorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (xs ++ [x]) x d = d :=
- by
+theorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (xs ++ [x]) x d = d := by
induction' xs with z zs IH
· simp
· obtain ⟨hz, hzs⟩ := not_or.mp (mt mem_cons.2 h)
@@ -185,8 +182,7 @@ theorem next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l)
#align list.next_cons_concat List.next_cons_concat
theorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
- (hx : x = getLast (y :: l) (cons_ne_nil _ _)) (hl : Nodup l) : next (y :: l) x h = y :=
- by
+ (hx : x = getLast (y :: l) (cons_ne_nil _ _)) (hl : Nodup l) : next (y :: l) x h = y := by
rw [next, get, ← dropLast_append_getLast (cons_ne_nil y l), hx, nextOr_concat]
subst hx
intro H
@@ -335,8 +331,7 @@ theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
List.get]
· rw [prev_ne_cons_cons]
· convert hl n.succ y h.of_cons (Nat.le_of_succ_le_succ hn) using 1
- have : ∀ k hk, (y :: l).nthLe k hk = (x :: y :: l).nthLe (k + 1) (Nat.succ_lt_succ hk) :=
- by
+ have : ∀ k hk, (y :: l).nthLe k hk = (x :: y :: l).nthLe (k + 1) (Nat.succ_lt_succ hk) := by
intros
simp [List.nthLe]
rw [this]
@@ -370,8 +365,7 @@ theorem pmap_next_eq_rotate_one (h : Nodup l) : (l.pmap l.next fun _ h => h) = l
set_option linter.deprecated false in
theorem pmap_prev_eq_rotate_length_sub_one (h : Nodup l) :
- (l.pmap l.prev fun _ h => h) = l.rotate (l.length - 1) :=
- by
+ (l.pmap l.prev fun _ h => h) = l.rotate (l.length - 1) := by
apply List.ext_nthLe
· simp
· intro n hn hn'
@@ -380,8 +374,7 @@ theorem pmap_prev_eq_rotate_length_sub_one (h : Nodup l) :
set_option linter.deprecated false in
theorem prev_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- prev l (next l x hx) (next_mem _ _ _) = x :=
- by
+ prev l (next l x hx) (next_mem _ _ _) = x := by
obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
cases' l with hd tl
@@ -394,8 +387,7 @@ theorem prev_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- next l (prev l x hx) (prev_mem _ _ _) = x :=
- by
+ next l (prev l x hx) (prev_mem _ _ _) = x := by
obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
cases' l with hd tl
@@ -408,8 +400,7 @@ theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- prev l.reverse x (mem_reverse'.mpr hx) = next l x hx :=
- by
+ prev l.reverse x (mem_reverse'.mpr hx) = next l x hx := by
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
have lpos : 0 < l.length := k.zero_le.trans_lt hk
have key : l.length - 1 - k < l.length :=
@@ -427,16 +418,14 @@ theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l)
#align list.prev_reverse_eq_next List.prev_reverse_eq_next
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
- next l.reverse x (mem_reverse'.mpr hx) = prev l x hx :=
- by
+ next l.reverse x (mem_reverse'.mpr hx) = prev l x hx := by
convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x ((mem_reverse _ _).mpr hx)).symm
exact (reverse_reverse l).symm
#align list.next_reverse_eq_prev List.next_reverse_eq_prev
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
- l.next x hx = l'.next x (h.mem_iff.mp hx) :=
- by
+ l.next x hx = l'.next x (h.mem_iff.mp hx) := by
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
obtain ⟨n, rfl⟩ := id h
rw [next_nthLe _ hn]
@@ -446,8 +435,7 @@ theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α}
#align list.is_rotated_next_eq List.isRotated_next_eq
theorem isRotated_prev_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
- l.prev x hx = l'.prev x (h.mem_iff.mp hx) :=
- by
+ l.prev x hx = l'.prev x (h.mem_iff.mp hx) := by
rw [← next_reverse_eq_prev _ hn, ← next_reverse_eq_prev _ (h.nodup_iff.mp hn)]
exact isRotated_next_eq h.reverse (nodup_reverse.mpr hn) _
#align list.is_rotated_prev_eq List.isRotated_prev_eq
@@ -619,8 +607,7 @@ theorem subsingleton_reverse_iff {s : Cycle α} : s.reverse.Subsingleton ↔ s.S
#align cycle.subsingleton_reverse_iff Cycle.subsingleton_reverse_iff
theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
- ∀ ⦃x⦄ (_hx : x ∈ s) ⦃y⦄ (_hy : y ∈ s), x = y :=
- by
+ ∀ ⦃x⦄ (_hx : x ∈ s) ⦃y⦄ (_hy : y ∈ s), x = y := by
induction' s using Quot.inductionOn with l
simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, Nat.lt_add_one_iff,
length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h
@@ -634,8 +621,7 @@ def Nontrivial (s : Cycle α) : Prop :=
@[simp]
theorem nontrivial_coe_nodup_iff {l : List α} (hl : l.Nodup) :
- Nontrivial (l : Cycle α) ↔ 2 ≤ l.length :=
- by
+ Nontrivial (l : Cycle α) ↔ 2 ≤ l.length := by
rw [Nontrivial]
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simp
@@ -682,8 +668,7 @@ theorem nodup_reverse_iff {s : Cycle α} : s.reverse.Nodup ↔ s.Nodup :=
Quot.inductionOn s fun _ => nodup_reverse
#align cycle.nodup_reverse_iff Cycle.nodup_reverse_iff
-theorem Subsingleton.nodup {s : Cycle α} (h : Subsingleton s) : Nodup s :=
- by
+theorem Subsingleton.nodup {s : Cycle α} (h : Subsingleton s) : Nodup s := by
induction' s using Quot.inductionOn with l
cases' l with hd tl
· simp
@@ -691,8 +676,7 @@ theorem Subsingleton.nodup {s : Cycle α} (h : Subsingleton s) : Nodup s :=
simp [this]
#align cycle.subsingleton.nodup Cycle.Subsingleton.nodup
-theorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬Subsingleton s :=
- by
+theorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬Subsingleton s := by
rw [length_subsingleton_iff]
induction s using Quotient.inductionOn'
simp only [mk''_eq_coe, nodup_coe_iff] at h
@@ -889,8 +873,7 @@ nonrec theorem next_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) :
apply next_mem; assumption
#align cycle.next_mem Cycle.next_mem
-theorem prev_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.prev hs x hx ∈ s :=
- by
+theorem prev_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.prev hs x hx ∈ s := by
rw [← next_reverse_eq_prev, ← mem_reverse_iff]
apply next_mem
#align cycle.prev_mem Cycle.prev_mem
Match https://github.com/leanprover-community/mathlib/pull/18512
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
! This file was ported from Lean 3 source module data.list.cycle
-! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
+! leanprover-community/mathlib commit 7413128c3bcb3b0818e3e18720abc9ea3100fb49
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -988,6 +988,19 @@ nonrec theorem chain_range_succ (r : ℕ → ℕ → Prop) (n : ℕ) :
variable {r : α → α → Prop} {s : Cycle α}
+theorem Chain.imp {r₁ r₂ : α → α → Prop} (H : ∀ a b, r₁ a b → r₂ a b) (p : Chain r₁ s) :
+ Chain r₂ s := by
+ induction s using Cycle.induction_on
+ · triv
+ · rw [chain_coe_cons] at p⊢
+ exact p.imp H
+#align cycle.chain.imp Cycle.Chain.imp
+
+/-- As a function from a relation to a predicate, `chain` is monotonic. -/
+theorem chain_mono : Monotone (Chain : (α → α → Prop) → Cycle α → Prop) := fun _a _b hab _s =>
+ Chain.imp hab
+#align cycle.chain_mono Cycle.chain_mono
+
theorem chain_of_pairwise : (∀ a ∈ s, ∀ b ∈ s, r a b) → Chain r s := by
induction' s using Cycle.induction_on with a l _
exact fun _ => Cycle.Chain.nil r
@@ -1029,6 +1042,17 @@ theorem chain_iff_pairwise [IsTrans α r] : Chain r s ↔ ∀ a ∈ s, ∀ b ∈
· exact _root_.trans (hs.2.2 b hb) (hs.1 c (Or.inl hc)), Cycle.chain_of_pairwise⟩
#align cycle.chain_iff_pairwise Cycle.chain_iff_pairwise
+theorem Chain.eq_nil_of_irrefl [IsTrans α r] [IsIrrefl α r] (h : Chain r s) : s = Cycle.nil := by
+ induction' s using Cycle.induction_on with a l _ h
+ · rfl
+ · have ha := mem_cons_self a l
+ exact (irrefl_of r a <| chain_iff_pairwise.1 h a ha a ha).elim
+#align cycle.chain.eq_nil_of_irrefl Cycle.Chain.eq_nil_of_irrefl
+
+theorem Chain.eq_nil_of_well_founded [IsWellFounded α r] (h : Chain r s) : s = Cycle.nil :=
+ Chain.eq_nil_of_irrefl <| h.imp fun _ _ => Relation.TransGen.single
+#align cycle.chain.eq_nil_of_well_founded Cycle.Chain.eq_nil_of_well_founded
+
theorem forall_eq_of_chain [IsTrans α r] [IsAntisymm α r] (hs : Chain r s) {a b : α} (ha : a ∈ s)
(hb : b ∈ s) : a = b := by
rw [chain_iff_pairwise] at hs
We don't port the IMO proof itself since it seems there's no archive in Mathlib4.
Mathlib 3: https://github.com/leanprover-community/mathlib/pull/15613
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
! This file was ported from Lean 3 source module data.list.cycle
-! leanprover-community/mathlib commit 008205aa645b3f194c1da47025c5f110c8406eab
+! leanprover-community/mathlib commit 728baa2f54e6062c5879a3e397ac6bac323e506f
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
@@ -745,6 +745,12 @@ theorem map_eq_nil {β : Type _} (f : α → β) (s : Cycle α) : map f s = nil
Quotient.inductionOn' s (by simp)
#align cycle.map_eq_nil Cycle.map_eq_nil
+@[simp]
+theorem mem_map {β : Type _} {f : α → β} {b : β} {s : Cycle α} :
+ b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
+ Quotient.inductionOn' s (by simp)
+#align cycle.mem_map Cycle.mem_map
+
/-- The `Multiset` of lists that can make the cycle. -/
def lists (s : Cycle α) : Multiset (List α) :=
Quotient.liftOn' s (fun l => (l.cyclicPermutations : Multiset (List α))) fun l₁ l₂ h => by
renames some names that don't follow naming conventions
@@ -706,24 +706,24 @@ def toMultiset (s : Cycle α) : Multiset α :=
#align cycle.to_multiset Cycle.toMultiset
@[simp]
-theorem coe_to_multiset (l : List α) : (l : Cycle α).toMultiset = l :=
+theorem coe_toMultiset (l : List α) : (l : Cycle α).toMultiset = l :=
rfl
-#align cycle.coe_to_multiset Cycle.coe_to_multiset
+#align cycle.coe_to_multiset Cycle.coe_toMultiset
@[simp]
-theorem nil_to_multiset : nil.toMultiset = (0 : Multiset α) :=
+theorem nil_toMultiset : nil.toMultiset = (0 : Multiset α) :=
rfl
-#align cycle.nil_to_multiset Cycle.nil_to_multiset
+#align cycle.nil_to_multiset Cycle.nil_toMultiset
@[simp]
-theorem card_to_multiset (s : Cycle α) : Multiset.card s.toMultiset = s.length :=
+theorem card_toMultiset (s : Cycle α) : Multiset.card s.toMultiset = s.length :=
Quotient.inductionOn' s (by simp)
-#align cycle.card_to_multiset Cycle.card_to_multiset
+#align cycle.card_to_multiset Cycle.card_toMultiset
@[simp]
-theorem to_multiset_eq_nil {s : Cycle α} : s.toMultiset = 0 ↔ s = Cycle.nil :=
+theorem toMultiset_eq_nil {s : Cycle α} : s.toMultiset = 0 ↔ s = Cycle.nil :=
Quotient.inductionOn' s (by simp)
-#align cycle.to_multiset_eq_nil Cycle.to_multiset_eq_nil
+#align cycle.to_multiset_eq_nil Cycle.toMultiset_eq_nil
/-- The lift of `list.map`. -/
def map {β : Type _} (f : α → β) : Cycle α → Cycle β :=
@@ -816,19 +816,19 @@ theorem toFinset_toMultiset (s : Cycle α) : s.toMultiset.toFinset = s.toFinset
#align cycle.to_finset_to_multiset Cycle.toFinset_toMultiset
@[simp]
-theorem coe_to_finset (l : List α) : (l : Cycle α).toFinset = l.toFinset :=
+theorem coe_toFinset (l : List α) : (l : Cycle α).toFinset = l.toFinset :=
rfl
-#align cycle.coe_to_finset Cycle.coe_to_finset
+#align cycle.coe_to_finset Cycle.coe_toFinset
@[simp]
-theorem nil_to_finset : (@nil α).toFinset = ∅ :=
+theorem nil_toFinset : (@nil α).toFinset = ∅ :=
rfl
-#align cycle.nil_to_finset Cycle.nil_to_finset
+#align cycle.nil_to_finset Cycle.nil_toFinset
@[simp]
-theorem to_finset_eq_nil {s : Cycle α} : s.toFinset = ∅ ↔ s = Cycle.nil :=
+theorem toFinset_eq_nil {s : Cycle α} : s.toFinset = ∅ ↔ s = Cycle.nil :=
Quotient.inductionOn' s (by simp)
-#align cycle.to_finset_eq_nil Cycle.to_finset_eq_nil
+#align cycle.to_finset_eq_nil Cycle.toFinset_eq_nil
/-- Given a `s : Cycle α` such that `Nodup s`, retrieve the next element after `x ∈ s`. -/
nonrec def next : ∀ (s : Cycle α) (_hs : Nodup s) (x : α) (_hx : x ∈ s), α := fun s =>
The unported dependencies are