Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit fd4628f

Browse files
chore(*): bump to lean 3.19.0c, fin is now a subtype (#3955)
* Some `decidable.*` order theorems have been moved to core. * `fin` is now a subtype. This means that the whnf of `fin n` is now `{i // i < n}`. Also, the coercion `fin n → nat` is now preferred over `subtype.val`. The entire library has been refactored accordingly. (Although I probably missed some cases.) * `in_current_file'` was removed since the bug in `in_current_file` was fixed in core. * The syntax of `guard_hyp` in core was changed from `guard_hyp h := t` to `guard_hyp h : t`, so the syntax for the related `guard_hyp'`, `match_hyp` and `guard_hyp_strict` tactics in `tactic.interactive` was changed as well. Co-authored-by: Bryan Gin-ge Chen <bryangingechen@gmail.com>
1 parent 17c4651 commit fd4628f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+384
-446
lines changed

archive/100-theorems-list/73_ascending_descending_sequences.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ begin
104104
refine ⟨_, _, _⟩,
105105
{ rw mem_powerset, apply subset_univ },
106106
-- It ends at `j` since `i < j`.
107-
{ rw [max_insert, ht₁.2.1, option.lift_or_get_some_some, max_eq_left, with_top.some_eq_coe],
107+
{ convert max_insert,
108+
rw [ht₁.2.1, option.lift_or_get_some_some, max_eq_left, with_top.some_eq_coe],
108109
apply le_of_lt ‹i < j› },
109110
-- To show it's increasing (i.e., `f` is monotone increasing on `t.insert j`), we do cases on
110111
-- what the possibilities could be - either in `t` or equals `j`.

archive/100-theorems-list/82_cubing_a_cube.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ begin
264264
rcases v.1 c.b_mem_bottom with ⟨_, ⟨i, rfl⟩, hi⟩,
265265
have h2i : i ∈ bcubes cs c := ⟨hi.1.symm, v.2.1 i hi.1.symm ⟨tail c.b, hi.2, λ j, c.b_mem_side j.succ⟩⟩,
266266
let j : fin (n+1) := ⟨2, h.2.2.2.2⟩,
267-
have hj : 0 ≠ j := by { intro h', have := congr_arg fin.val h', contradiction },
267+
have hj : 0 ≠ j := by { simp only [fin.ext_iff, ne.def], contradiction },
268268
let p : fin (n+1) → ℝ := λ j', if j' = j then c.b j + (cs i).w else c.b j',
269269
have hp : p ∈ c.bottom,
270270
{ split, { simp only [bottom, p, if_neg hj] },

leanpkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "mathlib"
33
version = "0.1"
4-
lean_version = "leanprover-community/lean:3.18.4"
4+
lean_version = "leanprover-community/lean:3.19.0"
55
path = "src"
66

77
[dependencies]

src/algebra/category/Mon/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ example (R : CommMon.{u}) : R ⟶ R :=
105105
{ to_fun := λ x,
106106
begin
107107
match_target (R : Type u),
108-
match_hyp x := (R : Type u),
108+
match_hyp x : (R : Type u),
109109
exact x * x
110110
end ,
111111
map_one' := by simp,

src/algebra/linear_recurrence.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def is_solution (u : ℕ → α) :=
6262
We will prove this is the only such solution. -/
6363
def mk_sol (init : fin E.order → α) : ℕ → α
6464
| n := if h : n < E.order then init ⟨n, h⟩ else
65-
∑ k : fin E.order, have n - E.order + k.1 < n, by have := k.2; omega,
65+
∑ k : fin E.order, have n - E.order + k < n, by have := k.is_lt; omega,
6666
E.coeffs k * mk_sol (n - E.order + k)
6767

6868
/-- `E.mk_sol` indeed gives solutions to `E`. -/
@@ -71,7 +71,7 @@ lemma is_sol_mk_sol (init : fin E.order → α) : E.is_solution (E.mk_sol init)
7171

7272
/-- `E.mk_sol init`'s first `E.order` terms are `init`. -/
7373
lemma mk_sol_eq_init (init : fin E.order → α) : ∀ n : fin E.order, E.mk_sol init n = init n :=
74-
λ n, by rw mk_sol; simp [fin.coe_eq_val, n.2]
74+
λ n, by { rw mk_sol, simp only [n.is_lt, dif_pos, fin.mk_coe] }
7575

7676
/-- If `u` is a solution to `E` and `init` designates its first `E.order` values,
7777
then `∀ n, u n = E.mk_sol init n`. -/
@@ -84,7 +84,7 @@ lemma eq_mk_of_is_sol_of_eq_init {u : ℕ → α} {init : fin E.order → α}
8484
rw [mk_sol, ← nat.sub_add_cancel (le_of_not_lt h'), h (n-E.order)],
8585
simp [h'],
8686
congr' with k,
87-
exact have wf : n - E.order + k.1 < n, by have := k.2; omega,
87+
exact have wf : n - E.order + k < n, by have := k.is_lt; omega,
8888
by rw eq_mk_of_is_sol_of_eq_init
8989
end
9090

@@ -140,7 +140,7 @@ end
140140
/-- `E.tuple_succ` maps `![s₀, s₁, ..., sₙ]` to `![s₁, ..., sₙ, ∑ (E.coeffs i) * sᵢ]`,
141141
where `n := E.order`. -/
142142
def tuple_succ : (fin E.order → α) →ₗ[α] (fin E.order → α) :=
143-
{ to_fun := λ X i, if h : i.1 + 1 < E.order then X ⟨i+1, h⟩ else (∑ i, E.coeffs i * X i),
143+
{ to_fun := λ X i, if h : (i : ℕ) + 1 < E.order then X ⟨i+1, h⟩ else (∑ i, E.coeffs i * X i),
144144
map_add' := λ x y,
145145
begin
146146
ext i,

src/algebra/order.lean

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,8 @@ lemma lt_of_not_ge' [linear_order α] {a b : α} (h : ¬ b ≤ a) : a < b :=
117117
lemma lt_iff_not_ge' [linear_order α] {x y : α} : x < y ↔ ¬ y ≤ x :=
118118
⟨not_le_of_gt, lt_of_not_ge'⟩
119119

120-
@[simp] lemma not_lt [linear_order α] {a b : α} : ¬ a < b ↔ b ≤ a := ⟨le_of_not_gt, not_lt_of_ge⟩
121-
122120
lemma le_of_not_lt [linear_order α] {a b : α} : ¬ a < b → b ≤ a := not_lt.1
123121

124-
@[simp] lemma not_le [linear_order α] {a b : α} : ¬ a ≤ b ↔ b < a := lt_iff_not_ge'.symm
125-
126122
lemma lt_or_le [linear_order α] : ∀ a b : α, a < b ∨ b ≤ a := lt_or_ge
127123
lemma le_or_lt [linear_order α] : ∀ a b : α, a ≤ b ∨ b < a := le_or_gt
128124

@@ -208,62 +204,6 @@ calc c
208204

209205
namespace decidable
210206

211-
-- See Note [decidable namespace]
212-
lemma lt_or_eq_of_le [partial_order α] [@decidable_rel α (≤)] {a b : α} (hab : a ≤ b) : a < b ∨ a = b :=
213-
if hba : b ≤ a then or.inr (le_antisymm hab hba)
214-
else or.inl (lt_of_le_not_le hab hba)
215-
216-
-- See Note [decidable namespace]
217-
lemma eq_or_lt_of_le [partial_order α] [@decidable_rel α (≤)] {a b : α} (hab : a ≤ b) : a = b ∨ a < b :=
218-
(lt_or_eq_of_le hab).swap
219-
220-
-- See Note [decidable namespace]
221-
lemma le_iff_lt_or_eq [partial_order α] [@decidable_rel α (≤)] {a b : α} : a ≤ b ↔ a < b ∨ a = b :=
222-
⟨lt_or_eq_of_le, le_of_lt_or_eq⟩
223-
224-
-- See Note [decidable namespace]
225-
lemma le_of_not_lt [decidable_linear_order α] {a b : α} (h : ¬ b < a) : a ≤ b :=
226-
decidable.by_contradiction $ λ h', h $ lt_of_le_not_le ((le_total _ _).resolve_right h') h'
227-
228-
-- See Note [decidable namespace]
229-
lemma not_lt [decidable_linear_order α] {a b : α} : ¬ a < b ↔ b ≤ a :=
230-
⟨le_of_not_lt, not_lt_of_ge⟩
231-
232-
-- See Note [decidable namespace]
233-
lemma lt_or_le [decidable_linear_order α] (a b : α) : a < b ∨ b ≤ a :=
234-
if hba : b ≤ a then or.inr hba else or.inl $ not_le.1 hba
235-
236-
-- See Note [decidable namespace]
237-
lemma le_or_lt [decidable_linear_order α] (a b : α) : a ≤ b ∨ b < a :=
238-
(lt_or_le b a).swap
239-
240-
-- See Note [decidable namespace]
241-
lemma lt_trichotomy [decidable_linear_order α] (a b : α) : a < b ∨ a = b ∨ b < a :=
242-
(lt_or_le _ _).imp_right $ λ h, (eq_or_lt_of_le h).imp_left eq.symm
243-
244-
-- See Note [decidable namespace]
245-
lemma lt_or_gt_of_ne [decidable_linear_order α] {a b : α} (h : a ≠ b) : a < b ∨ b < a :=
246-
(lt_trichotomy a b).imp_right $ λ h', h'.resolve_left h
247-
248-
/-- Perform a case-split on the ordering of `x` and `y` in a decidable linear order. -/
249-
-- See Note [decidable namespace]
250-
def lt_by_cases [decidable_linear_order α] (x y : α) {P : Sort*}
251-
(h₁ : x < y → P) (h₂ : x = y → P) (h₃ : y < x → P) : P :=
252-
begin
253-
by_cases h : x < y, { exact h₁ h },
254-
by_cases h' : y < x, { exact h₃ h' },
255-
apply h₂, apply le_antisymm; apply le_of_not_gt; assumption
256-
end
257-
258-
-- See Note [decidable namespace]
259-
lemma ne_iff_lt_or_gt [decidable_linear_order α] {a b : α} : a ≠ b ↔ a < b ∨ b < a :=
260-
⟨lt_or_gt_of_ne, λo, o.elim ne_of_lt ne_of_gt⟩
261-
262-
-- See Note [decidable namespace]
263-
lemma le_imp_le_of_lt_imp_lt {β} [preorder α] [decidable_linear_order β]
264-
{a b : α} {c d : β} (H : d < c → b < a) (h : a ≤ b) : c ≤ d :=
265-
le_of_not_lt $ λ h', (H h').not_le h
266-
267207
-- See Note [decidable namespace]
268208
lemma le_imp_le_iff_lt_imp_lt {β} [linear_order α] [decidable_linear_order β]
269209
{a b : α} {c d : β} : (a ≤ b → c ≤ d) ↔ (d < c → b < a) :=

src/analysis/analytic/composition.lean

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ begin
101101
intros j hjn hj1,
102102
obtain rfl : j = 0, { linarith },
103103
refine congr_arg v _,
104-
rw [fin.ext_iff, fin.cast_le_val, composition.ones_embedding],
104+
rw [fin.ext_iff, fin.coe_cast_le, composition.ones_embedding, fin.coe_mk],
105105
end
106106

107107
/-- Technical lemma stating how `p.apply_composition` commutes with updating variables. This
@@ -295,7 +295,7 @@ begin
295295
intros,
296296
rw apply_composition_ones,
297297
refine congr_arg v _,
298-
rw [fin.ext_iff, fin.cast_le_val], },
298+
rw [fin.ext_iff, fin.coe_cast_le, fin.coe_mk, fin.coe_mk], },
299299
show ∀ (b : composition n),
300300
b ∈ finset.univ → b ≠ composition.ones n → comp_along_composition p (id 𝕜 E) b = 0,
301301
{ assume b _ hb,
@@ -520,13 +520,13 @@ end
520520
lemma comp_change_of_variables_blocks_fun
521521
(N : ℕ) {i : Σ n, (fin n) → ℕ} (hi : i ∈ comp_partial_sum_source N) (j : fin i.1) :
522522
(comp_change_of_variables N i hi).2.blocks_fun
523-
⟨j.val, (comp_change_of_variables_length N hi).symm ▸ j.2⟩ = i.2 j :=
523+
⟨j, (comp_change_of_variables_length N hi).symm ▸ j.2⟩ = i.2 j :=
524524
begin
525525
rcases i with ⟨n, f⟩,
526526
dsimp [composition.blocks_fun, composition.blocks, comp_change_of_variables],
527527
simp only [map_of_fn, nth_le_of_fn', function.comp_app],
528528
apply congr_arg,
529-
rw fin.ext_iff
529+
rw [fin.ext_iff, fin.mk_coe]
530530
end
531531

532532
/-- Target set in the change of variables to compute the composition of partial sums of formal
@@ -546,7 +546,8 @@ begin
546546
{ dsimp [comp_change_of_variables],
547547
rw composition.sigma_eq_iff_blocks_eq,
548548
simp only [composition.blocks_fun, composition.blocks, subtype.coe_eta, nth_le_map'],
549-
conv_lhs { rw ← of_fn_nth_le c.blocks } }
549+
conv_lhs { rw ← of_fn_nth_le c.blocks },
550+
simp only [fin.val_eq_coe], refl, /- where does this fin.val come from? -/ }
550551
end
551552

552553
/-- Target set in the change of variables to compute the composition of partial sums of formal
@@ -861,8 +862,8 @@ begin
861862
induction h,
862863
simp only [true_and, eq_self_iff_true, heq_iff_eq],
863864
ext i : 2,
864-
have : nth_le (of_fn (λ (i : fin (composition.length a)), (b i).blocks)) i.1 (by simp [i.2]) =
865-
nth_le (of_fn (λ (i : fin (composition.length a)), (b' i).blocks)) i.1 (by simp [i.2]) :=
865+
have : nth_le (of_fn (λ (i : fin (composition.length a)), (b i).blocks)) i (by simp [i.is_lt]) =
866+
nth_le (of_fn (λ (i : fin (composition.length a)), (b' i).blocks)) i (by simp [i.is_lt]) :=
866867
nth_le_of_eq H _,
867868
rwa [nth_le_of_fn, nth_le_of_fn] at this
868869
end
@@ -899,22 +900,23 @@ two compositions `a` of `n` and `b` of `a.length`, and an index `i` bounded by t
899900
def sigma_composition_aux (a : composition n) (b : composition a.length)
900901
(i : fin (a.gather b).length) :
901902
composition ((a.gather b).blocks_fun i) :=
902-
{ blocks := nth_le (a.blocks.split_wrt_composition b) i.val
903+
{ blocks := nth_le (a.blocks.split_wrt_composition b) i
903904
(by { rw [length_split_wrt_composition, ← length_gather], exact i.2 }),
904905
blocks_pos := assume i hi, a.blocks_pos
905906
(by { rw ← a.blocks.join_split_wrt_composition b, exact mem_join_of_mem (nth_le_mem _ _ _) hi }),
906-
blocks_sum := by simp only [composition.blocks_fun, nth_le_map', composition.gather] }
907+
blocks_sum := by simp only [composition.blocks_fun, nth_le_map', composition.gather, fin.val_eq_coe] }
908+
/- Where did the fin.val come from in the proof on the preceding line? -/
907909

908910
lemma length_sigma_composition_aux (a : composition n) (b : composition a.length) (i : fin b.length) :
909-
composition.length (composition.sigma_composition_aux a b ⟨i.val, (length_gather a b).symm ▸ i.2⟩) =
911+
composition.length (composition.sigma_composition_aux a b ⟨i, (length_gather a b).symm ▸ i.2⟩) =
910912
composition.blocks_fun b i :=
911-
show list.length (nth_le (split_wrt_composition a.blocks b) i.val _) = blocks_fun b i,
913+
show list.length (nth_le (split_wrt_composition a.blocks b) i _) = blocks_fun b i,
912914
by { rw [nth_le_map_rev list.length, nth_le_of_eq (map_length_split_wrt_composition _ _)], refl }
913915

914916
lemma blocks_fun_sigma_composition_aux (a : composition n) (b : composition a.length)
915917
(i : fin b.length) (j : fin (blocks_fun b i)) :
916-
blocks_fun (sigma_composition_aux a b ⟨i.val, (length_gather a b).symm ▸ i.2⟩)
917-
⟨j.val, (length_sigma_composition_aux a b i).symm ▸ j.2⟩ = blocks_fun a (embedding b i j) :=
918+
blocks_fun (sigma_composition_aux a b ⟨i, (length_gather a b).symm ▸ i.2⟩)
919+
⟨j, (length_sigma_composition_aux a b i).symm ▸ j.2⟩ = blocks_fun a (embedding b i j) :=
918920
show nth_le (nth_le _ _ _) _ _ = nth_le a.blocks _ _,
919921
by { rw [nth_le_of_eq (nth_le_split_wrt_composition _ _ _), nth_le_drop', nth_le_take'], refl }
920922

@@ -951,14 +953,14 @@ begin
951953
rw [take_append_drop] } },
952954
{ have A : j < blocks_fun b ⟨i, hi⟩ := lt_trans (lt_add_one j) hj,
953955
have B : j < length (sigma_composition_aux a b ⟨i, (length_gather a b).symm ▸ hi⟩),
954-
by { convert A, rw ← length_sigma_composition_aux },
956+
by { convert A, rw [← length_sigma_composition_aux], refl },
955957
have C : size_up_to b i + j < size_up_to b (i + 1),
956958
{ simp only [size_up_to_succ b hi, add_lt_add_iff_left],
957959
exact A },
958960
have D : size_up_to b i + j < length a := lt_of_lt_of_le C (b.size_up_to_le _),
959961
have : size_up_to b i + nat.succ j = (size_up_to b i + j).succ := rfl,
960962
rw [this, size_up_to_succ _ D, IHj A, size_up_to_succ _ B],
961-
simp only [sigma_composition_aux, add_assoc, add_left_inj],
963+
simp only [sigma_composition_aux, add_assoc, add_left_inj, fin.coe_mk],
962964
rw [nth_le_of_eq (nth_le_split_wrt_composition _ _ _), nth_le_drop', nth_le_take _ _ C] }
963965
end
964966

@@ -1014,7 +1016,7 @@ def sigma_equiv_sigma_pi (n : ℕ) :
10141016
{ exact B },
10151017
{ apply (fin.heq_fun_iff B).2 (λ i, _),
10161018
rw [sigma_composition_aux, composition.length, nth_le_map_rev list.length,
1017-
nth_le_of_eq (map_length_split_wrt_composition _ _)] } }
1019+
nth_le_of_eq (map_length_split_wrt_composition _ _)], refl } }
10181020
end,
10191021
right_inv :=
10201022
begin

0 commit comments

Comments
 (0)