Context
stringlengths
57
6.04k
file_name
stringlengths
21
79
start
int64
14
1.49k
end
int64
18
1.5k
theorem
stringlengths
25
1.55k
proof
stringlengths
5
7.36k
rank
int64
0
2.4k
import Mathlib.Analysis.Normed.Group.Basic #align_import information_theory.hamming from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" section HammingDistNorm open Finset Function variable {α ι : Type*} {β : ι → Type*} [Fintype ι] [∀ i, DecidableEq (β i)] variable {γ : ι → Type*} [∀ i, DecidableEq (γ i)] def hammingDist (x y : ∀ i, β i) : ℕ := (univ.filter fun i => x i ≠ y i).card #align hamming_dist hammingDist @[simp] theorem hammingDist_self (x : ∀ i, β i) : hammingDist x x = 0 := by rw [hammingDist, card_eq_zero, filter_eq_empty_iff] exact fun _ _ H => H rfl #align hamming_dist_self hammingDist_self theorem hammingDist_nonneg {x y : ∀ i, β i} : 0 ≤ hammingDist x y := zero_le _ #align hamming_dist_nonneg hammingDist_nonneg theorem hammingDist_comm (x y : ∀ i, β i) : hammingDist x y = hammingDist y x := by simp_rw [hammingDist, ne_comm] #align hamming_dist_comm hammingDist_comm theorem hammingDist_triangle (x y z : ∀ i, β i) : hammingDist x z ≤ hammingDist x y + hammingDist y z := by classical unfold hammingDist refine le_trans (card_mono ?_) (card_union_le _ _) rw [← filter_or] exact monotone_filter_right _ fun i h ↦ (h.ne_or_ne _).imp_right Ne.symm #align hamming_dist_triangle hammingDist_triangle theorem hammingDist_triangle_left (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist z x + hammingDist z y := by rw [hammingDist_comm z] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_left hammingDist_triangle_left theorem hammingDist_triangle_right (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist x z + hammingDist y z := by rw [hammingDist_comm y] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_right hammingDist_triangle_right theorem swap_hammingDist : swap (@hammingDist _ β _ _) = hammingDist := by funext x y exact hammingDist_comm _ _ #align swap_hamming_dist swap_hammingDist theorem eq_of_hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 → x = y := by simp_rw [hammingDist, card_eq_zero, filter_eq_empty_iff, Classical.not_not, funext_iff, mem_univ, forall_true_left, imp_self] #align eq_of_hamming_dist_eq_zero eq_of_hammingDist_eq_zero @[simp] theorem hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 ↔ x = y := ⟨eq_of_hammingDist_eq_zero, fun H => by rw [H] exact hammingDist_self _⟩ #align hamming_dist_eq_zero hammingDist_eq_zero @[simp]
Mathlib/InformationTheory/Hamming.lean
106
107
theorem hamming_zero_eq_dist {x y : ∀ i, β i} : 0 = hammingDist x y ↔ x = y := by
rw [eq_comm, hammingDist_eq_zero]
652
import Mathlib.Analysis.Normed.Group.Basic #align_import information_theory.hamming from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" section HammingDistNorm open Finset Function variable {α ι : Type*} {β : ι → Type*} [Fintype ι] [∀ i, DecidableEq (β i)] variable {γ : ι → Type*} [∀ i, DecidableEq (γ i)] def hammingDist (x y : ∀ i, β i) : ℕ := (univ.filter fun i => x i ≠ y i).card #align hamming_dist hammingDist @[simp] theorem hammingDist_self (x : ∀ i, β i) : hammingDist x x = 0 := by rw [hammingDist, card_eq_zero, filter_eq_empty_iff] exact fun _ _ H => H rfl #align hamming_dist_self hammingDist_self theorem hammingDist_nonneg {x y : ∀ i, β i} : 0 ≤ hammingDist x y := zero_le _ #align hamming_dist_nonneg hammingDist_nonneg theorem hammingDist_comm (x y : ∀ i, β i) : hammingDist x y = hammingDist y x := by simp_rw [hammingDist, ne_comm] #align hamming_dist_comm hammingDist_comm theorem hammingDist_triangle (x y z : ∀ i, β i) : hammingDist x z ≤ hammingDist x y + hammingDist y z := by classical unfold hammingDist refine le_trans (card_mono ?_) (card_union_le _ _) rw [← filter_or] exact monotone_filter_right _ fun i h ↦ (h.ne_or_ne _).imp_right Ne.symm #align hamming_dist_triangle hammingDist_triangle theorem hammingDist_triangle_left (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist z x + hammingDist z y := by rw [hammingDist_comm z] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_left hammingDist_triangle_left theorem hammingDist_triangle_right (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist x z + hammingDist y z := by rw [hammingDist_comm y] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_right hammingDist_triangle_right theorem swap_hammingDist : swap (@hammingDist _ β _ _) = hammingDist := by funext x y exact hammingDist_comm _ _ #align swap_hamming_dist swap_hammingDist theorem eq_of_hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 → x = y := by simp_rw [hammingDist, card_eq_zero, filter_eq_empty_iff, Classical.not_not, funext_iff, mem_univ, forall_true_left, imp_self] #align eq_of_hamming_dist_eq_zero eq_of_hammingDist_eq_zero @[simp] theorem hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 ↔ x = y := ⟨eq_of_hammingDist_eq_zero, fun H => by rw [H] exact hammingDist_self _⟩ #align hamming_dist_eq_zero hammingDist_eq_zero @[simp] theorem hamming_zero_eq_dist {x y : ∀ i, β i} : 0 = hammingDist x y ↔ x = y := by rw [eq_comm, hammingDist_eq_zero] #align hamming_zero_eq_dist hamming_zero_eq_dist theorem hammingDist_ne_zero {x y : ∀ i, β i} : hammingDist x y ≠ 0 ↔ x ≠ y := hammingDist_eq_zero.not #align hamming_dist_ne_zero hammingDist_ne_zero @[simp]
Mathlib/InformationTheory/Hamming.lean
117
118
theorem hammingDist_pos {x y : ∀ i, β i} : 0 < hammingDist x y ↔ x ≠ y := by
rw [← hammingDist_ne_zero, iff_not_comm, not_lt, Nat.le_zero]
652
import Mathlib.Analysis.Normed.Group.Basic #align_import information_theory.hamming from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" section HammingDistNorm open Finset Function variable {α ι : Type*} {β : ι → Type*} [Fintype ι] [∀ i, DecidableEq (β i)] variable {γ : ι → Type*} [∀ i, DecidableEq (γ i)] def hammingDist (x y : ∀ i, β i) : ℕ := (univ.filter fun i => x i ≠ y i).card #align hamming_dist hammingDist @[simp] theorem hammingDist_self (x : ∀ i, β i) : hammingDist x x = 0 := by rw [hammingDist, card_eq_zero, filter_eq_empty_iff] exact fun _ _ H => H rfl #align hamming_dist_self hammingDist_self theorem hammingDist_nonneg {x y : ∀ i, β i} : 0 ≤ hammingDist x y := zero_le _ #align hamming_dist_nonneg hammingDist_nonneg theorem hammingDist_comm (x y : ∀ i, β i) : hammingDist x y = hammingDist y x := by simp_rw [hammingDist, ne_comm] #align hamming_dist_comm hammingDist_comm theorem hammingDist_triangle (x y z : ∀ i, β i) : hammingDist x z ≤ hammingDist x y + hammingDist y z := by classical unfold hammingDist refine le_trans (card_mono ?_) (card_union_le _ _) rw [← filter_or] exact monotone_filter_right _ fun i h ↦ (h.ne_or_ne _).imp_right Ne.symm #align hamming_dist_triangle hammingDist_triangle theorem hammingDist_triangle_left (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist z x + hammingDist z y := by rw [hammingDist_comm z] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_left hammingDist_triangle_left theorem hammingDist_triangle_right (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist x z + hammingDist y z := by rw [hammingDist_comm y] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_right hammingDist_triangle_right theorem swap_hammingDist : swap (@hammingDist _ β _ _) = hammingDist := by funext x y exact hammingDist_comm _ _ #align swap_hamming_dist swap_hammingDist theorem eq_of_hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 → x = y := by simp_rw [hammingDist, card_eq_zero, filter_eq_empty_iff, Classical.not_not, funext_iff, mem_univ, forall_true_left, imp_self] #align eq_of_hamming_dist_eq_zero eq_of_hammingDist_eq_zero @[simp] theorem hammingDist_eq_zero {x y : ∀ i, β i} : hammingDist x y = 0 ↔ x = y := ⟨eq_of_hammingDist_eq_zero, fun H => by rw [H] exact hammingDist_self _⟩ #align hamming_dist_eq_zero hammingDist_eq_zero @[simp] theorem hamming_zero_eq_dist {x y : ∀ i, β i} : 0 = hammingDist x y ↔ x = y := by rw [eq_comm, hammingDist_eq_zero] #align hamming_zero_eq_dist hamming_zero_eq_dist theorem hammingDist_ne_zero {x y : ∀ i, β i} : hammingDist x y ≠ 0 ↔ x ≠ y := hammingDist_eq_zero.not #align hamming_dist_ne_zero hammingDist_ne_zero @[simp] theorem hammingDist_pos {x y : ∀ i, β i} : 0 < hammingDist x y ↔ x ≠ y := by rw [← hammingDist_ne_zero, iff_not_comm, not_lt, Nat.le_zero] #align hamming_dist_pos hammingDist_pos -- @[simp] -- Porting note (#10618): simp can prove this
Mathlib/InformationTheory/Hamming.lean
122
123
theorem hammingDist_lt_one {x y : ∀ i, β i} : hammingDist x y < 1 ↔ x = y := by
rw [Nat.lt_one_iff, hammingDist_eq_zero]
652
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" namespace MeasureTheory open Filter open scoped ENNReal variable {α E : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} [NormedAddCommGroup E]
Mathlib/MeasureTheory/Function/LpSeminorm/Trim.lean
25
32
theorem snorm'_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm' f q (μ.trim hm) = snorm' f q μ := by
simp_rw [snorm'] congr 1 refine lintegral_trim hm ?_ refine @Measurable.pow_const _ _ _ _ _ _ _ m _ (@Measurable.coe_nnreal_ennreal _ m _ ?_) q apply @StronglyMeasurable.measurable exact @StronglyMeasurable.nnnorm α m _ _ _ hf
653
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" namespace MeasureTheory open Filter open scoped ENNReal variable {α E : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} [NormedAddCommGroup E] theorem snorm'_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm' f q (μ.trim hm) = snorm' f q μ := by simp_rw [snorm'] congr 1 refine lintegral_trim hm ?_ refine @Measurable.pow_const _ _ _ _ _ _ _ m _ (@Measurable.coe_nnreal_ennreal _ m _ ?_) q apply @StronglyMeasurable.measurable exact @StronglyMeasurable.nnnorm α m _ _ _ hf #align measure_theory.snorm'_trim MeasureTheory.snorm'_trim
Mathlib/MeasureTheory/Function/LpSeminorm/Trim.lean
35
45
theorem limsup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : limsup f (ae (μ.trim hm)) = limsup f (ae μ) := by
simp_rw [limsup_eq] suffices h_set_eq : { a : ℝ≥0∞ | ∀ᵐ n ∂μ.trim hm, f n ≤ a } = { a : ℝ≥0∞ | ∀ᵐ n ∂μ, f n ≤ a } by rw [h_set_eq] ext1 a suffices h_meas_eq : μ { x | ¬f x ≤ a } = μ.trim hm { x | ¬f x ≤ a } by simp_rw [Set.mem_setOf_eq, ae_iff, h_meas_eq] refine (trim_measurableSet_eq hm ?_).symm refine @MeasurableSet.compl _ _ m (@measurableSet_le ℝ≥0∞ _ _ _ _ m _ _ _ _ _ hf ?_) exact @measurable_const _ _ _ m _
653
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" namespace MeasureTheory open Filter open scoped ENNReal variable {α E : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} [NormedAddCommGroup E] theorem snorm'_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm' f q (μ.trim hm) = snorm' f q μ := by simp_rw [snorm'] congr 1 refine lintegral_trim hm ?_ refine @Measurable.pow_const _ _ _ _ _ _ _ m _ (@Measurable.coe_nnreal_ennreal _ m _ ?_) q apply @StronglyMeasurable.measurable exact @StronglyMeasurable.nnnorm α m _ _ _ hf #align measure_theory.snorm'_trim MeasureTheory.snorm'_trim theorem limsup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : limsup f (ae (μ.trim hm)) = limsup f (ae μ) := by simp_rw [limsup_eq] suffices h_set_eq : { a : ℝ≥0∞ | ∀ᵐ n ∂μ.trim hm, f n ≤ a } = { a : ℝ≥0∞ | ∀ᵐ n ∂μ, f n ≤ a } by rw [h_set_eq] ext1 a suffices h_meas_eq : μ { x | ¬f x ≤ a } = μ.trim hm { x | ¬f x ≤ a } by simp_rw [Set.mem_setOf_eq, ae_iff, h_meas_eq] refine (trim_measurableSet_eq hm ?_).symm refine @MeasurableSet.compl _ _ m (@measurableSet_le ℝ≥0∞ _ _ _ _ m _ _ _ _ _ hf ?_) exact @measurable_const _ _ _ m _ #align measure_theory.limsup_trim MeasureTheory.limsup_trim
Mathlib/MeasureTheory/Function/LpSeminorm/Trim.lean
48
51
theorem essSup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : essSup f (μ.trim hm) = essSup f μ := by
simp_rw [essSup] exact limsup_trim hm hf
653
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" namespace MeasureTheory open Filter open scoped ENNReal variable {α E : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} [NormedAddCommGroup E] theorem snorm'_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm' f q (μ.trim hm) = snorm' f q μ := by simp_rw [snorm'] congr 1 refine lintegral_trim hm ?_ refine @Measurable.pow_const _ _ _ _ _ _ _ m _ (@Measurable.coe_nnreal_ennreal _ m _ ?_) q apply @StronglyMeasurable.measurable exact @StronglyMeasurable.nnnorm α m _ _ _ hf #align measure_theory.snorm'_trim MeasureTheory.snorm'_trim theorem limsup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : limsup f (ae (μ.trim hm)) = limsup f (ae μ) := by simp_rw [limsup_eq] suffices h_set_eq : { a : ℝ≥0∞ | ∀ᵐ n ∂μ.trim hm, f n ≤ a } = { a : ℝ≥0∞ | ∀ᵐ n ∂μ, f n ≤ a } by rw [h_set_eq] ext1 a suffices h_meas_eq : μ { x | ¬f x ≤ a } = μ.trim hm { x | ¬f x ≤ a } by simp_rw [Set.mem_setOf_eq, ae_iff, h_meas_eq] refine (trim_measurableSet_eq hm ?_).symm refine @MeasurableSet.compl _ _ m (@measurableSet_le ℝ≥0∞ _ _ _ _ m _ _ _ _ _ hf ?_) exact @measurable_const _ _ _ m _ #align measure_theory.limsup_trim MeasureTheory.limsup_trim theorem essSup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : essSup f (μ.trim hm) = essSup f μ := by simp_rw [essSup] exact limsup_trim hm hf #align measure_theory.ess_sup_trim MeasureTheory.essSup_trim theorem snormEssSup_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snormEssSup f (μ.trim hm) = snormEssSup f μ := essSup_trim _ (@StronglyMeasurable.ennnorm _ m _ _ _ hf) #align measure_theory.snorm_ess_sup_trim MeasureTheory.snormEssSup_trim
Mathlib/MeasureTheory/Function/LpSeminorm/Trim.lean
59
65
theorem snorm_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm f p (μ.trim hm) = snorm f p μ := by
by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · simpa only [h_top, snorm_exponent_top] using snormEssSup_trim hm hf simpa only [snorm_eq_snorm' h0 h_top] using snorm'_trim hm hf
653
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic #align_import measure_theory.function.lp_seminorm from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9" namespace MeasureTheory open Filter open scoped ENNReal variable {α E : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} [NormedAddCommGroup E] theorem snorm'_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm' f q (μ.trim hm) = snorm' f q μ := by simp_rw [snorm'] congr 1 refine lintegral_trim hm ?_ refine @Measurable.pow_const _ _ _ _ _ _ _ m _ (@Measurable.coe_nnreal_ennreal _ m _ ?_) q apply @StronglyMeasurable.measurable exact @StronglyMeasurable.nnnorm α m _ _ _ hf #align measure_theory.snorm'_trim MeasureTheory.snorm'_trim theorem limsup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : limsup f (ae (μ.trim hm)) = limsup f (ae μ) := by simp_rw [limsup_eq] suffices h_set_eq : { a : ℝ≥0∞ | ∀ᵐ n ∂μ.trim hm, f n ≤ a } = { a : ℝ≥0∞ | ∀ᵐ n ∂μ, f n ≤ a } by rw [h_set_eq] ext1 a suffices h_meas_eq : μ { x | ¬f x ≤ a } = μ.trim hm { x | ¬f x ≤ a } by simp_rw [Set.mem_setOf_eq, ae_iff, h_meas_eq] refine (trim_measurableSet_eq hm ?_).symm refine @MeasurableSet.compl _ _ m (@measurableSet_le ℝ≥0∞ _ _ _ _ m _ _ _ _ _ hf ?_) exact @measurable_const _ _ _ m _ #align measure_theory.limsup_trim MeasureTheory.limsup_trim theorem essSup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : essSup f (μ.trim hm) = essSup f μ := by simp_rw [essSup] exact limsup_trim hm hf #align measure_theory.ess_sup_trim MeasureTheory.essSup_trim theorem snormEssSup_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snormEssSup f (μ.trim hm) = snormEssSup f μ := essSup_trim _ (@StronglyMeasurable.ennnorm _ m _ _ _ hf) #align measure_theory.snorm_ess_sup_trim MeasureTheory.snormEssSup_trim theorem snorm_trim (hm : m ≤ m0) {f : α → E} (hf : StronglyMeasurable[m] f) : snorm f p (μ.trim hm) = snorm f p μ := by by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · simpa only [h_top, snorm_exponent_top] using snormEssSup_trim hm hf simpa only [snorm_eq_snorm' h0 h_top] using snorm'_trim hm hf #align measure_theory.snorm_trim MeasureTheory.snorm_trim
Mathlib/MeasureTheory/Function/LpSeminorm/Trim.lean
68
71
theorem snorm_trim_ae (hm : m ≤ m0) {f : α → E} (hf : AEStronglyMeasurable f (μ.trim hm)) : snorm f p (μ.trim hm) = snorm f p μ := by
rw [snorm_congr_ae hf.ae_eq_mk, snorm_congr_ae (ae_eq_of_ae_eq_trim hf.ae_eq_mk)] exact snorm_trim hm hf.stronglyMeasurable_mk
653
import Mathlib.Analysis.Calculus.Deriv.Inv import Mathlib.Analysis.NormedSpace.Real #align_import analysis.calculus.diff_cont_on_cl from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" open Set Filter Metric open scoped Topology variable (𝕜 : Type*) {E F G : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G] {f g : E → F} {s t : Set E} {x : E} structure DiffContOnCl (f : E → F) (s : Set E) : Prop where protected differentiableOn : DifferentiableOn 𝕜 f s protected continuousOn : ContinuousOn f (closure s) #align diff_cont_on_cl DiffContOnCl variable {𝕜} theorem DifferentiableOn.diffContOnCl (h : DifferentiableOn 𝕜 f (closure s)) : DiffContOnCl 𝕜 f s := ⟨h.mono subset_closure, h.continuousOn⟩ #align differentiable_on.diff_cont_on_cl DifferentiableOn.diffContOnCl theorem Differentiable.diffContOnCl (h : Differentiable 𝕜 f) : DiffContOnCl 𝕜 f s := ⟨h.differentiableOn, h.continuous.continuousOn⟩ #align differentiable.diff_cont_on_cl Differentiable.diffContOnCl theorem IsClosed.diffContOnCl_iff (hs : IsClosed s) : DiffContOnCl 𝕜 f s ↔ DifferentiableOn 𝕜 f s := ⟨fun h => h.differentiableOn, fun h => ⟨h, hs.closure_eq.symm ▸ h.continuousOn⟩⟩ #align is_closed.diff_cont_on_cl_iff IsClosed.diffContOnCl_iff theorem diffContOnCl_univ : DiffContOnCl 𝕜 f univ ↔ Differentiable 𝕜 f := isClosed_univ.diffContOnCl_iff.trans differentiableOn_univ #align diff_cont_on_cl_univ diffContOnCl_univ theorem diffContOnCl_const {c : F} : DiffContOnCl 𝕜 (fun _ : E => c) s := ⟨differentiableOn_const c, continuousOn_const⟩ #align diff_cont_on_cl_const diffContOnCl_const namespace DiffContOnCl theorem comp {g : G → E} {t : Set G} (hf : DiffContOnCl 𝕜 f s) (hg : DiffContOnCl 𝕜 g t) (h : MapsTo g t s) : DiffContOnCl 𝕜 (f ∘ g) t := ⟨hf.1.comp hg.1 h, hf.2.comp hg.2 <| h.closure_of_continuousOn hg.2⟩ #align diff_cont_on_cl.comp DiffContOnCl.comp
Mathlib/Analysis/Calculus/DiffContOnCl.lean
64
70
theorem continuousOn_ball [NormedSpace ℝ E] {x : E} {r : ℝ} (h : DiffContOnCl 𝕜 f (ball x r)) : ContinuousOn f (closedBall x r) := by
rcases eq_or_ne r 0 with (rfl | hr) · rw [closedBall_zero] exact continuousOn_singleton f x · rw [← closure_ball x hr] exact h.continuousOn
654
import Mathlib.Data.List.Basic #align_import data.list.infix from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" open Nat variable {α β : Type*} namespace List variable {l l₁ l₂ l₃ : List α} {a b : α} {m n : ℕ} section Fix #align list.prefix_append List.prefix_append #align list.suffix_append List.suffix_append #align list.infix_append List.infix_append #align list.infix_append' List.infix_append' #align list.is_prefix.is_infix List.IsPrefix.isInfix #align list.is_suffix.is_infix List.IsSuffix.isInfix #align list.nil_prefix List.nil_prefix #align list.nil_suffix List.nil_suffix #align list.nil_infix List.nil_infix #align list.prefix_refl List.prefix_refl #align list.suffix_refl List.suffix_refl #align list.infix_refl List.infix_refl theorem prefix_rfl : l <+: l := prefix_refl _ #align list.prefix_rfl List.prefix_rfl theorem suffix_rfl : l <:+ l := suffix_refl _ #align list.suffix_rfl List.suffix_rfl theorem infix_rfl : l <:+: l := infix_refl _ #align list.infix_rfl List.infix_rfl #align list.suffix_cons List.suffix_cons
Mathlib/Data/List/Infix.lean
70
70
theorem prefix_concat (a : α) (l) : l <+: concat l a := by
simp
655
import Mathlib.Data.List.Basic #align_import data.list.infix from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" open Nat variable {α β : Type*} namespace List variable {l l₁ l₂ l₃ : List α} {a b : α} {m n : ℕ} section Fix #align list.prefix_append List.prefix_append #align list.suffix_append List.suffix_append #align list.infix_append List.infix_append #align list.infix_append' List.infix_append' #align list.is_prefix.is_infix List.IsPrefix.isInfix #align list.is_suffix.is_infix List.IsSuffix.isInfix #align list.nil_prefix List.nil_prefix #align list.nil_suffix List.nil_suffix #align list.nil_infix List.nil_infix #align list.prefix_refl List.prefix_refl #align list.suffix_refl List.suffix_refl #align list.infix_refl List.infix_refl theorem prefix_rfl : l <+: l := prefix_refl _ #align list.prefix_rfl List.prefix_rfl theorem suffix_rfl : l <:+ l := suffix_refl _ #align list.suffix_rfl List.suffix_rfl theorem infix_rfl : l <:+: l := infix_refl _ #align list.infix_rfl List.infix_rfl #align list.suffix_cons List.suffix_cons theorem prefix_concat (a : α) (l) : l <+: concat l a := by simp #align list.prefix_concat List.prefix_concat
Mathlib/Data/List/Infix.lean
73
76
theorem prefix_concat_iff {l₁ l₂ : List α} {a : α} : l₁ <+: l₂ ++ [a] ↔ l₁ = l₂ ++ [a] ∨ l₁ <+: l₂ := by
simpa only [← reverse_concat', reverse_inj, reverse_suffix] using suffix_cons_iff (l₁ := l₁.reverse) (l₂ := l₂.reverse)
655
import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Data.List.Infix import Mathlib.Data.List.MinMax import Mathlib.Data.List.EditDistance.Defs set_option autoImplicit true variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ]
Mathlib/Data/List/EditDistance/Bounds.lean
26
56
theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by
induction xs with | nil => simp only [suffixLevenshtein_nil', levenshtein_nil_cons, List.minimum_singleton, WithTop.coe_le_coe] exact le_add_of_nonneg_left (by simp) | cons x xs ih => suffices (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by simpa [suffixLevenshtein_eq_tails_map] refine ⟨?_, ?_, ?_⟩ · calc _ ≤ (suffixLevenshtein C xs ys).1.minimum := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ ↑(levenshtein C xs (y :: ys)) := ih _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons] apply min_le_of_right_le cases xs · simp [suffixLevenshtein_nil'] · simp [suffixLevenshtein_cons₁, List.minimum_cons] _ ≤ _ := by simp
656
import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Data.List.Infix import Mathlib.Data.List.MinMax import Mathlib.Data.List.EditDistance.Defs set_option autoImplicit true variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ] theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by induction xs with | nil => simp only [suffixLevenshtein_nil', levenshtein_nil_cons, List.minimum_singleton, WithTop.coe_le_coe] exact le_add_of_nonneg_left (by simp) | cons x xs ih => suffices (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by simpa [suffixLevenshtein_eq_tails_map] refine ⟨?_, ?_, ?_⟩ · calc _ ≤ (suffixLevenshtein C xs ys).1.minimum := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ ↑(levenshtein C xs (y :: ys)) := ih _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons] apply min_le_of_right_le cases xs · simp [suffixLevenshtein_nil'] · simp [suffixLevenshtein_cons₁, List.minimum_cons] _ ≤ _ := by simp
Mathlib/Data/List/EditDistance/Bounds.lean
58
73
theorem le_suffixLevenshtein_cons_minimum (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ (suffixLevenshtein C xs (y :: ys)).1.minimum := by
apply List.le_minimum_of_forall_le simp only [suffixLevenshtein_eq_tails_map] simp only [List.mem_map, List.mem_tails, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro a suff refine (?_ : _ ≤ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _) simp only [suffixLevenshtein_eq_tails_map] apply List.le_minimum_of_forall_le intro b m replace m : ∃ a_1, a_1 <:+ a ∧ levenshtein C a_1 ys = b := by simpa using m obtain ⟨a', suff', rfl⟩ := m apply List.minimum_le_of_mem' simp only [List.mem_map, List.mem_tails] suffices ∃ a, a <:+ xs ∧ levenshtein C a ys = levenshtein C a' ys by simpa exact ⟨a', suff'.trans suff, rfl⟩
656
import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Data.List.Infix import Mathlib.Data.List.MinMax import Mathlib.Data.List.EditDistance.Defs set_option autoImplicit true variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ] theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by induction xs with | nil => simp only [suffixLevenshtein_nil', levenshtein_nil_cons, List.minimum_singleton, WithTop.coe_le_coe] exact le_add_of_nonneg_left (by simp) | cons x xs ih => suffices (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by simpa [suffixLevenshtein_eq_tails_map] refine ⟨?_, ?_, ?_⟩ · calc _ ≤ (suffixLevenshtein C xs ys).1.minimum := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ ↑(levenshtein C xs (y :: ys)) := ih _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons] apply min_le_of_right_le cases xs · simp [suffixLevenshtein_nil'] · simp [suffixLevenshtein_cons₁, List.minimum_cons] _ ≤ _ := by simp theorem le_suffixLevenshtein_cons_minimum (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ (suffixLevenshtein C xs (y :: ys)).1.minimum := by apply List.le_minimum_of_forall_le simp only [suffixLevenshtein_eq_tails_map] simp only [List.mem_map, List.mem_tails, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro a suff refine (?_ : _ ≤ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _) simp only [suffixLevenshtein_eq_tails_map] apply List.le_minimum_of_forall_le intro b m replace m : ∃ a_1, a_1 <:+ a ∧ levenshtein C a_1 ys = b := by simpa using m obtain ⟨a', suff', rfl⟩ := m apply List.minimum_le_of_mem' simp only [List.mem_map, List.mem_tails] suffices ∃ a, a <:+ xs ∧ levenshtein C a ys = levenshtein C a' ys by simpa exact ⟨a', suff'.trans suff, rfl⟩
Mathlib/Data/List/EditDistance/Bounds.lean
75
79
theorem le_suffixLevenshtein_append_minimum (xs : List α) (ys₁ ys₂) : (suffixLevenshtein C xs ys₂).1.minimum ≤ (suffixLevenshtein C xs (ys₁ ++ ys₂)).1.minimum := by
induction ys₁ with | nil => exact le_refl _ | cons y ys₁ ih => exact ih.trans (le_suffixLevenshtein_cons_minimum _ _ _)
656
import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Data.List.Infix import Mathlib.Data.List.MinMax import Mathlib.Data.List.EditDistance.Defs set_option autoImplicit true variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ] theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by induction xs with | nil => simp only [suffixLevenshtein_nil', levenshtein_nil_cons, List.minimum_singleton, WithTop.coe_le_coe] exact le_add_of_nonneg_left (by simp) | cons x xs ih => suffices (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by simpa [suffixLevenshtein_eq_tails_map] refine ⟨?_, ?_, ?_⟩ · calc _ ≤ (suffixLevenshtein C xs ys).1.minimum := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ ↑(levenshtein C xs (y :: ys)) := ih _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons] apply min_le_of_right_le cases xs · simp [suffixLevenshtein_nil'] · simp [suffixLevenshtein_cons₁, List.minimum_cons] _ ≤ _ := by simp theorem le_suffixLevenshtein_cons_minimum (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ (suffixLevenshtein C xs (y :: ys)).1.minimum := by apply List.le_minimum_of_forall_le simp only [suffixLevenshtein_eq_tails_map] simp only [List.mem_map, List.mem_tails, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro a suff refine (?_ : _ ≤ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _) simp only [suffixLevenshtein_eq_tails_map] apply List.le_minimum_of_forall_le intro b m replace m : ∃ a_1, a_1 <:+ a ∧ levenshtein C a_1 ys = b := by simpa using m obtain ⟨a', suff', rfl⟩ := m apply List.minimum_le_of_mem' simp only [List.mem_map, List.mem_tails] suffices ∃ a, a <:+ xs ∧ levenshtein C a ys = levenshtein C a' ys by simpa exact ⟨a', suff'.trans suff, rfl⟩ theorem le_suffixLevenshtein_append_minimum (xs : List α) (ys₁ ys₂) : (suffixLevenshtein C xs ys₂).1.minimum ≤ (suffixLevenshtein C xs (ys₁ ++ ys₂)).1.minimum := by induction ys₁ with | nil => exact le_refl _ | cons y ys₁ ih => exact ih.trans (le_suffixLevenshtein_cons_minimum _ _ _)
Mathlib/Data/List/EditDistance/Bounds.lean
81
87
theorem suffixLevenshtein_minimum_le_levenshtein_append (xs ys₁ ys₂) : (suffixLevenshtein C xs ys₂).1.minimum ≤ levenshtein C xs (ys₁ ++ ys₂) := by
cases ys₁ with | nil => exact List.minimum_le_of_mem' (List.get_mem _ _ _) | cons y ys₁ => exact (le_suffixLevenshtein_append_minimum _ _ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _)
656
import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Data.List.Infix import Mathlib.Data.List.MinMax import Mathlib.Data.List.EditDistance.Defs set_option autoImplicit true variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ] theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by induction xs with | nil => simp only [suffixLevenshtein_nil', levenshtein_nil_cons, List.minimum_singleton, WithTop.coe_le_coe] exact le_add_of_nonneg_left (by simp) | cons x xs ih => suffices (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by simpa [suffixLevenshtein_eq_tails_map] refine ⟨?_, ?_, ?_⟩ · calc _ ≤ (suffixLevenshtein C xs ys).1.minimum := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ ↑(levenshtein C xs (y :: ys)) := ih _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons] apply min_le_of_right_le cases xs · simp [suffixLevenshtein_nil'] · simp [suffixLevenshtein_cons₁, List.minimum_cons] _ ≤ _ := by simp theorem le_suffixLevenshtein_cons_minimum (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ (suffixLevenshtein C xs (y :: ys)).1.minimum := by apply List.le_minimum_of_forall_le simp only [suffixLevenshtein_eq_tails_map] simp only [List.mem_map, List.mem_tails, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro a suff refine (?_ : _ ≤ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _) simp only [suffixLevenshtein_eq_tails_map] apply List.le_minimum_of_forall_le intro b m replace m : ∃ a_1, a_1 <:+ a ∧ levenshtein C a_1 ys = b := by simpa using m obtain ⟨a', suff', rfl⟩ := m apply List.minimum_le_of_mem' simp only [List.mem_map, List.mem_tails] suffices ∃ a, a <:+ xs ∧ levenshtein C a ys = levenshtein C a' ys by simpa exact ⟨a', suff'.trans suff, rfl⟩ theorem le_suffixLevenshtein_append_minimum (xs : List α) (ys₁ ys₂) : (suffixLevenshtein C xs ys₂).1.minimum ≤ (suffixLevenshtein C xs (ys₁ ++ ys₂)).1.minimum := by induction ys₁ with | nil => exact le_refl _ | cons y ys₁ ih => exact ih.trans (le_suffixLevenshtein_cons_minimum _ _ _) theorem suffixLevenshtein_minimum_le_levenshtein_append (xs ys₁ ys₂) : (suffixLevenshtein C xs ys₂).1.minimum ≤ levenshtein C xs (ys₁ ++ ys₂) := by cases ys₁ with | nil => exact List.minimum_le_of_mem' (List.get_mem _ _ _) | cons y ys₁ => exact (le_suffixLevenshtein_append_minimum _ _ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _)
Mathlib/Data/List/EditDistance/Bounds.lean
89
92
theorem le_levenshtein_cons (xs : List α) (y ys) : ∃ xs', xs' <:+ xs ∧ levenshtein C xs' ys ≤ levenshtein C xs (y :: ys) := by
simpa [suffixLevenshtein_eq_tails_map, List.minimum_le_coe_iff] using suffixLevenshtein_minimum_le_levenshtein_cons (δ := δ) xs y ys
656
import Mathlib.Algebra.Order.Monoid.Canonical.Defs import Mathlib.Data.List.Infix import Mathlib.Data.List.MinMax import Mathlib.Data.List.EditDistance.Defs set_option autoImplicit true variable {C : Levenshtein.Cost α β δ} [CanonicallyLinearOrderedAddCommMonoid δ] theorem suffixLevenshtein_minimum_le_levenshtein_cons (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ levenshtein C xs (y :: ys) := by induction xs with | nil => simp only [suffixLevenshtein_nil', levenshtein_nil_cons, List.minimum_singleton, WithTop.coe_le_coe] exact le_add_of_nonneg_left (by simp) | cons x xs ih => suffices (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.delete x + levenshtein C xs (y :: ys)) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.insert y + levenshtein C (x :: xs) ys) ∧ (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (C.substitute x y + levenshtein C xs ys) by simpa [suffixLevenshtein_eq_tails_map] refine ⟨?_, ?_, ?_⟩ · calc _ ≤ (suffixLevenshtein C xs ys).1.minimum := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ ↑(levenshtein C xs (y :: ys)) := ih _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C (x :: xs) ys) := by simp [suffixLevenshtein_cons₁_fst, List.minimum_cons] _ ≤ _ := by simp · calc (suffixLevenshtein C (x :: xs) ys).1.minimum ≤ (levenshtein C xs ys) := by simp only [suffixLevenshtein_cons₁_fst, List.minimum_cons] apply min_le_of_right_le cases xs · simp [suffixLevenshtein_nil'] · simp [suffixLevenshtein_cons₁, List.minimum_cons] _ ≤ _ := by simp theorem le_suffixLevenshtein_cons_minimum (xs : List α) (y ys) : (suffixLevenshtein C xs ys).1.minimum ≤ (suffixLevenshtein C xs (y :: ys)).1.minimum := by apply List.le_minimum_of_forall_le simp only [suffixLevenshtein_eq_tails_map] simp only [List.mem_map, List.mem_tails, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] intro a suff refine (?_ : _ ≤ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _) simp only [suffixLevenshtein_eq_tails_map] apply List.le_minimum_of_forall_le intro b m replace m : ∃ a_1, a_1 <:+ a ∧ levenshtein C a_1 ys = b := by simpa using m obtain ⟨a', suff', rfl⟩ := m apply List.minimum_le_of_mem' simp only [List.mem_map, List.mem_tails] suffices ∃ a, a <:+ xs ∧ levenshtein C a ys = levenshtein C a' ys by simpa exact ⟨a', suff'.trans suff, rfl⟩ theorem le_suffixLevenshtein_append_minimum (xs : List α) (ys₁ ys₂) : (suffixLevenshtein C xs ys₂).1.minimum ≤ (suffixLevenshtein C xs (ys₁ ++ ys₂)).1.minimum := by induction ys₁ with | nil => exact le_refl _ | cons y ys₁ ih => exact ih.trans (le_suffixLevenshtein_cons_minimum _ _ _) theorem suffixLevenshtein_minimum_le_levenshtein_append (xs ys₁ ys₂) : (suffixLevenshtein C xs ys₂).1.minimum ≤ levenshtein C xs (ys₁ ++ ys₂) := by cases ys₁ with | nil => exact List.minimum_le_of_mem' (List.get_mem _ _ _) | cons y ys₁ => exact (le_suffixLevenshtein_append_minimum _ _ _).trans (suffixLevenshtein_minimum_le_levenshtein_cons _ _ _) theorem le_levenshtein_cons (xs : List α) (y ys) : ∃ xs', xs' <:+ xs ∧ levenshtein C xs' ys ≤ levenshtein C xs (y :: ys) := by simpa [suffixLevenshtein_eq_tails_map, List.minimum_le_coe_iff] using suffixLevenshtein_minimum_le_levenshtein_cons (δ := δ) xs y ys
Mathlib/Data/List/EditDistance/Bounds.lean
94
97
theorem le_levenshtein_append (xs : List α) (ys₁ ys₂) : ∃ xs', xs' <:+ xs ∧ levenshtein C xs' ys₂ ≤ levenshtein C xs (ys₁ ++ ys₂) := by
simpa [suffixLevenshtein_eq_tails_map, List.minimum_le_coe_iff] using suffixLevenshtein_minimum_le_levenshtein_append (δ := δ) xs ys₁ ys₂
656
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem
Mathlib/Data/List/Chain.lean
58
59
theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by
simp only [chain_cons, Chain.nil, and_true_iff]
657
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton
Mathlib/Data/List/Chain.lean
62
65
theorem chain_split {a b : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by
induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc]
657
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton theorem chain_split {a b : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc] #align list.chain_split List.chain_split @[simp]
Mathlib/Data/List/Chain.lean
69
71
theorem chain_append_cons_cons {a b c : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: c :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ R b c ∧ Chain R c l₂ := by
rw [chain_split, chain_cons]
657
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton theorem chain_split {a b : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc] #align list.chain_split List.chain_split @[simp] theorem chain_append_cons_cons {a b c : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: c :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ R b c ∧ Chain R c l₂ := by rw [chain_split, chain_cons] #align list.chain_append_cons_cons List.chain_append_cons_cons theorem chain_iff_forall₂ : ∀ {a : α} {l : List α}, Chain R a l ↔ l = [] ∨ Forall₂ R (a :: dropLast l) l | a, [] => by simp | a, b :: l => by by_cases h : l = [] <;> simp [@chain_iff_forall₂ b l, dropLast, *] #align list.chain_iff_forall₂ List.chain_iff_forall₂
Mathlib/Data/List/Chain.lean
82
83
theorem chain_append_singleton_iff_forall₂ : Chain R a (l ++ [b]) ↔ Forall₂ R (a :: l) (l ++ [b]) := by
simp [chain_iff_forall₂]
657
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton theorem chain_split {a b : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc] #align list.chain_split List.chain_split @[simp] theorem chain_append_cons_cons {a b c : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: c :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ R b c ∧ Chain R c l₂ := by rw [chain_split, chain_cons] #align list.chain_append_cons_cons List.chain_append_cons_cons theorem chain_iff_forall₂ : ∀ {a : α} {l : List α}, Chain R a l ↔ l = [] ∨ Forall₂ R (a :: dropLast l) l | a, [] => by simp | a, b :: l => by by_cases h : l = [] <;> simp [@chain_iff_forall₂ b l, dropLast, *] #align list.chain_iff_forall₂ List.chain_iff_forall₂ theorem chain_append_singleton_iff_forall₂ : Chain R a (l ++ [b]) ↔ Forall₂ R (a :: l) (l ++ [b]) := by simp [chain_iff_forall₂] #align list.chain_append_singleton_iff_forall₂ List.chain_append_singleton_iff_forall₂
Mathlib/Data/List/Chain.lean
86
88
theorem chain_map (f : β → α) {b : β} {l : List β} : Chain R (f b) (map f l) ↔ Chain (fun a b : β => R (f a) (f b)) b l := by
induction l generalizing b <;> simp only [map, Chain.nil, chain_cons, *]
657
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton theorem chain_split {a b : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc] #align list.chain_split List.chain_split @[simp] theorem chain_append_cons_cons {a b c : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: c :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ R b c ∧ Chain R c l₂ := by rw [chain_split, chain_cons] #align list.chain_append_cons_cons List.chain_append_cons_cons theorem chain_iff_forall₂ : ∀ {a : α} {l : List α}, Chain R a l ↔ l = [] ∨ Forall₂ R (a :: dropLast l) l | a, [] => by simp | a, b :: l => by by_cases h : l = [] <;> simp [@chain_iff_forall₂ b l, dropLast, *] #align list.chain_iff_forall₂ List.chain_iff_forall₂ theorem chain_append_singleton_iff_forall₂ : Chain R a (l ++ [b]) ↔ Forall₂ R (a :: l) (l ++ [b]) := by simp [chain_iff_forall₂] #align list.chain_append_singleton_iff_forall₂ List.chain_append_singleton_iff_forall₂ theorem chain_map (f : β → α) {b : β} {l : List β} : Chain R (f b) (map f l) ↔ Chain (fun a b : β => R (f a) (f b)) b l := by induction l generalizing b <;> simp only [map, Chain.nil, chain_cons, *] #align list.chain_map List.chain_map theorem chain_of_chain_map {S : β → β → Prop} (f : α → β) (H : ∀ a b : α, S (f a) (f b) → R a b) {a : α} {l : List α} (p : Chain S (f a) (map f l)) : Chain R a l := ((chain_map f).1 p).imp H #align list.chain_of_chain_map List.chain_of_chain_map theorem chain_map_of_chain {S : β → β → Prop} (f : α → β) (H : ∀ a b : α, R a b → S (f a) (f b)) {a : α} {l : List α} (p : Chain R a l) : Chain S (f a) (map f l) := (chain_map f).2 <| p.imp H #align list.chain_map_of_chain List.chain_map_of_chain
Mathlib/Data/List/Chain.lean
101
106
theorem chain_pmap_of_chain {S : β → β → Prop} {p : α → Prop} {f : ∀ a, p a → β} (H : ∀ a b ha hb, R a b → S (f a ha) (f b hb)) {a : α} {l : List α} (hl₁ : Chain R a l) (ha : p a) (hl₂ : ∀ a ∈ l, p a) : Chain S (f a ha) (List.pmap f l hl₂) := by
induction' l with lh lt l_ih generalizing a · simp · simp [H _ _ _ _ (rel_of_chain_cons hl₁), l_ih (chain_of_chain_cons hl₁)]
657
import Mathlib.Logic.Relation import Mathlib.Data.List.Forall2 import Mathlib.Data.List.Lex import Mathlib.Data.List.Infix #align_import data.list.chain from "leanprover-community/mathlib"@"dd71334db81d0bd444af1ee339a29298bef40734" -- Make sure we haven't imported `Data.Nat.Order.Basic` assert_not_exists OrderedSub universe u v open Nat namespace List variable {α : Type u} {β : Type v} {R r : α → α → Prop} {l l₁ l₂ : List α} {a b : α} mk_iff_of_inductive_prop List.Chain List.chain_iff #align list.chain_iff List.chain_iff #align list.chain.nil List.Chain.nil #align list.chain.cons List.Chain.cons #align list.rel_of_chain_cons List.rel_of_chain_cons #align list.chain_of_chain_cons List.chain_of_chain_cons #align list.chain.imp' List.Chain.imp' #align list.chain.imp List.Chain.imp theorem Chain.iff {S : α → α → Prop} (H : ∀ a b, R a b ↔ S a b) {a : α} {l : List α} : Chain R a l ↔ Chain S a l := ⟨Chain.imp fun a b => (H a b).1, Chain.imp fun a b => (H a b).2⟩ #align list.chain.iff List.Chain.iff theorem Chain.iff_mem {a : α} {l : List α} : Chain R a l ↔ Chain (fun x y => x ∈ a :: l ∧ y ∈ l ∧ R x y) a l := ⟨fun p => by induction' p with _ a b l r _ IH <;> constructor <;> [exact ⟨mem_cons_self _ _, mem_cons_self _ _, r⟩; exact IH.imp fun a b ⟨am, bm, h⟩ => ⟨mem_cons_of_mem _ am, mem_cons_of_mem _ bm, h⟩], Chain.imp fun a b h => h.2.2⟩ #align list.chain.iff_mem List.Chain.iff_mem theorem chain_singleton {a b : α} : Chain R a [b] ↔ R a b := by simp only [chain_cons, Chain.nil, and_true_iff] #align list.chain_singleton List.chain_singleton theorem chain_split {a b : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ Chain R b l₂ := by induction' l₁ with x l₁ IH generalizing a <;> simp only [*, nil_append, cons_append, Chain.nil, chain_cons, and_true_iff, and_assoc] #align list.chain_split List.chain_split @[simp] theorem chain_append_cons_cons {a b c : α} {l₁ l₂ : List α} : Chain R a (l₁ ++ b :: c :: l₂) ↔ Chain R a (l₁ ++ [b]) ∧ R b c ∧ Chain R c l₂ := by rw [chain_split, chain_cons] #align list.chain_append_cons_cons List.chain_append_cons_cons theorem chain_iff_forall₂ : ∀ {a : α} {l : List α}, Chain R a l ↔ l = [] ∨ Forall₂ R (a :: dropLast l) l | a, [] => by simp | a, b :: l => by by_cases h : l = [] <;> simp [@chain_iff_forall₂ b l, dropLast, *] #align list.chain_iff_forall₂ List.chain_iff_forall₂ theorem chain_append_singleton_iff_forall₂ : Chain R a (l ++ [b]) ↔ Forall₂ R (a :: l) (l ++ [b]) := by simp [chain_iff_forall₂] #align list.chain_append_singleton_iff_forall₂ List.chain_append_singleton_iff_forall₂ theorem chain_map (f : β → α) {b : β} {l : List β} : Chain R (f b) (map f l) ↔ Chain (fun a b : β => R (f a) (f b)) b l := by induction l generalizing b <;> simp only [map, Chain.nil, chain_cons, *] #align list.chain_map List.chain_map theorem chain_of_chain_map {S : β → β → Prop} (f : α → β) (H : ∀ a b : α, S (f a) (f b) → R a b) {a : α} {l : List α} (p : Chain S (f a) (map f l)) : Chain R a l := ((chain_map f).1 p).imp H #align list.chain_of_chain_map List.chain_of_chain_map theorem chain_map_of_chain {S : β → β → Prop} (f : α → β) (H : ∀ a b : α, R a b → S (f a) (f b)) {a : α} {l : List α} (p : Chain R a l) : Chain S (f a) (map f l) := (chain_map f).2 <| p.imp H #align list.chain_map_of_chain List.chain_map_of_chain theorem chain_pmap_of_chain {S : β → β → Prop} {p : α → Prop} {f : ∀ a, p a → β} (H : ∀ a b ha hb, R a b → S (f a ha) (f b hb)) {a : α} {l : List α} (hl₁ : Chain R a l) (ha : p a) (hl₂ : ∀ a ∈ l, p a) : Chain S (f a ha) (List.pmap f l hl₂) := by induction' l with lh lt l_ih generalizing a · simp · simp [H _ _ _ _ (rel_of_chain_cons hl₁), l_ih (chain_of_chain_cons hl₁)] #align list.chain_pmap_of_chain List.chain_pmap_of_chain
Mathlib/Data/List/Chain.lean
109
114
theorem chain_of_chain_pmap {S : β → β → Prop} {p : α → Prop} (f : ∀ a, p a → β) {l : List α} (hl₁ : ∀ a ∈ l, p a) {a : α} (ha : p a) (hl₂ : Chain S (f a ha) (List.pmap f l hl₁)) (H : ∀ a b ha hb, S (f a ha) (f b hb) → R a b) : Chain R a l := by
induction' l with lh lt l_ih generalizing a · simp · simp [H _ _ _ _ (rel_of_chain_cons hl₂), l_ih _ _ (chain_of_chain_cons hl₂)]
657
import Mathlib.Algebra.FreeMonoid.Basic import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.GroupTheory.Congruence.Basic import Mathlib.GroupTheory.FreeGroup.IsFreeGroup import Mathlib.Data.List.Chain import Mathlib.SetTheory.Cardinal.Basic import Mathlib.Data.Set.Pointwise.SMul #align_import group_theory.free_product from "leanprover-community/mathlib"@"9114ddffa023340c9ec86965e00cdd6fe26fcdf6" open Set variable {ι : Type*} (M : ι → Type*) [∀ i, Monoid (M i)] inductive Monoid.CoprodI.Rel : FreeMonoid (Σi, M i) → FreeMonoid (Σi, M i) → Prop | of_one (i : ι) : Monoid.CoprodI.Rel (FreeMonoid.of ⟨i, 1⟩) 1 | of_mul {i : ι} (x y : M i) : Monoid.CoprodI.Rel (FreeMonoid.of ⟨i, x⟩ * FreeMonoid.of ⟨i, y⟩) (FreeMonoid.of ⟨i, x * y⟩) #align free_product.rel Monoid.CoprodI.Rel def Monoid.CoprodI : Type _ := (conGen (Monoid.CoprodI.Rel M)).Quotient #align free_product Monoid.CoprodI -- Porting note: could not de derived instance : Monoid (Monoid.CoprodI M) := by delta Monoid.CoprodI; infer_instance instance : Inhabited (Monoid.CoprodI M) := ⟨1⟩ namespace Monoid.CoprodI @[ext] structure Word where toList : List (Σi, M i) ne_one : ∀ l ∈ toList, Sigma.snd l ≠ 1 chain_ne : toList.Chain' fun l l' => Sigma.fst l ≠ Sigma.fst l' #align free_product.word Monoid.CoprodI.Word variable {M} def of {i : ι} : M i →* CoprodI M where toFun x := Con.mk' _ (FreeMonoid.of <| Sigma.mk i x) map_one' := (Con.eq _).mpr (ConGen.Rel.of _ _ (CoprodI.Rel.of_one i)) map_mul' x y := Eq.symm <| (Con.eq _).mpr (ConGen.Rel.of _ _ (CoprodI.Rel.of_mul x y)) #align free_product.of Monoid.CoprodI.of theorem of_apply {i} (m : M i) : of m = Con.mk' _ (FreeMonoid.of <| Sigma.mk i m) := rfl #align free_product.of_apply Monoid.CoprodI.of_apply variable {N : Type*} [Monoid N] -- Porting note: higher `ext` priority @[ext 1100] theorem ext_hom (f g : CoprodI M →* N) (h : ∀ i, f.comp (of : M i →* _) = g.comp of) : f = g := (MonoidHom.cancel_right Con.mk'_surjective).mp <| FreeMonoid.hom_eq fun ⟨i, x⟩ => by -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [MonoidHom.comp_apply, MonoidHom.comp_apply, ← of_apply, ← MonoidHom.comp_apply, ← MonoidHom.comp_apply, h]; rfl #align free_product.ext_hom Monoid.CoprodI.ext_hom @[simps symm_apply] def lift : (∀ i, M i →* N) ≃ (CoprodI M →* N) where toFun fi := Con.lift _ (FreeMonoid.lift fun p : Σi, M i => fi p.fst p.snd) <| Con.conGen_le <| by simp_rw [Con.ker_rel] rintro _ _ (i | ⟨x, y⟩) · change FreeMonoid.lift _ (FreeMonoid.of _) = FreeMonoid.lift _ 1 simp only [MonoidHom.map_one, FreeMonoid.lift_eval_of] · change FreeMonoid.lift _ (FreeMonoid.of _ * FreeMonoid.of _) = FreeMonoid.lift _ (FreeMonoid.of _) simp only [MonoidHom.map_mul, FreeMonoid.lift_eval_of] invFun f i := f.comp of left_inv := by intro fi ext i x -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [MonoidHom.comp_apply, of_apply, Con.lift_mk', FreeMonoid.lift_eval_of] right_inv := by intro f ext i x rfl #align free_product.lift Monoid.CoprodI.lift @[simp] theorem lift_comp_of {N} [Monoid N] (fi : ∀ i, M i →* N) i : (lift fi).comp of = fi i := congr_fun (lift.symm_apply_apply fi) i @[simp] theorem lift_of {N} [Monoid N] (fi : ∀ i, M i →* N) {i} (m : M i) : lift fi (of m) = fi i m := DFunLike.congr_fun (lift_comp_of ..) m #align free_product.lift_of Monoid.CoprodI.lift_of @[simp] theorem lift_comp_of' {N} [Monoid N] (f : CoprodI M →* N) : lift (fun i ↦ f.comp (of (i := i))) = f := lift.apply_symm_apply f @[simp] theorem lift_of' : lift (fun i ↦ (of : M i →* CoprodI M)) = .id (CoprodI M) := lift_comp_of' (.id _) theorem of_leftInverse [DecidableEq ι] (i : ι) : Function.LeftInverse (lift <| Pi.mulSingle i (MonoidHom.id (M i))) of := fun x => by simp only [lift_of, Pi.mulSingle_eq_same, MonoidHom.id_apply] #align free_product.of_left_inverse Monoid.CoprodI.of_leftInverse
Mathlib/GroupTheory/CoprodI.lean
199
200
theorem of_injective (i : ι) : Function.Injective (of : M i →* _) := by
classical exact (of_leftInverse i).injective
658
import Mathlib.Algebra.FreeMonoid.Basic import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.GroupTheory.Congruence.Basic import Mathlib.GroupTheory.FreeGroup.IsFreeGroup import Mathlib.Data.List.Chain import Mathlib.SetTheory.Cardinal.Basic import Mathlib.Data.Set.Pointwise.SMul #align_import group_theory.free_product from "leanprover-community/mathlib"@"9114ddffa023340c9ec86965e00cdd6fe26fcdf6" open Set variable {ι : Type*} (M : ι → Type*) [∀ i, Monoid (M i)] inductive Monoid.CoprodI.Rel : FreeMonoid (Σi, M i) → FreeMonoid (Σi, M i) → Prop | of_one (i : ι) : Monoid.CoprodI.Rel (FreeMonoid.of ⟨i, 1⟩) 1 | of_mul {i : ι} (x y : M i) : Monoid.CoprodI.Rel (FreeMonoid.of ⟨i, x⟩ * FreeMonoid.of ⟨i, y⟩) (FreeMonoid.of ⟨i, x * y⟩) #align free_product.rel Monoid.CoprodI.Rel def Monoid.CoprodI : Type _ := (conGen (Monoid.CoprodI.Rel M)).Quotient #align free_product Monoid.CoprodI -- Porting note: could not de derived instance : Monoid (Monoid.CoprodI M) := by delta Monoid.CoprodI; infer_instance instance : Inhabited (Monoid.CoprodI M) := ⟨1⟩ namespace Monoid.CoprodI @[ext] structure Word where toList : List (Σi, M i) ne_one : ∀ l ∈ toList, Sigma.snd l ≠ 1 chain_ne : toList.Chain' fun l l' => Sigma.fst l ≠ Sigma.fst l' #align free_product.word Monoid.CoprodI.Word variable {M} def of {i : ι} : M i →* CoprodI M where toFun x := Con.mk' _ (FreeMonoid.of <| Sigma.mk i x) map_one' := (Con.eq _).mpr (ConGen.Rel.of _ _ (CoprodI.Rel.of_one i)) map_mul' x y := Eq.symm <| (Con.eq _).mpr (ConGen.Rel.of _ _ (CoprodI.Rel.of_mul x y)) #align free_product.of Monoid.CoprodI.of theorem of_apply {i} (m : M i) : of m = Con.mk' _ (FreeMonoid.of <| Sigma.mk i m) := rfl #align free_product.of_apply Monoid.CoprodI.of_apply variable {N : Type*} [Monoid N] -- Porting note: higher `ext` priority @[ext 1100] theorem ext_hom (f g : CoprodI M →* N) (h : ∀ i, f.comp (of : M i →* _) = g.comp of) : f = g := (MonoidHom.cancel_right Con.mk'_surjective).mp <| FreeMonoid.hom_eq fun ⟨i, x⟩ => by -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [MonoidHom.comp_apply, MonoidHom.comp_apply, ← of_apply, ← MonoidHom.comp_apply, ← MonoidHom.comp_apply, h]; rfl #align free_product.ext_hom Monoid.CoprodI.ext_hom @[simps symm_apply] def lift : (∀ i, M i →* N) ≃ (CoprodI M →* N) where toFun fi := Con.lift _ (FreeMonoid.lift fun p : Σi, M i => fi p.fst p.snd) <| Con.conGen_le <| by simp_rw [Con.ker_rel] rintro _ _ (i | ⟨x, y⟩) · change FreeMonoid.lift _ (FreeMonoid.of _) = FreeMonoid.lift _ 1 simp only [MonoidHom.map_one, FreeMonoid.lift_eval_of] · change FreeMonoid.lift _ (FreeMonoid.of _ * FreeMonoid.of _) = FreeMonoid.lift _ (FreeMonoid.of _) simp only [MonoidHom.map_mul, FreeMonoid.lift_eval_of] invFun f i := f.comp of left_inv := by intro fi ext i x -- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 erw [MonoidHom.comp_apply, of_apply, Con.lift_mk', FreeMonoid.lift_eval_of] right_inv := by intro f ext i x rfl #align free_product.lift Monoid.CoprodI.lift @[simp] theorem lift_comp_of {N} [Monoid N] (fi : ∀ i, M i →* N) i : (lift fi).comp of = fi i := congr_fun (lift.symm_apply_apply fi) i @[simp] theorem lift_of {N} [Monoid N] (fi : ∀ i, M i →* N) {i} (m : M i) : lift fi (of m) = fi i m := DFunLike.congr_fun (lift_comp_of ..) m #align free_product.lift_of Monoid.CoprodI.lift_of @[simp] theorem lift_comp_of' {N} [Monoid N] (f : CoprodI M →* N) : lift (fun i ↦ f.comp (of (i := i))) = f := lift.apply_symm_apply f @[simp] theorem lift_of' : lift (fun i ↦ (of : M i →* CoprodI M)) = .id (CoprodI M) := lift_comp_of' (.id _) theorem of_leftInverse [DecidableEq ι] (i : ι) : Function.LeftInverse (lift <| Pi.mulSingle i (MonoidHom.id (M i))) of := fun x => by simp only [lift_of, Pi.mulSingle_eq_same, MonoidHom.id_apply] #align free_product.of_left_inverse Monoid.CoprodI.of_leftInverse theorem of_injective (i : ι) : Function.Injective (of : M i →* _) := by classical exact (of_leftInverse i).injective #align free_product.of_injective Monoid.CoprodI.of_injective
Mathlib/GroupTheory/CoprodI.lean
203
207
theorem mrange_eq_iSup {N} [Monoid N] (f : ∀ i, M i →* N) : MonoidHom.mrange (lift f) = ⨆ i, MonoidHom.mrange (f i) := by
rw [lift, Equiv.coe_fn_mk, Con.lift_range, FreeMonoid.mrange_lift, range_sigma_eq_iUnion_range, Submonoid.closure_iUnion] simp only [MonoidHom.mclosure_range]
658
import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace List @[simp]
Mathlib/Data/Bool/Count.lean
24
29
theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by
-- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl
659
import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp]
Mathlib/Data/Bool/Count.lean
33
34
theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by
rw [add_comm, count_not_add_count]
659
import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp] theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by rw [add_comm, count_not_add_count] #align list.count_add_count_bnot List.count_add_count_not @[simp] theorem count_false_add_count_true (l : List Bool) : count false l + count true l = length l := count_not_add_count l true #align list.count_ff_add_count_tt List.count_false_add_count_true @[simp] theorem count_true_add_count_false (l : List Bool) : count true l + count false l = length l := count_not_add_count l false #align list.count_tt_add_count_ff List.count_true_add_count_false theorem Chain.count_not : ∀ {b : Bool} {l : List Bool}, Chain (· ≠ ·) b l → count (!b) l = count b l + length l % 2 | b, [], _h => rfl | b, x :: l, h => by obtain rfl : b = !x := Bool.eq_not_iff.2 (rel_of_chain_cons h) rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, Chain.count_not (chain_of_chain_cons h), length, add_assoc, Nat.mod_two_add_succ_mod_two] #align list.chain.count_bnot List.Chain.count_not namespace Chain' variable {l : List Bool}
Mathlib/Data/Bool/Count.lean
60
71
theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : count (!b) l = count b l := by
cases' l with x l · rfl rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2 suffices count (!x) (x :: l) = count x (x :: l) by -- Porting note: old proof is -- cases b <;> cases x <;> try exact this; cases b <;> cases x <;> revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;> (try exact this) <;> exact this.symm rw [count_cons_of_ne x.not_ne_self, hl.count_not, h2, count_cons_self]
659
import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp] theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by rw [add_comm, count_not_add_count] #align list.count_add_count_bnot List.count_add_count_not @[simp] theorem count_false_add_count_true (l : List Bool) : count false l + count true l = length l := count_not_add_count l true #align list.count_ff_add_count_tt List.count_false_add_count_true @[simp] theorem count_true_add_count_false (l : List Bool) : count true l + count false l = length l := count_not_add_count l false #align list.count_tt_add_count_ff List.count_true_add_count_false theorem Chain.count_not : ∀ {b : Bool} {l : List Bool}, Chain (· ≠ ·) b l → count (!b) l = count b l + length l % 2 | b, [], _h => rfl | b, x :: l, h => by obtain rfl : b = !x := Bool.eq_not_iff.2 (rel_of_chain_cons h) rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, Chain.count_not (chain_of_chain_cons h), length, add_assoc, Nat.mod_two_add_succ_mod_two] #align list.chain.count_bnot List.Chain.count_not namespace Chain' variable {l : List Bool} theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : count (!b) l = count b l := by cases' l with x l · rfl rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2 suffices count (!x) (x :: l) = count x (x :: l) by -- Porting note: old proof is -- cases b <;> cases x <;> try exact this; cases b <;> cases x <;> revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;> (try exact this) <;> exact this.symm rw [count_cons_of_ne x.not_ne_self, hl.count_not, h2, count_cons_self] #align list.chain'.count_bnot_eq_count List.Chain'.count_not_eq_count theorem count_false_eq_count_true (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) : count false l = count true l := hl.count_not_eq_count h2 true #align list.chain'.count_ff_eq_count_tt List.Chain'.count_false_eq_count_true
Mathlib/Data/Bool/Count.lean
79
87
theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) : count (!b) l ≤ count b l + 1 := by
cases' l with x l · exact zero_le _ obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em] · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc] exact add_le_add_left (Nat.mod_lt _ two_pos).le _ · rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, hl.count_not] exact add_le_add_right (le_add_right le_rfl) _
659
import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp] theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by rw [add_comm, count_not_add_count] #align list.count_add_count_bnot List.count_add_count_not @[simp] theorem count_false_add_count_true (l : List Bool) : count false l + count true l = length l := count_not_add_count l true #align list.count_ff_add_count_tt List.count_false_add_count_true @[simp] theorem count_true_add_count_false (l : List Bool) : count true l + count false l = length l := count_not_add_count l false #align list.count_tt_add_count_ff List.count_true_add_count_false theorem Chain.count_not : ∀ {b : Bool} {l : List Bool}, Chain (· ≠ ·) b l → count (!b) l = count b l + length l % 2 | b, [], _h => rfl | b, x :: l, h => by obtain rfl : b = !x := Bool.eq_not_iff.2 (rel_of_chain_cons h) rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, Chain.count_not (chain_of_chain_cons h), length, add_assoc, Nat.mod_two_add_succ_mod_two] #align list.chain.count_bnot List.Chain.count_not namespace Chain' variable {l : List Bool} theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : count (!b) l = count b l := by cases' l with x l · rfl rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2 suffices count (!x) (x :: l) = count x (x :: l) by -- Porting note: old proof is -- cases b <;> cases x <;> try exact this; cases b <;> cases x <;> revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;> (try exact this) <;> exact this.symm rw [count_cons_of_ne x.not_ne_self, hl.count_not, h2, count_cons_self] #align list.chain'.count_bnot_eq_count List.Chain'.count_not_eq_count theorem count_false_eq_count_true (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) : count false l = count true l := hl.count_not_eq_count h2 true #align list.chain'.count_ff_eq_count_tt List.Chain'.count_false_eq_count_true theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) : count (!b) l ≤ count b l + 1 := by cases' l with x l · exact zero_le _ obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em] · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc] exact add_le_add_left (Nat.mod_lt _ two_pos).le _ · rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, hl.count_not] exact add_le_add_right (le_add_right le_rfl) _ #align list.chain'.count_bnot_le_count_add_one List.Chain'.count_not_le_count_add_one theorem count_false_le_count_true_add_one (hl : Chain' (· ≠ ·) l) : count false l ≤ count true l + 1 := hl.count_not_le_count_add_one true #align list.chain'.count_ff_le_count_tt_add_one List.Chain'.count_false_le_count_true_add_one theorem count_true_le_count_false_add_one (hl : Chain' (· ≠ ·) l) : count true l ≤ count false l + 1 := hl.count_not_le_count_add_one false #align list.chain'.count_tt_le_count_ff_add_one List.Chain'.count_true_le_count_false_add_one
Mathlib/Data/Bool/Count.lean
100
102
theorem two_mul_count_bool_of_even (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : 2 * count b l = length l := by
rw [← count_not_add_count l b, hl.count_not_eq_count h2, two_mul]
659
import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp] theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by rw [add_comm, count_not_add_count] #align list.count_add_count_bnot List.count_add_count_not @[simp] theorem count_false_add_count_true (l : List Bool) : count false l + count true l = length l := count_not_add_count l true #align list.count_ff_add_count_tt List.count_false_add_count_true @[simp] theorem count_true_add_count_false (l : List Bool) : count true l + count false l = length l := count_not_add_count l false #align list.count_tt_add_count_ff List.count_true_add_count_false theorem Chain.count_not : ∀ {b : Bool} {l : List Bool}, Chain (· ≠ ·) b l → count (!b) l = count b l + length l % 2 | b, [], _h => rfl | b, x :: l, h => by obtain rfl : b = !x := Bool.eq_not_iff.2 (rel_of_chain_cons h) rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, Chain.count_not (chain_of_chain_cons h), length, add_assoc, Nat.mod_two_add_succ_mod_two] #align list.chain.count_bnot List.Chain.count_not namespace Chain' variable {l : List Bool} theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : count (!b) l = count b l := by cases' l with x l · rfl rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2 suffices count (!x) (x :: l) = count x (x :: l) by -- Porting note: old proof is -- cases b <;> cases x <;> try exact this; cases b <;> cases x <;> revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;> (try exact this) <;> exact this.symm rw [count_cons_of_ne x.not_ne_self, hl.count_not, h2, count_cons_self] #align list.chain'.count_bnot_eq_count List.Chain'.count_not_eq_count theorem count_false_eq_count_true (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) : count false l = count true l := hl.count_not_eq_count h2 true #align list.chain'.count_ff_eq_count_tt List.Chain'.count_false_eq_count_true theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) : count (!b) l ≤ count b l + 1 := by cases' l with x l · exact zero_le _ obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em] · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc] exact add_le_add_left (Nat.mod_lt _ two_pos).le _ · rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, hl.count_not] exact add_le_add_right (le_add_right le_rfl) _ #align list.chain'.count_bnot_le_count_add_one List.Chain'.count_not_le_count_add_one theorem count_false_le_count_true_add_one (hl : Chain' (· ≠ ·) l) : count false l ≤ count true l + 1 := hl.count_not_le_count_add_one true #align list.chain'.count_ff_le_count_tt_add_one List.Chain'.count_false_le_count_true_add_one theorem count_true_le_count_false_add_one (hl : Chain' (· ≠ ·) l) : count true l ≤ count false l + 1 := hl.count_not_le_count_add_one false #align list.chain'.count_tt_le_count_ff_add_one List.Chain'.count_true_le_count_false_add_one theorem two_mul_count_bool_of_even (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : 2 * count b l = length l := by rw [← count_not_add_count l b, hl.count_not_eq_count h2, two_mul] #align list.chain'.two_mul_count_bool_of_even List.Chain'.two_mul_count_bool_of_even
Mathlib/Data/Bool/Count.lean
105
117
theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) : 2 * count b l = if Even (length l) then length l else if Option.some b == l.head? then length l + 1 else length l - 1 := by
by_cases h2 : Even (length l) · rw [if_pos h2, hl.two_mul_count_bool_of_even h2] · cases' l with x l · exact (h2 even_zero).elim simp only [if_neg h2, count_cons, mul_add, head?, Option.mem_some_iff, @eq_comm _ x] rw [length_cons, Nat.even_add_one, not_not] at h2 replace hl : l.Chain' (· ≠ ·) := hl.tail rw [hl.two_mul_count_bool_of_even h2] cases b <;> cases x <;> split_ifs <;> simp <;> contradiction
659
import Mathlib.Algebra.Order.Ring.Nat import Mathlib.Data.List.Chain #align_import data.bool.count from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" namespace List @[simp] theorem count_not_add_count (l : List Bool) (b : Bool) : count (!b) l + count b l = length l := by -- Porting note: Proof re-written -- Old proof: simp only [length_eq_countP_add_countP (Eq (!b)), Bool.not_not_eq, count] simp only [length_eq_countP_add_countP (· == !b), count, add_right_inj] suffices (fun x => x == b) = (fun a => decide ¬(a == !b) = true) by rw [this] ext x; cases x <;> cases b <;> rfl #align list.count_bnot_add_count List.count_not_add_count @[simp] theorem count_add_count_not (l : List Bool) (b : Bool) : count b l + count (!b) l = length l := by rw [add_comm, count_not_add_count] #align list.count_add_count_bnot List.count_add_count_not @[simp] theorem count_false_add_count_true (l : List Bool) : count false l + count true l = length l := count_not_add_count l true #align list.count_ff_add_count_tt List.count_false_add_count_true @[simp] theorem count_true_add_count_false (l : List Bool) : count true l + count false l = length l := count_not_add_count l false #align list.count_tt_add_count_ff List.count_true_add_count_false theorem Chain.count_not : ∀ {b : Bool} {l : List Bool}, Chain (· ≠ ·) b l → count (!b) l = count b l + length l % 2 | b, [], _h => rfl | b, x :: l, h => by obtain rfl : b = !x := Bool.eq_not_iff.2 (rel_of_chain_cons h) rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, Chain.count_not (chain_of_chain_cons h), length, add_assoc, Nat.mod_two_add_succ_mod_two] #align list.chain.count_bnot List.Chain.count_not namespace Chain' variable {l : List Bool} theorem count_not_eq_count (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : count (!b) l = count b l := by cases' l with x l · rfl rw [length_cons, Nat.even_add_one, Nat.not_even_iff] at h2 suffices count (!x) (x :: l) = count x (x :: l) by -- Porting note: old proof is -- cases b <;> cases x <;> try exact this; cases b <;> cases x <;> revert this <;> simp only [Bool.not_false, Bool.not_true] <;> intro this <;> (try exact this) <;> exact this.symm rw [count_cons_of_ne x.not_ne_self, hl.count_not, h2, count_cons_self] #align list.chain'.count_bnot_eq_count List.Chain'.count_not_eq_count theorem count_false_eq_count_true (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) : count false l = count true l := hl.count_not_eq_count h2 true #align list.chain'.count_ff_eq_count_tt List.Chain'.count_false_eq_count_true theorem count_not_le_count_add_one (hl : Chain' (· ≠ ·) l) (b : Bool) : count (!b) l ≤ count b l + 1 := by cases' l with x l · exact zero_le _ obtain rfl | rfl : b = x ∨ b = !x := by simp only [Bool.eq_not_iff, em] · rw [count_cons_of_ne b.not_ne_self, count_cons_self, hl.count_not, add_assoc] exact add_le_add_left (Nat.mod_lt _ two_pos).le _ · rw [Bool.not_not, count_cons_self, count_cons_of_ne x.not_ne_self, hl.count_not] exact add_le_add_right (le_add_right le_rfl) _ #align list.chain'.count_bnot_le_count_add_one List.Chain'.count_not_le_count_add_one theorem count_false_le_count_true_add_one (hl : Chain' (· ≠ ·) l) : count false l ≤ count true l + 1 := hl.count_not_le_count_add_one true #align list.chain'.count_ff_le_count_tt_add_one List.Chain'.count_false_le_count_true_add_one theorem count_true_le_count_false_add_one (hl : Chain' (· ≠ ·) l) : count true l ≤ count false l + 1 := hl.count_not_le_count_add_one false #align list.chain'.count_tt_le_count_ff_add_one List.Chain'.count_true_le_count_false_add_one theorem two_mul_count_bool_of_even (hl : Chain' (· ≠ ·) l) (h2 : Even (length l)) (b : Bool) : 2 * count b l = length l := by rw [← count_not_add_count l b, hl.count_not_eq_count h2, two_mul] #align list.chain'.two_mul_count_bool_of_even List.Chain'.two_mul_count_bool_of_even theorem two_mul_count_bool_eq_ite (hl : Chain' (· ≠ ·) l) (b : Bool) : 2 * count b l = if Even (length l) then length l else if Option.some b == l.head? then length l + 1 else length l - 1 := by by_cases h2 : Even (length l) · rw [if_pos h2, hl.two_mul_count_bool_of_even h2] · cases' l with x l · exact (h2 even_zero).elim simp only [if_neg h2, count_cons, mul_add, head?, Option.mem_some_iff, @eq_comm _ x] rw [length_cons, Nat.even_add_one, not_not] at h2 replace hl : l.Chain' (· ≠ ·) := hl.tail rw [hl.two_mul_count_bool_of_even h2] cases b <;> cases x <;> split_ifs <;> simp <;> contradiction #align list.chain'.two_mul_count_bool_eq_ite List.Chain'.two_mul_count_bool_eq_ite
Mathlib/Data/Bool/Count.lean
120
123
theorem length_sub_one_le_two_mul_count_bool (hl : Chain' (· ≠ ·) l) (b : Bool) : length l - 1 ≤ 2 * count b l := by
rw [hl.two_mul_count_bool_eq_ite] split_ifs <;> simp [le_tsub_add, Nat.le_succ_of_le]
659
import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp]
Mathlib/Data/List/Destutter.lean
48
49
theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by
rw [destutter', if_pos h]
660
import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp] theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by rw [destutter', if_pos h] #align list.destutter'_cons_pos List.destutter'_cons_pos @[simp]
Mathlib/Data/List/Destutter.lean
53
54
theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by
rw [destutter', if_neg h]
660
import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp] theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by rw [destutter', if_pos h] #align list.destutter'_cons_pos List.destutter'_cons_pos @[simp] theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by rw [destutter', if_neg h] #align list.destutter'_cons_neg List.destutter'_cons_neg variable (R) @[simp]
Mathlib/Data/List/Destutter.lean
60
61
theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by
split_ifs with h <;> simp! [h]
660
import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp] theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by rw [destutter', if_pos h] #align list.destutter'_cons_pos List.destutter'_cons_pos @[simp] theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by rw [destutter', if_neg h] #align list.destutter'_cons_neg List.destutter'_cons_neg variable (R) @[simp] theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by split_ifs with h <;> simp! [h] #align list.destutter'_singleton List.destutter'_singleton
Mathlib/Data/List/Destutter.lean
64
70
theorem destutter'_sublist (a) : l.destutter' R a <+ a :: l := by
induction' l with b l hl generalizing a · simp rw [destutter'] split_ifs · exact Sublist.cons₂ a (hl b) · exact (hl a).trans ((l.sublist_cons b).cons_cons a)
660
import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp] theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by rw [destutter', if_pos h] #align list.destutter'_cons_pos List.destutter'_cons_pos @[simp] theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by rw [destutter', if_neg h] #align list.destutter'_cons_neg List.destutter'_cons_neg variable (R) @[simp] theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by split_ifs with h <;> simp! [h] #align list.destutter'_singleton List.destutter'_singleton theorem destutter'_sublist (a) : l.destutter' R a <+ a :: l := by induction' l with b l hl generalizing a · simp rw [destutter'] split_ifs · exact Sublist.cons₂ a (hl b) · exact (hl a).trans ((l.sublist_cons b).cons_cons a) #align list.destutter'_sublist List.destutter'_sublist
Mathlib/Data/List/Destutter.lean
73
79
theorem mem_destutter' (a) : a ∈ l.destutter' R a := by
induction' l with b l hl · simp rw [destutter'] split_ifs · simp · assumption
660
import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp] theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by rw [destutter', if_pos h] #align list.destutter'_cons_pos List.destutter'_cons_pos @[simp] theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by rw [destutter', if_neg h] #align list.destutter'_cons_neg List.destutter'_cons_neg variable (R) @[simp] theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by split_ifs with h <;> simp! [h] #align list.destutter'_singleton List.destutter'_singleton theorem destutter'_sublist (a) : l.destutter' R a <+ a :: l := by induction' l with b l hl generalizing a · simp rw [destutter'] split_ifs · exact Sublist.cons₂ a (hl b) · exact (hl a).trans ((l.sublist_cons b).cons_cons a) #align list.destutter'_sublist List.destutter'_sublist theorem mem_destutter' (a) : a ∈ l.destutter' R a := by induction' l with b l hl · simp rw [destutter'] split_ifs · simp · assumption #align list.mem_destutter' List.mem_destutter' theorem destutter'_is_chain : ∀ l : List α, ∀ {a b}, R a b → (l.destutter' R b).Chain R a | [], a, b, h => chain_singleton.mpr h | c :: l, a, b, h => by rw [destutter'] split_ifs with hbc · rw [chain_cons] exact ⟨h, destutter'_is_chain l hbc⟩ · exact destutter'_is_chain l h #align list.destutter'_is_chain List.destutter'_is_chain
Mathlib/Data/List/Destutter.lean
92
98
theorem destutter'_is_chain' (a) : (l.destutter' R a).Chain' R := by
induction' l with b l hl generalizing a · simp rw [destutter'] split_ifs with h · exact destutter'_is_chain R l h · exact hl a
660
import Mathlib.Data.List.Chain #align_import data.list.destutter from "leanprover-community/mathlib"@"7b78d1776212a91ecc94cf601f83bdcc46b04213" variable {α : Type*} (l : List α) (R : α → α → Prop) [DecidableRel R] {a b : α} namespace List @[simp] theorem destutter'_nil : destutter' R a [] = [a] := rfl #align list.destutter'_nil List.destutter'_nil theorem destutter'_cons : (b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l := rfl #align list.destutter'_cons List.destutter'_cons variable {R} @[simp] theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by rw [destutter', if_pos h] #align list.destutter'_cons_pos List.destutter'_cons_pos @[simp] theorem destutter'_cons_neg (h : ¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by rw [destutter', if_neg h] #align list.destutter'_cons_neg List.destutter'_cons_neg variable (R) @[simp] theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by split_ifs with h <;> simp! [h] #align list.destutter'_singleton List.destutter'_singleton theorem destutter'_sublist (a) : l.destutter' R a <+ a :: l := by induction' l with b l hl generalizing a · simp rw [destutter'] split_ifs · exact Sublist.cons₂ a (hl b) · exact (hl a).trans ((l.sublist_cons b).cons_cons a) #align list.destutter'_sublist List.destutter'_sublist theorem mem_destutter' (a) : a ∈ l.destutter' R a := by induction' l with b l hl · simp rw [destutter'] split_ifs · simp · assumption #align list.mem_destutter' List.mem_destutter' theorem destutter'_is_chain : ∀ l : List α, ∀ {a b}, R a b → (l.destutter' R b).Chain R a | [], a, b, h => chain_singleton.mpr h | c :: l, a, b, h => by rw [destutter'] split_ifs with hbc · rw [chain_cons] exact ⟨h, destutter'_is_chain l hbc⟩ · exact destutter'_is_chain l h #align list.destutter'_is_chain List.destutter'_is_chain theorem destutter'_is_chain' (a) : (l.destutter' R a).Chain' R := by induction' l with b l hl generalizing a · simp rw [destutter'] split_ifs with h · exact destutter'_is_chain R l h · exact hl a #align list.destutter'_is_chain' List.destutter'_is_chain'
Mathlib/Data/List/Destutter.lean
101
105
theorem destutter'_of_chain (h : l.Chain R a) : l.destutter' R a = a :: l := by
induction' l with b l hb generalizing a · simp obtain ⟨h, hc⟩ := chain_cons.mp h rw [l.destutter'_cons_pos h, hb hc]
660
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp]
Mathlib/Data/List/DropRight.lean
47
47
theorem rdrop_nil : rdrop ([] : List α) n = [] := by
simp [rdrop]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp]
Mathlib/Data/List/DropRight.lean
51
51
theorem rdrop_zero : rdrop l 0 = l := by
simp [rdrop]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero
Mathlib/Data/List/DropRight.lean
54
60
theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by
rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp]
Mathlib/Data/List/DropRight.lean
64
65
theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
simp [rdrop_eq_reverse_drop_reverse]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp]
Mathlib/Data/List/DropRight.lean
74
74
theorem rtake_nil : rtake ([] : List α) n = [] := by
simp [rtake]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp]
Mathlib/Data/List/DropRight.lean
78
78
theorem rtake_zero : rtake l 0 = [] := by
simp [rtake]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero
Mathlib/Data/List/DropRight.lean
81
87
theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by
rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp]
Mathlib/Data/List/DropRight.lean
91
92
theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
simp [rtake_eq_reverse_take_reverse]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp]
Mathlib/Data/List/DropRight.lean
102
102
theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by
simp [rdropWhile, dropWhile]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil
Mathlib/Data/List/DropRight.lean
105
108
theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by
simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp]
Mathlib/Data/List/DropRight.lean
112
113
theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by
rw [rdropWhile_concat, if_pos h]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp]
Mathlib/Data/List/DropRight.lean
117
118
theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by
rw [rdropWhile_concat, if_neg h]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg
Mathlib/Data/List/DropRight.lean
121
122
theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by
rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil] #align list.rdrop_while_singleton List.rdropWhile_singleton
Mathlib/Data/List/DropRight.lean
125
128
theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by
simp_rw [rdropWhile] rw [getLast_reverse] exact dropWhile_nthLe_zero_not _ _ _
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil] #align list.rdrop_while_singleton List.rdropWhile_singleton theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by simp_rw [rdropWhile] rw [getLast_reverse] exact dropWhile_nthLe_zero_not _ _ _ #align list.rdrop_while_last_not List.rdropWhile_last_not
Mathlib/Data/List/DropRight.lean
131
133
theorem rdropWhile_prefix : l.rdropWhile p <+: l := by
rw [← reverse_suffix, rdropWhile, reverse_reverse] exact dropWhile_suffix _
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil] #align list.rdrop_while_singleton List.rdropWhile_singleton theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by simp_rw [rdropWhile] rw [getLast_reverse] exact dropWhile_nthLe_zero_not _ _ _ #align list.rdrop_while_last_not List.rdropWhile_last_not theorem rdropWhile_prefix : l.rdropWhile p <+: l := by rw [← reverse_suffix, rdropWhile, reverse_reverse] exact dropWhile_suffix _ #align list.rdrop_while_prefix List.rdropWhile_prefix variable {p} {l} @[simp]
Mathlib/Data/List/DropRight.lean
139
139
theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by
simp [rdropWhile]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil] #align list.rdrop_while_singleton List.rdropWhile_singleton theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by simp_rw [rdropWhile] rw [getLast_reverse] exact dropWhile_nthLe_zero_not _ _ _ #align list.rdrop_while_last_not List.rdropWhile_last_not theorem rdropWhile_prefix : l.rdropWhile p <+: l := by rw [← reverse_suffix, rdropWhile, reverse_reverse] exact dropWhile_suffix _ #align list.rdrop_while_prefix List.rdropWhile_prefix variable {p} {l} @[simp] theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdropWhile] #align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff -- it is in this file because it requires `List.Infix` @[simp]
Mathlib/Data/List/DropRight.lean
144
160
theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.get ⟨0, hl⟩) := by
cases' l with hd tl · simp only [dropWhile, true_iff] intro h by_contra rwa [length_nil, lt_self_iff_false] at h · rw [dropWhile] refine ⟨fun h => ?_, fun h => ?_⟩ · intro _ H rw [get] at H refine (cons_ne_self hd tl) (Sublist.antisymm ?_ (sublist_cons _ _)) rw [← h] simp only [H] exact List.IsSuffix.sublist (dropWhile_suffix p) · have := h (by simp only [length, Nat.succ_pos]) rw [get] at this simp_rw [this]
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil] #align list.rdrop_while_singleton List.rdropWhile_singleton theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by simp_rw [rdropWhile] rw [getLast_reverse] exact dropWhile_nthLe_zero_not _ _ _ #align list.rdrop_while_last_not List.rdropWhile_last_not theorem rdropWhile_prefix : l.rdropWhile p <+: l := by rw [← reverse_suffix, rdropWhile, reverse_reverse] exact dropWhile_suffix _ #align list.rdrop_while_prefix List.rdropWhile_prefix variable {p} {l} @[simp] theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdropWhile] #align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff -- it is in this file because it requires `List.Infix` @[simp] theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.get ⟨0, hl⟩) := by cases' l with hd tl · simp only [dropWhile, true_iff] intro h by_contra rwa [length_nil, lt_self_iff_false] at h · rw [dropWhile] refine ⟨fun h => ?_, fun h => ?_⟩ · intro _ H rw [get] at H refine (cons_ne_self hd tl) (Sublist.antisymm ?_ (sublist_cons _ _)) rw [← h] simp only [H] exact List.IsSuffix.sublist (dropWhile_suffix p) · have := h (by simp only [length, Nat.succ_pos]) rw [get] at this simp_rw [this] #align list.drop_while_eq_self_iff List.dropWhile_eq_self_iff @[simp]
Mathlib/Data/List/DropRight.lean
166
174
theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by
simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get] refine ⟨fun h hl => ?_, fun h hl => ?_⟩ · rw [← length_pos, ← length_reverse] at hl have := h hl rwa [get_reverse'] at this · rw [length_reverse, length_pos] at hl have := h hl rwa [get_reverse']
661
import Mathlib.Data.List.Infix #align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" -- Make sure we don't import algebra assert_not_exists Monoid variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ) namespace List def rdrop : List α := l.take (l.length - n) #align list.rdrop List.rdrop @[simp] theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop] #align list.rdrop_nil List.rdrop_nil @[simp] theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop] #align list.rdrop_zero List.rdrop_zero theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by rw [rdrop] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · simp [take_append] · simp [take_append_eq_append_take, IH] #align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse @[simp] theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by simp [rdrop_eq_reverse_drop_reverse] #align list.rdrop_concat_succ List.rdrop_concat_succ def rtake : List α := l.drop (l.length - n) #align list.rtake List.rtake @[simp] theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake] #align list.rtake_nil List.rtake_nil @[simp] theorem rtake_zero : rtake l 0 = [] := by simp [rtake] #align list.rtake_zero List.rtake_zero theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by rw [rtake] induction' l using List.reverseRecOn with xs x IH generalizing n · simp · cases n · exact drop_length _ · simp [drop_append_eq_append_drop, IH] #align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse @[simp] theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by simp [rtake_eq_reverse_take_reverse] #align list.rtake_concat_succ List.rtake_concat_succ def rdropWhile : List α := reverse (l.reverse.dropWhile p) #align list.rdrop_while List.rdropWhile @[simp] theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile] #align list.rdrop_while_nil List.rdropWhile_nil theorem rdropWhile_concat (x : α) : rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append] split_ifs with h <;> simp [h] #align list.rdrop_while_concat List.rdropWhile_concat @[simp] theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by rw [rdropWhile_concat, if_pos h] #align list.rdrop_while_concat_pos List.rdropWhile_concat_pos @[simp] theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by rw [rdropWhile_concat, if_neg h] #align list.rdrop_while_concat_neg List.rdropWhile_concat_neg theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil] #align list.rdrop_while_singleton List.rdropWhile_singleton theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by simp_rw [rdropWhile] rw [getLast_reverse] exact dropWhile_nthLe_zero_not _ _ _ #align list.rdrop_while_last_not List.rdropWhile_last_not theorem rdropWhile_prefix : l.rdropWhile p <+: l := by rw [← reverse_suffix, rdropWhile, reverse_reverse] exact dropWhile_suffix _ #align list.rdrop_while_prefix List.rdropWhile_prefix variable {p} {l} @[simp] theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdropWhile] #align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff -- it is in this file because it requires `List.Infix` @[simp] theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.get ⟨0, hl⟩) := by cases' l with hd tl · simp only [dropWhile, true_iff] intro h by_contra rwa [length_nil, lt_self_iff_false] at h · rw [dropWhile] refine ⟨fun h => ?_, fun h => ?_⟩ · intro _ H rw [get] at H refine (cons_ne_self hd tl) (Sublist.antisymm ?_ (sublist_cons _ _)) rw [← h] simp only [H] exact List.IsSuffix.sublist (dropWhile_suffix p) · have := h (by simp only [length, Nat.succ_pos]) rw [get] at this simp_rw [this] #align list.drop_while_eq_self_iff List.dropWhile_eq_self_iff @[simp] theorem rdropWhile_eq_self_iff : rdropWhile p l = l ↔ ∀ hl : l ≠ [], ¬p (l.getLast hl) := by simp only [rdropWhile, reverse_eq_iff, dropWhile_eq_self_iff, getLast_eq_get] refine ⟨fun h hl => ?_, fun h hl => ?_⟩ · rw [← length_pos, ← length_reverse] at hl have := h hl rwa [get_reverse'] at this · rw [length_reverse, length_pos] at hl have := h hl rwa [get_reverse'] #align list.rdrop_while_eq_self_iff List.rdropWhile_eq_self_iff variable (p) (l)
Mathlib/Data/List/DropRight.lean
179
181
theorem dropWhile_idempotent : dropWhile p (dropWhile p l) = dropWhile p l := by
simp only [dropWhile_eq_self_iff] exact fun h => dropWhile_nthLe_zero_not p l h
661
import Mathlib.CategoryTheory.Galois.Basic import Mathlib.CategoryTheory.Limits.FintypeCat import Mathlib.CategoryTheory.Limits.Preserves.Limits import Mathlib.CategoryTheory.Limits.Shapes.SingleObj import Mathlib.Logic.Equiv.TransferInstance universe u₁ u₂ v₁ v₂ v w namespace CategoryTheory namespace PreGaloisCategory open Limits Functor noncomputable instance {G : Type v} [Group G] [Finite G] : PreservesColimitsOfShape (SingleObj G) FintypeCat.incl.{w} := by choose G' hg hf e using Finite.exists_type_zero_nonempty_mulEquiv G exact Limits.preservesColimitsOfShapeOfEquiv (Classical.choice e).toSingleObjEquiv.symm _ class IsGalois {C : Type u₁} [Category.{u₂, u₁} C] [GaloisCategory C] (X : C) extends IsConnected X : Prop where quotientByAutTerminal : Nonempty (IsTerminal <| colimit <| SingleObj.functor <| Aut.toEnd X) variable {C : Type u₁} [Category.{u₂, u₁} C] instance autMulFiber (F : C ⥤ FintypeCat.{w}) (X : C) : MulAction (Aut X) (F.obj X) where smul σ a := F.map σ.hom a one_smul a := by show F.map (𝟙 X) a = a simp only [map_id, FintypeCat.id_apply] mul_smul g h a := by show F.map (h.hom ≫ g.hom) a = (F.map h.hom ≫ F.map g.hom) a simp only [map_comp, FintypeCat.comp_apply] variable [GaloisCategory C] (F : C ⥤ FintypeCat.{w}) [FiberFunctor F] noncomputable def quotientByAutTerminalEquivUniqueQuotient (X : C) [IsConnected X] : IsTerminal (colimit <| SingleObj.functor <| Aut.toEnd X) ≃ Unique (MulAction.orbitRel.Quotient (Aut X) (F.obj X)) := by let J : SingleObj (Aut X) ⥤ C := SingleObj.functor (Aut.toEnd X) let e : (F ⋙ FintypeCat.incl).obj (colimit J) ≅ _ := preservesColimitIso (F ⋙ FintypeCat.incl) J ≪≫ (Equiv.toIso <| SingleObj.Types.colimitEquivQuotient (J ⋙ F ⋙ FintypeCat.incl)) apply Equiv.trans · apply (IsTerminal.isTerminalIffObj (F ⋙ FintypeCat.incl) _).trans (isLimitEmptyConeEquiv _ (asEmptyCone _) (asEmptyCone _) e) exact Types.isTerminalEquivUnique _ lemma isGalois_iff_aux (X : C) [IsConnected X] : IsGalois X ↔ Nonempty (IsTerminal <| colimit <| SingleObj.functor <| Aut.toEnd X) := ⟨fun h ↦ h.quotientByAutTerminal, fun h ↦ ⟨h⟩⟩
Mathlib/CategoryTheory/Galois/GaloisObjects.lean
81
84
theorem isGalois_iff_pretransitive (X : C) [IsConnected X] : IsGalois X ↔ MulAction.IsPretransitive (Aut X) (F.obj X) := by
rw [isGalois_iff_aux, Equiv.nonempty_congr <| quotientByAutTerminalEquivUniqueQuotient F X] exact (MulAction.pretransitive_iff_unique_quotient_of_nonempty (Aut X) (F.obj X)).symm
662
import Mathlib.CategoryTheory.Galois.GaloisObjects import Mathlib.CategoryTheory.Limits.Shapes.CombinedProducts universe u₁ u₂ w namespace CategoryTheory open Limits Functor variable {C : Type u₁} [Category.{u₂} C] namespace PreGaloisCategory variable [GaloisCategory C] section Decomposition private lemma has_decomp_connected_components_aux_conn (X : C) [IsConnected X] : ∃ (ι : Type) (f : ι → C) (g : (i : ι) → (f i) ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by refine ⟨Unit, fun _ ↦ X, fun _ ↦ 𝟙 X, mkCofanColimit _ (fun s ↦ s.inj ()), ?_⟩ exact ⟨fun _ ↦ inferInstance, inferInstance⟩ private lemma has_decomp_connected_components_aux_initial (X : C) (h : IsInitial X) : ∃ (ι : Type) (f : ι → C) (g : (i : ι) → (f i) ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by refine ⟨Empty, fun _ ↦ X, fun _ ↦ 𝟙 X, ?_⟩ use mkCofanColimit _ (fun s ↦ IsInitial.to h s.pt) (fun s ↦ by aesop) (fun s m _ ↦ IsInitial.hom_ext h m _) exact ⟨by simp only [IsEmpty.forall_iff], inferInstance⟩ private lemma has_decomp_connected_components_aux (F : C ⥤ FintypeCat.{w}) [FiberFunctor F] (n : ℕ) : ∀ (X : C), n = Nat.card (F.obj X) → ∃ (ι : Type) (f : ι → C) (g : (i : ι) → (f i) ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by induction' n using Nat.strongRecOn with n hi intro X hn by_cases h : IsConnected X · exact has_decomp_connected_components_aux_conn X by_cases nhi : IsInitial X → False · obtain ⟨Y, v, hni, hvmono, hvnoiso⟩ := has_non_trivial_subobject_of_not_isConnected_of_not_initial X h nhi obtain ⟨Z, u, ⟨c⟩⟩ := PreGaloisCategory.monoInducesIsoOnDirectSummand v let t : ColimitCocone (pair Y Z) := { cocone := BinaryCofan.mk v u, isColimit := c } have hn1 : Nat.card (F.obj Y) < n := by rw [hn] exact lt_card_fiber_of_mono_of_notIso F v hvnoiso have i : X ≅ Y ⨿ Z := (colimit.isoColimitCocone t).symm have hnn : Nat.card (F.obj X) = Nat.card (F.obj Y) + Nat.card (F.obj Z) := by rw [card_fiber_eq_of_iso F i] exact card_fiber_coprod_eq_sum F Y Z have hn2 : Nat.card (F.obj Z) < n := by rw [hn, hnn, lt_add_iff_pos_left] exact Nat.pos_of_ne_zero (non_zero_card_fiber_of_not_initial F Y hni) let ⟨ι₁, f₁, g₁, hc₁, hf₁, he₁⟩ := hi (Nat.card (F.obj Y)) hn1 Y rfl let ⟨ι₂, f₂, g₂, hc₂, hf₂, he₂⟩ := hi (Nat.card (F.obj Z)) hn2 Z rfl refine ⟨ι₁ ⊕ ι₂, Sum.elim f₁ f₂, Cofan.combPairHoms (Cofan.mk Y g₁) (Cofan.mk Z g₂) (BinaryCofan.mk v u), ?_⟩ use Cofan.combPairIsColimit hc₁ hc₂ c refine ⟨fun i ↦ ?_, inferInstance⟩ cases i · exact hf₁ _ · exact hf₂ _ · simp only [not_forall, not_false_eq_true] at nhi obtain ⟨hi⟩ := nhi exact has_decomp_connected_components_aux_initial X hi
Mathlib/CategoryTheory/Galois/Decomposition.lean
111
115
theorem has_decomp_connected_components (X : C) : ∃ (ι : Type) (f : ι → C) (g : (i : ι) → f i ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by
let F := GaloisCategory.getFiberFunctor C exact has_decomp_connected_components_aux F (Nat.card <| F.obj X) X rfl
663
import Mathlib.CategoryTheory.Galois.GaloisObjects import Mathlib.CategoryTheory.Limits.Shapes.CombinedProducts universe u₁ u₂ w namespace CategoryTheory open Limits Functor variable {C : Type u₁} [Category.{u₂} C] namespace PreGaloisCategory variable [GaloisCategory C] section Decomposition private lemma has_decomp_connected_components_aux_conn (X : C) [IsConnected X] : ∃ (ι : Type) (f : ι → C) (g : (i : ι) → (f i) ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by refine ⟨Unit, fun _ ↦ X, fun _ ↦ 𝟙 X, mkCofanColimit _ (fun s ↦ s.inj ()), ?_⟩ exact ⟨fun _ ↦ inferInstance, inferInstance⟩ private lemma has_decomp_connected_components_aux_initial (X : C) (h : IsInitial X) : ∃ (ι : Type) (f : ι → C) (g : (i : ι) → (f i) ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by refine ⟨Empty, fun _ ↦ X, fun _ ↦ 𝟙 X, ?_⟩ use mkCofanColimit _ (fun s ↦ IsInitial.to h s.pt) (fun s ↦ by aesop) (fun s m _ ↦ IsInitial.hom_ext h m _) exact ⟨by simp only [IsEmpty.forall_iff], inferInstance⟩ private lemma has_decomp_connected_components_aux (F : C ⥤ FintypeCat.{w}) [FiberFunctor F] (n : ℕ) : ∀ (X : C), n = Nat.card (F.obj X) → ∃ (ι : Type) (f : ι → C) (g : (i : ι) → (f i) ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by induction' n using Nat.strongRecOn with n hi intro X hn by_cases h : IsConnected X · exact has_decomp_connected_components_aux_conn X by_cases nhi : IsInitial X → False · obtain ⟨Y, v, hni, hvmono, hvnoiso⟩ := has_non_trivial_subobject_of_not_isConnected_of_not_initial X h nhi obtain ⟨Z, u, ⟨c⟩⟩ := PreGaloisCategory.monoInducesIsoOnDirectSummand v let t : ColimitCocone (pair Y Z) := { cocone := BinaryCofan.mk v u, isColimit := c } have hn1 : Nat.card (F.obj Y) < n := by rw [hn] exact lt_card_fiber_of_mono_of_notIso F v hvnoiso have i : X ≅ Y ⨿ Z := (colimit.isoColimitCocone t).symm have hnn : Nat.card (F.obj X) = Nat.card (F.obj Y) + Nat.card (F.obj Z) := by rw [card_fiber_eq_of_iso F i] exact card_fiber_coprod_eq_sum F Y Z have hn2 : Nat.card (F.obj Z) < n := by rw [hn, hnn, lt_add_iff_pos_left] exact Nat.pos_of_ne_zero (non_zero_card_fiber_of_not_initial F Y hni) let ⟨ι₁, f₁, g₁, hc₁, hf₁, he₁⟩ := hi (Nat.card (F.obj Y)) hn1 Y rfl let ⟨ι₂, f₂, g₂, hc₂, hf₂, he₂⟩ := hi (Nat.card (F.obj Z)) hn2 Z rfl refine ⟨ι₁ ⊕ ι₂, Sum.elim f₁ f₂, Cofan.combPairHoms (Cofan.mk Y g₁) (Cofan.mk Z g₂) (BinaryCofan.mk v u), ?_⟩ use Cofan.combPairIsColimit hc₁ hc₂ c refine ⟨fun i ↦ ?_, inferInstance⟩ cases i · exact hf₁ _ · exact hf₂ _ · simp only [not_forall, not_false_eq_true] at nhi obtain ⟨hi⟩ := nhi exact has_decomp_connected_components_aux_initial X hi theorem has_decomp_connected_components (X : C) : ∃ (ι : Type) (f : ι → C) (g : (i : ι) → f i ⟶ X) (_ : IsColimit (Cofan.mk X g)), (∀ i, IsConnected (f i)) ∧ Finite ι := by let F := GaloisCategory.getFiberFunctor C exact has_decomp_connected_components_aux F (Nat.card <| F.obj X) X rfl
Mathlib/CategoryTheory/Galois/Decomposition.lean
118
121
theorem has_decomp_connected_components' (X : C) : ∃ (ι : Type) (_ : Finite ι) (f : ι → C) (_ : ∐ f ≅ X), ∀ i, IsConnected (f i) := by
obtain ⟨ι, f, g, hl, hc, hf⟩ := has_decomp_connected_components X exact ⟨ι, hf, f, colimit.isoColimitCocone ⟨Cofan.mk X g, hl⟩, hc⟩
663
import Mathlib.CategoryTheory.Abelian.Basic import Mathlib.CategoryTheory.Preadditive.FunctorCategory import Mathlib.CategoryTheory.Limits.Shapes.FunctorCategory import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Kernels #align_import category_theory.abelian.functor_category from "leanprover-community/mathlib"@"8abfb3ba5e211d8376b855dab5d67f9eba9e0774" noncomputable section namespace CategoryTheory open CategoryTheory.Limits namespace Abelian section universe z w v u -- Porting note: removed restrictions on universes variable {C : Type u} [Category.{v} C] variable {D : Type w} [Category.{z} D] [Abelian D] namespace FunctorCategory variable {F G : C ⥤ D} (α : F ⟶ G) (X : C) @[simps!] def coimageObjIso : (Abelian.coimage α).obj X ≅ Abelian.coimage (α.app X) := PreservesCokernel.iso ((evaluation C D).obj X) _ ≪≫ cokernel.mapIso _ _ (PreservesKernel.iso ((evaluation C D).obj X) _) (Iso.refl _) (by dsimp simp only [Category.comp_id, PreservesKernel.iso_hom] exact (kernelComparison_comp_ι _ ((evaluation C D).obj X)).symm) #align category_theory.abelian.functor_category.coimage_obj_iso CategoryTheory.Abelian.FunctorCategory.coimageObjIso @[simps!] def imageObjIso : (Abelian.image α).obj X ≅ Abelian.image (α.app X) := PreservesKernel.iso ((evaluation C D).obj X) _ ≪≫ kernel.mapIso _ _ (Iso.refl _) (PreservesCokernel.iso ((evaluation C D).obj X) _) (by apply (cancel_mono (PreservesCokernel.iso ((evaluation C D).obj X) α).inv).1 simp only [Category.assoc, Iso.hom_inv_id] dsimp simp only [PreservesCokernel.iso_inv, Category.id_comp, Category.comp_id] exact (π_comp_cokernelComparison _ ((evaluation C D).obj X)).symm) #align category_theory.abelian.functor_category.image_obj_iso CategoryTheory.Abelian.FunctorCategory.imageObjIso
Mathlib/CategoryTheory/Abelian/FunctorCategory.lean
64
76
theorem coimageImageComparison_app : coimageImageComparison (α.app X) = (coimageObjIso α X).inv ≫ (coimageImageComparison α).app X ≫ (imageObjIso α X).hom := by
ext dsimp dsimp [imageObjIso, coimageObjIso, cokernel.map] simp only [coimage_image_factorisation, PreservesKernel.iso_hom, Category.assoc, kernel.lift_ι, Category.comp_id, PreservesCokernel.iso_inv, cokernel.π_desc_assoc, Category.id_comp] erw [kernelComparison_comp_ι _ ((evaluation C D).obj X), π_comp_cokernelComparison_assoc _ ((evaluation C D).obj X)] conv_lhs => rw [← coimage_image_factorisation α] rfl
664
import Mathlib.CategoryTheory.Abelian.Basic import Mathlib.CategoryTheory.Preadditive.FunctorCategory import Mathlib.CategoryTheory.Limits.Shapes.FunctorCategory import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Kernels #align_import category_theory.abelian.functor_category from "leanprover-community/mathlib"@"8abfb3ba5e211d8376b855dab5d67f9eba9e0774" noncomputable section namespace CategoryTheory open CategoryTheory.Limits namespace Abelian section universe z w v u -- Porting note: removed restrictions on universes variable {C : Type u} [Category.{v} C] variable {D : Type w} [Category.{z} D] [Abelian D] namespace FunctorCategory variable {F G : C ⥤ D} (α : F ⟶ G) (X : C) @[simps!] def coimageObjIso : (Abelian.coimage α).obj X ≅ Abelian.coimage (α.app X) := PreservesCokernel.iso ((evaluation C D).obj X) _ ≪≫ cokernel.mapIso _ _ (PreservesKernel.iso ((evaluation C D).obj X) _) (Iso.refl _) (by dsimp simp only [Category.comp_id, PreservesKernel.iso_hom] exact (kernelComparison_comp_ι _ ((evaluation C D).obj X)).symm) #align category_theory.abelian.functor_category.coimage_obj_iso CategoryTheory.Abelian.FunctorCategory.coimageObjIso @[simps!] def imageObjIso : (Abelian.image α).obj X ≅ Abelian.image (α.app X) := PreservesKernel.iso ((evaluation C D).obj X) _ ≪≫ kernel.mapIso _ _ (Iso.refl _) (PreservesCokernel.iso ((evaluation C D).obj X) _) (by apply (cancel_mono (PreservesCokernel.iso ((evaluation C D).obj X) α).inv).1 simp only [Category.assoc, Iso.hom_inv_id] dsimp simp only [PreservesCokernel.iso_inv, Category.id_comp, Category.comp_id] exact (π_comp_cokernelComparison _ ((evaluation C D).obj X)).symm) #align category_theory.abelian.functor_category.image_obj_iso CategoryTheory.Abelian.FunctorCategory.imageObjIso theorem coimageImageComparison_app : coimageImageComparison (α.app X) = (coimageObjIso α X).inv ≫ (coimageImageComparison α).app X ≫ (imageObjIso α X).hom := by ext dsimp dsimp [imageObjIso, coimageObjIso, cokernel.map] simp only [coimage_image_factorisation, PreservesKernel.iso_hom, Category.assoc, kernel.lift_ι, Category.comp_id, PreservesCokernel.iso_inv, cokernel.π_desc_assoc, Category.id_comp] erw [kernelComparison_comp_ι _ ((evaluation C D).obj X), π_comp_cokernelComparison_assoc _ ((evaluation C D).obj X)] conv_lhs => rw [← coimage_image_factorisation α] rfl #align category_theory.abelian.functor_category.coimage_image_comparison_app CategoryTheory.Abelian.FunctorCategory.coimageImageComparison_app
Mathlib/CategoryTheory/Abelian/FunctorCategory.lean
79
83
theorem coimageImageComparison_app' : (coimageImageComparison α).app X = (coimageObjIso α X).hom ≫ coimageImageComparison (α.app X) ≫ (imageObjIso α X).inv := by
simp only [coimageImageComparison_app, Iso.hom_inv_id_assoc, Iso.hom_inv_id, Category.assoc, Category.comp_id]
664
import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts #align_import category_theory.limits.shapes.strict_initial from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v u namespace CategoryTheory namespace Limits open Category variable (C : Type u) [Category.{v} C] section StrictInitial class HasStrictInitialObjects : Prop where out : ∀ {I A : C} (f : A ⟶ I), IsInitial I → IsIso f #align category_theory.limits.has_strict_initial_objects CategoryTheory.Limits.HasStrictInitialObjects variable {C} section variable [HasStrictInitialObjects C] {I : C} theorem IsInitial.isIso_to (hI : IsInitial I) {A : C} (f : A ⟶ I) : IsIso f := HasStrictInitialObjects.out f hI #align category_theory.limits.is_initial.is_iso_to CategoryTheory.Limits.IsInitial.isIso_to
Mathlib/CategoryTheory/Limits/Shapes/StrictInitial.lean
74
77
theorem IsInitial.strict_hom_ext (hI : IsInitial I) {A : C} (f g : A ⟶ I) : f = g := by
haveI := hI.isIso_to f haveI := hI.isIso_to g exact eq_of_inv_eq_inv (hI.hom_ext (inv f) (inv g))
665
import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts #align_import category_theory.limits.shapes.strict_initial from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v u namespace CategoryTheory namespace Limits open Category variable (C : Type u) [Category.{v} C] section StrictTerminal class HasStrictTerminalObjects : Prop where out : ∀ {I A : C} (f : I ⟶ A), IsTerminal I → IsIso f #align category_theory.limits.has_strict_terminal_objects CategoryTheory.Limits.HasStrictTerminalObjects variable {C} section variable [HasStrictTerminalObjects C] {I : C} theorem IsTerminal.isIso_from (hI : IsTerminal I) {A : C} (f : I ⟶ A) : IsIso f := HasStrictTerminalObjects.out f hI #align category_theory.limits.is_terminal.is_iso_from CategoryTheory.Limits.IsTerminal.isIso_from
Mathlib/CategoryTheory/Limits/Shapes/StrictInitial.lean
192
195
theorem IsTerminal.strict_hom_ext (hI : IsTerminal I) {A : C} (f g : I ⟶ A) : f = g := by
haveI := hI.isIso_from f haveI := hI.isIso_from g exact eq_of_inv_eq_inv (hI.hom_ext (inv f) (inv g))
665
import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts #align_import category_theory.limits.shapes.strict_initial from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe v u namespace CategoryTheory namespace Limits open Category variable (C : Type u) [Category.{v} C] section StrictTerminal class HasStrictTerminalObjects : Prop where out : ∀ {I A : C} (f : I ⟶ A), IsTerminal I → IsIso f #align category_theory.limits.has_strict_terminal_objects CategoryTheory.Limits.HasStrictTerminalObjects variable {C} section variable [HasStrictTerminalObjects C] {I : C} theorem IsTerminal.isIso_from (hI : IsTerminal I) {A : C} (f : I ⟶ A) : IsIso f := HasStrictTerminalObjects.out f hI #align category_theory.limits.is_terminal.is_iso_from CategoryTheory.Limits.IsTerminal.isIso_from theorem IsTerminal.strict_hom_ext (hI : IsTerminal I) {A : C} (f g : I ⟶ A) : f = g := by haveI := hI.isIso_from f haveI := hI.isIso_from g exact eq_of_inv_eq_inv (hI.hom_ext (inv f) (inv g)) #align category_theory.limits.is_terminal.strict_hom_ext CategoryTheory.Limits.IsTerminal.strict_hom_ext theorem IsTerminal.subsingleton_to (hI : IsTerminal I) {A : C} : Subsingleton (I ⟶ A) := ⟨hI.strict_hom_ext⟩ #align category_theory.limits.is_terminal.subsingleton_to CategoryTheory.Limits.IsTerminal.subsingleton_to variable {J : Type v} [SmallCategory J]
Mathlib/CategoryTheory/Limits/Shapes/StrictInitial.lean
206
237
theorem limit_π_isIso_of_is_strict_terminal (F : J ⥤ C) [HasLimit F] (i : J) (H : ∀ (j) (_ : j ≠ i), IsTerminal (F.obj j)) [Subsingleton (i ⟶ i)] : IsIso (limit.π F i) := by
classical refine ⟨⟨limit.lift _ ⟨_, ⟨?_, ?_⟩⟩, ?_, ?_⟩⟩ · exact fun j => dite (j = i) (fun h => eqToHom (by cases h; rfl)) fun h => (H _ h).from _ · intro j k f split_ifs with h h_1 h_1 · cases h cases h_1 obtain rfl : f = 𝟙 _ := Subsingleton.elim _ _ simp · cases h erw [Category.comp_id] haveI : IsIso (F.map f) := (H _ h_1).isIso_from _ rw [← IsIso.comp_inv_eq] apply (H _ h_1).hom_ext · cases h_1 apply (H _ h).hom_ext · apply (H _ h).hom_ext · ext rw [assoc, limit.lift_π] dsimp only split_ifs with h · cases h rw [id_comp, eqToHom_refl] exact comp_id _ · apply (H _ h).hom_ext · rw [limit.lift_π] simp
665
import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Limits.Shapes.CommSq import Mathlib.CategoryTheory.Limits.Shapes.StrictInitial import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts #align_import category_theory.extensive from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" open CategoryTheory.Limits namespace CategoryTheory universe v' u' v u variable {J : Type v'} [Category.{u'} J] {C : Type u} [Category.{v} C] variable {K : Type*} [Category K] {D : Type*} [Category D] section NatTrans def NatTrans.Equifibered {F G : J ⥤ C} (α : F ⟶ G) : Prop := ∀ ⦃i j : J⦄ (f : i ⟶ j), IsPullback (F.map f) (α.app i) (α.app j) (G.map f) #align category_theory.nat_trans.equifibered CategoryTheory.NatTrans.Equifibered theorem NatTrans.equifibered_of_isIso {F G : J ⥤ C} (α : F ⟶ G) [IsIso α] : Equifibered α := fun _ _ f => IsPullback.of_vert_isIso ⟨NatTrans.naturality _ f⟩ #align category_theory.nat_trans.equifibered_of_is_iso CategoryTheory.NatTrans.equifibered_of_isIso theorem NatTrans.Equifibered.comp {F G H : J ⥤ C} {α : F ⟶ G} {β : G ⟶ H} (hα : Equifibered α) (hβ : Equifibered β) : Equifibered (α ≫ β) := fun _ _ f => (hα f).paste_vert (hβ f) #align category_theory.nat_trans.equifibered.comp CategoryTheory.NatTrans.Equifibered.comp theorem NatTrans.Equifibered.whiskerRight {F G : J ⥤ C} {α : F ⟶ G} (hα : Equifibered α) (H : C ⥤ D) [∀ (i j : J) (f : j ⟶ i), PreservesLimit (cospan (α.app i) (G.map f)) H] : Equifibered (whiskerRight α H) := fun _ _ f => (hα f).map H #align category_theory.nat_trans.equifibered.whisker_right CategoryTheory.NatTrans.Equifibered.whiskerRight theorem NatTrans.Equifibered.whiskerLeft {K : Type*} [Category K] {F G : J ⥤ C} {α : F ⟶ G} (hα : Equifibered α) (H : K ⥤ J) : Equifibered (whiskerLeft H α) := fun _ _ f => hα (H.map f)
Mathlib/CategoryTheory/Limits/VanKampen.lean
75
80
theorem mapPair_equifibered {F F' : Discrete WalkingPair ⥤ C} (α : F ⟶ F') : NatTrans.Equifibered α := by
rintro ⟨⟨⟩⟩ ⟨j⟩ ⟨⟨rfl : _ = j⟩⟩ all_goals dsimp; simp only [Discrete.functor_map_id] exact IsPullback.of_horiz_isIso ⟨by simp only [Category.comp_id, Category.id_comp]⟩
666
import Mathlib.CategoryTheory.Adjunction.FullyFaithful import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Limits.Shapes.CommSq import Mathlib.CategoryTheory.Limits.Shapes.StrictInitial import Mathlib.CategoryTheory.Limits.FunctorCategory import Mathlib.CategoryTheory.Limits.Constructions.FiniteProductsOfBinaryProducts #align_import category_theory.extensive from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1" open CategoryTheory.Limits namespace CategoryTheory universe v' u' v u variable {J : Type v'} [Category.{u'} J] {C : Type u} [Category.{v} C] variable {K : Type*} [Category K] {D : Type*} [Category D] section NatTrans def NatTrans.Equifibered {F G : J ⥤ C} (α : F ⟶ G) : Prop := ∀ ⦃i j : J⦄ (f : i ⟶ j), IsPullback (F.map f) (α.app i) (α.app j) (G.map f) #align category_theory.nat_trans.equifibered CategoryTheory.NatTrans.Equifibered theorem NatTrans.equifibered_of_isIso {F G : J ⥤ C} (α : F ⟶ G) [IsIso α] : Equifibered α := fun _ _ f => IsPullback.of_vert_isIso ⟨NatTrans.naturality _ f⟩ #align category_theory.nat_trans.equifibered_of_is_iso CategoryTheory.NatTrans.equifibered_of_isIso theorem NatTrans.Equifibered.comp {F G H : J ⥤ C} {α : F ⟶ G} {β : G ⟶ H} (hα : Equifibered α) (hβ : Equifibered β) : Equifibered (α ≫ β) := fun _ _ f => (hα f).paste_vert (hβ f) #align category_theory.nat_trans.equifibered.comp CategoryTheory.NatTrans.Equifibered.comp theorem NatTrans.Equifibered.whiskerRight {F G : J ⥤ C} {α : F ⟶ G} (hα : Equifibered α) (H : C ⥤ D) [∀ (i j : J) (f : j ⟶ i), PreservesLimit (cospan (α.app i) (G.map f)) H] : Equifibered (whiskerRight α H) := fun _ _ f => (hα f).map H #align category_theory.nat_trans.equifibered.whisker_right CategoryTheory.NatTrans.Equifibered.whiskerRight theorem NatTrans.Equifibered.whiskerLeft {K : Type*} [Category K] {F G : J ⥤ C} {α : F ⟶ G} (hα : Equifibered α) (H : K ⥤ J) : Equifibered (whiskerLeft H α) := fun _ _ f => hα (H.map f) theorem mapPair_equifibered {F F' : Discrete WalkingPair ⥤ C} (α : F ⟶ F') : NatTrans.Equifibered α := by rintro ⟨⟨⟩⟩ ⟨j⟩ ⟨⟨rfl : _ = j⟩⟩ all_goals dsimp; simp only [Discrete.functor_map_id] exact IsPullback.of_horiz_isIso ⟨by simp only [Category.comp_id, Category.id_comp]⟩ #align category_theory.map_pair_equifibered CategoryTheory.mapPair_equifibered
Mathlib/CategoryTheory/Limits/VanKampen.lean
83
87
theorem NatTrans.equifibered_of_discrete {ι : Type*} {F G : Discrete ι ⥤ C} (α : F ⟶ G) : NatTrans.Equifibered α := by
rintro ⟨i⟩ ⟨j⟩ ⟨⟨rfl : i = j⟩⟩ simp only [Discrete.functor_map_id] exact IsPullback.of_horiz_isIso ⟨by rw [Category.id_comp, Category.comp_id]⟩
666
import Mathlib.Algebra.Associated import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Ring.Opposite import Mathlib.GroupTheory.GroupAction.Opposite #align_import ring_theory.non_zero_divisors from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" variable (M₀ : Type*) [MonoidWithZero M₀] def nonZeroDivisorsLeft : Submonoid M₀ where carrier := {x | ∀ y, y * x = 0 → y = 0} one_mem' := by simp mul_mem' {x} {y} hx hy := fun z hz ↦ hx _ <| hy _ (mul_assoc z x y ▸ hz) @[simp] lemma mem_nonZeroDivisorsLeft_iff {x : M₀} : x ∈ nonZeroDivisorsLeft M₀ ↔ ∀ y, y * x = 0 → y = 0 := Iff.rfl lemma nmem_nonZeroDivisorsLeft_iff {r : M₀} : r ∉ nonZeroDivisorsLeft M₀ ↔ {s | s * r = 0 ∧ s ≠ 0}.Nonempty := by simpa [mem_nonZeroDivisorsLeft_iff] using Set.nonempty_def.symm def nonZeroDivisorsRight : Submonoid M₀ where carrier := {x | ∀ y, x * y = 0 → y = 0} one_mem' := by simp mul_mem' := fun {x} {y} hx hy z hz ↦ hy _ (hx _ ((mul_assoc x y z).symm ▸ hz)) @[simp] lemma mem_nonZeroDivisorsRight_iff {x : M₀} : x ∈ nonZeroDivisorsRight M₀ ↔ ∀ y, x * y = 0 → y = 0 := Iff.rfl lemma nmem_nonZeroDivisorsRight_iff {r : M₀} : r ∉ nonZeroDivisorsRight M₀ ↔ {s | r * s = 0 ∧ s ≠ 0}.Nonempty := by simpa [mem_nonZeroDivisorsRight_iff] using Set.nonempty_def.symm lemma nonZeroDivisorsLeft_eq_right (M₀ : Type*) [CommMonoidWithZero M₀] : nonZeroDivisorsLeft M₀ = nonZeroDivisorsRight M₀ := by ext x; simp [mul_comm x] @[simp] lemma coe_nonZeroDivisorsLeft_eq [NoZeroDivisors M₀] [Nontrivial M₀] : nonZeroDivisorsLeft M₀ = {x : M₀ | x ≠ 0} := by ext x simp only [SetLike.mem_coe, mem_nonZeroDivisorsLeft_iff, mul_eq_zero, forall_eq_or_imp, true_and, Set.mem_setOf_eq] refine ⟨fun h ↦ ?_, fun hx y hx' ↦ by contradiction⟩ contrapose! h exact ⟨1, h, one_ne_zero⟩ @[simp] lemma coe_nonZeroDivisorsRight_eq [NoZeroDivisors M₀] [Nontrivial M₀] : nonZeroDivisorsRight M₀ = {x : M₀ | x ≠ 0} := by ext x simp only [SetLike.mem_coe, mem_nonZeroDivisorsRight_iff, mul_eq_zero, Set.mem_setOf_eq] refine ⟨fun h ↦ ?_, fun hx y hx' ↦ by aesop⟩ contrapose! h exact ⟨1, Or.inl h, one_ne_zero⟩ def nonZeroDivisors (R : Type*) [MonoidWithZero R] : Submonoid R where carrier := { x | ∀ z, z * x = 0 → z = 0 } one_mem' _ hz := by rwa [mul_one] at hz mul_mem' hx₁ hx₂ _ hz := by rw [← mul_assoc] at hz exact hx₁ _ (hx₂ _ hz) #align non_zero_divisors nonZeroDivisors scoped[nonZeroDivisors] notation:9000 R "⁰" => nonZeroDivisors R def nonZeroSMulDivisors (R : Type*) [MonoidWithZero R] (M : Type _) [Zero M] [MulAction R M] : Submonoid R where carrier := { r | ∀ m : M, r • m = 0 → m = 0} one_mem' m h := (one_smul R m) ▸ h mul_mem' {r₁ r₂} h₁ h₂ m H := h₂ _ <| h₁ _ <| mul_smul r₁ r₂ m ▸ H scoped[nonZeroSMulDivisors] notation:9000 R "⁰[" M "]" => nonZeroSMulDivisors R M section nonZeroDivisors open nonZeroDivisors variable {M M' M₁ R R' F : Type*} [MonoidWithZero M] [MonoidWithZero M'] [CommMonoidWithZero M₁] [Ring R] [CommRing R'] theorem mem_nonZeroDivisors_iff {r : M} : r ∈ M⁰ ↔ ∀ x, x * r = 0 → x = 0 := Iff.rfl #align mem_non_zero_divisors_iff mem_nonZeroDivisors_iff lemma nmem_nonZeroDivisors_iff {r : M} : r ∉ M⁰ ↔ {s | s * r = 0 ∧ s ≠ 0}.Nonempty := by simpa [mem_nonZeroDivisors_iff] using Set.nonempty_def.symm theorem mul_right_mem_nonZeroDivisors_eq_zero_iff {x r : M} (hr : r ∈ M⁰) : x * r = 0 ↔ x = 0 := ⟨hr _, by simp (config := { contextual := true })⟩ #align mul_right_mem_non_zero_divisors_eq_zero_iff mul_right_mem_nonZeroDivisors_eq_zero_iff @[simp] theorem mul_right_coe_nonZeroDivisors_eq_zero_iff {x : M} {c : M⁰} : x * c = 0 ↔ x = 0 := mul_right_mem_nonZeroDivisors_eq_zero_iff c.prop #align mul_right_coe_non_zero_divisors_eq_zero_iff mul_right_coe_nonZeroDivisors_eq_zero_iff
Mathlib/Algebra/GroupWithZero/NonZeroDivisors.lean
129
130
theorem mul_left_mem_nonZeroDivisors_eq_zero_iff {r x : M₁} (hr : r ∈ M₁⁰) : r * x = 0 ↔ x = 0 := by
rw [mul_comm, mul_right_mem_nonZeroDivisors_eq_zero_iff hr]
667
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.LinearAlgebra.BilinearForm.Properties open LinearMap (BilinForm) universe u v w variable {R : Type*} {M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] variable {R₁ : Type*} {M₁ : Type*} [CommRing R₁] [AddCommGroup M₁] [Module R₁ M₁] variable {V : Type*} {K : Type*} [Field K] [AddCommGroup V] [Module K V] variable {B : BilinForm R M} {B₁ : BilinForm R₁ M₁} namespace LinearMap namespace BilinForm def IsOrtho (B : BilinForm R M) (x y : M) : Prop := B x y = 0 #align bilin_form.is_ortho LinearMap.BilinForm.IsOrtho theorem isOrtho_def {B : BilinForm R M} {x y : M} : B.IsOrtho x y ↔ B x y = 0 := Iff.rfl #align bilin_form.is_ortho_def LinearMap.BilinForm.isOrtho_def theorem isOrtho_zero_left (x : M) : IsOrtho B (0 : M) x := LinearMap.isOrtho_zero_left B x #align bilin_form.is_ortho_zero_left LinearMap.BilinForm.isOrtho_zero_left theorem isOrtho_zero_right (x : M) : IsOrtho B x (0 : M) := zero_right x #align bilin_form.is_ortho_zero_right LinearMap.BilinForm.isOrtho_zero_right theorem ne_zero_of_not_isOrtho_self {B : BilinForm K V} (x : V) (hx₁ : ¬B.IsOrtho x x) : x ≠ 0 := fun hx₂ => hx₁ (hx₂.symm ▸ isOrtho_zero_left _) #align bilin_form.ne_zero_of_not_is_ortho_self LinearMap.BilinForm.ne_zero_of_not_isOrtho_self theorem IsRefl.ortho_comm (H : B.IsRefl) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := ⟨eq_zero H, eq_zero H⟩ #align bilin_form.is_refl.ortho_comm LinearMap.BilinForm.IsRefl.ortho_comm theorem IsAlt.ortho_comm (H : B₁.IsAlt) {x y : M₁} : IsOrtho B₁ x y ↔ IsOrtho B₁ y x := LinearMap.IsAlt.ortho_comm H #align bilin_form.is_alt.ortho_comm LinearMap.BilinForm.IsAlt.ortho_comm theorem IsSymm.ortho_comm (H : B.IsSymm) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := LinearMap.IsSymm.ortho_comm H #align bilin_form.is_symm.ortho_comm LinearMap.BilinForm.IsSymm.ortho_comm def iIsOrtho {n : Type w} (B : BilinForm R M) (v : n → M) : Prop := B.IsOrthoᵢ v set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho LinearMap.BilinForm.iIsOrtho theorem iIsOrtho_def {n : Type w} {B : BilinForm R M} {v : n → M} : B.iIsOrtho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 := Iff.rfl set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho_def LinearMap.BilinForm.iIsOrtho_def section variable {R₄ M₄ : Type*} [CommRing R₄] [IsDomain R₄] variable [AddCommGroup M₄] [Module R₄ M₄] {G : BilinForm R₄ M₄} @[simp]
Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean
100
105
theorem isOrtho_smul_left {x y : M₄} {a : R₄} (ha : a ≠ 0) : IsOrtho G (a • x) y ↔ IsOrtho G x y := by
dsimp only [IsOrtho] rw [map_smul] simp only [LinearMap.smul_apply, smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp] exact fun a ↦ (ha a).elim
668
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.LinearAlgebra.BilinearForm.Properties open LinearMap (BilinForm) universe u v w variable {R : Type*} {M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] variable {R₁ : Type*} {M₁ : Type*} [CommRing R₁] [AddCommGroup M₁] [Module R₁ M₁] variable {V : Type*} {K : Type*} [Field K] [AddCommGroup V] [Module K V] variable {B : BilinForm R M} {B₁ : BilinForm R₁ M₁} namespace LinearMap namespace BilinForm def IsOrtho (B : BilinForm R M) (x y : M) : Prop := B x y = 0 #align bilin_form.is_ortho LinearMap.BilinForm.IsOrtho theorem isOrtho_def {B : BilinForm R M} {x y : M} : B.IsOrtho x y ↔ B x y = 0 := Iff.rfl #align bilin_form.is_ortho_def LinearMap.BilinForm.isOrtho_def theorem isOrtho_zero_left (x : M) : IsOrtho B (0 : M) x := LinearMap.isOrtho_zero_left B x #align bilin_form.is_ortho_zero_left LinearMap.BilinForm.isOrtho_zero_left theorem isOrtho_zero_right (x : M) : IsOrtho B x (0 : M) := zero_right x #align bilin_form.is_ortho_zero_right LinearMap.BilinForm.isOrtho_zero_right theorem ne_zero_of_not_isOrtho_self {B : BilinForm K V} (x : V) (hx₁ : ¬B.IsOrtho x x) : x ≠ 0 := fun hx₂ => hx₁ (hx₂.symm ▸ isOrtho_zero_left _) #align bilin_form.ne_zero_of_not_is_ortho_self LinearMap.BilinForm.ne_zero_of_not_isOrtho_self theorem IsRefl.ortho_comm (H : B.IsRefl) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := ⟨eq_zero H, eq_zero H⟩ #align bilin_form.is_refl.ortho_comm LinearMap.BilinForm.IsRefl.ortho_comm theorem IsAlt.ortho_comm (H : B₁.IsAlt) {x y : M₁} : IsOrtho B₁ x y ↔ IsOrtho B₁ y x := LinearMap.IsAlt.ortho_comm H #align bilin_form.is_alt.ortho_comm LinearMap.BilinForm.IsAlt.ortho_comm theorem IsSymm.ortho_comm (H : B.IsSymm) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := LinearMap.IsSymm.ortho_comm H #align bilin_form.is_symm.ortho_comm LinearMap.BilinForm.IsSymm.ortho_comm def iIsOrtho {n : Type w} (B : BilinForm R M) (v : n → M) : Prop := B.IsOrthoᵢ v set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho LinearMap.BilinForm.iIsOrtho theorem iIsOrtho_def {n : Type w} {B : BilinForm R M} {v : n → M} : B.iIsOrtho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 := Iff.rfl set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho_def LinearMap.BilinForm.iIsOrtho_def section variable {R₄ M₄ : Type*} [CommRing R₄] [IsDomain R₄] variable [AddCommGroup M₄] [Module R₄ M₄] {G : BilinForm R₄ M₄} @[simp] theorem isOrtho_smul_left {x y : M₄} {a : R₄} (ha : a ≠ 0) : IsOrtho G (a • x) y ↔ IsOrtho G x y := by dsimp only [IsOrtho] rw [map_smul] simp only [LinearMap.smul_apply, smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp] exact fun a ↦ (ha a).elim #align bilin_form.is_ortho_smul_left LinearMap.BilinForm.isOrtho_smul_left @[simp]
Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean
109
114
theorem isOrtho_smul_right {x y : M₄} {a : R₄} (ha : a ≠ 0) : IsOrtho G x (a • y) ↔ IsOrtho G x y := by
dsimp only [IsOrtho] rw [map_smul] simp only [smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp] exact fun a ↦ (ha a).elim
668
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.LinearAlgebra.BilinearForm.Properties open LinearMap (BilinForm) universe u v w variable {R : Type*} {M : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M] variable {R₁ : Type*} {M₁ : Type*} [CommRing R₁] [AddCommGroup M₁] [Module R₁ M₁] variable {V : Type*} {K : Type*} [Field K] [AddCommGroup V] [Module K V] variable {B : BilinForm R M} {B₁ : BilinForm R₁ M₁} namespace LinearMap namespace BilinForm def IsOrtho (B : BilinForm R M) (x y : M) : Prop := B x y = 0 #align bilin_form.is_ortho LinearMap.BilinForm.IsOrtho theorem isOrtho_def {B : BilinForm R M} {x y : M} : B.IsOrtho x y ↔ B x y = 0 := Iff.rfl #align bilin_form.is_ortho_def LinearMap.BilinForm.isOrtho_def theorem isOrtho_zero_left (x : M) : IsOrtho B (0 : M) x := LinearMap.isOrtho_zero_left B x #align bilin_form.is_ortho_zero_left LinearMap.BilinForm.isOrtho_zero_left theorem isOrtho_zero_right (x : M) : IsOrtho B x (0 : M) := zero_right x #align bilin_form.is_ortho_zero_right LinearMap.BilinForm.isOrtho_zero_right theorem ne_zero_of_not_isOrtho_self {B : BilinForm K V} (x : V) (hx₁ : ¬B.IsOrtho x x) : x ≠ 0 := fun hx₂ => hx₁ (hx₂.symm ▸ isOrtho_zero_left _) #align bilin_form.ne_zero_of_not_is_ortho_self LinearMap.BilinForm.ne_zero_of_not_isOrtho_self theorem IsRefl.ortho_comm (H : B.IsRefl) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := ⟨eq_zero H, eq_zero H⟩ #align bilin_form.is_refl.ortho_comm LinearMap.BilinForm.IsRefl.ortho_comm theorem IsAlt.ortho_comm (H : B₁.IsAlt) {x y : M₁} : IsOrtho B₁ x y ↔ IsOrtho B₁ y x := LinearMap.IsAlt.ortho_comm H #align bilin_form.is_alt.ortho_comm LinearMap.BilinForm.IsAlt.ortho_comm theorem IsSymm.ortho_comm (H : B.IsSymm) {x y : M} : IsOrtho B x y ↔ IsOrtho B y x := LinearMap.IsSymm.ortho_comm H #align bilin_form.is_symm.ortho_comm LinearMap.BilinForm.IsSymm.ortho_comm def iIsOrtho {n : Type w} (B : BilinForm R M) (v : n → M) : Prop := B.IsOrthoᵢ v set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho LinearMap.BilinForm.iIsOrtho theorem iIsOrtho_def {n : Type w} {B : BilinForm R M} {v : n → M} : B.iIsOrtho v ↔ ∀ i j : n, i ≠ j → B (v i) (v j) = 0 := Iff.rfl set_option linter.uppercaseLean3 false in #align bilin_form.is_Ortho_def LinearMap.BilinForm.iIsOrtho_def section variable {R₄ M₄ : Type*} [CommRing R₄] [IsDomain R₄] variable [AddCommGroup M₄] [Module R₄ M₄] {G : BilinForm R₄ M₄} @[simp] theorem isOrtho_smul_left {x y : M₄} {a : R₄} (ha : a ≠ 0) : IsOrtho G (a • x) y ↔ IsOrtho G x y := by dsimp only [IsOrtho] rw [map_smul] simp only [LinearMap.smul_apply, smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp] exact fun a ↦ (ha a).elim #align bilin_form.is_ortho_smul_left LinearMap.BilinForm.isOrtho_smul_left @[simp] theorem isOrtho_smul_right {x y : M₄} {a : R₄} (ha : a ≠ 0) : IsOrtho G x (a • y) ↔ IsOrtho G x y := by dsimp only [IsOrtho] rw [map_smul] simp only [smul_eq_mul, mul_eq_zero, or_iff_right_iff_imp] exact fun a ↦ (ha a).elim #align bilin_form.is_ortho_smul_right LinearMap.BilinForm.isOrtho_smul_right
Mathlib/LinearAlgebra/BilinearForm/Orthogonal.lean
119
130
theorem linearIndependent_of_iIsOrtho {n : Type w} {B : BilinForm K V} {v : n → V} (hv₁ : B.iIsOrtho v) (hv₂ : ∀ i, ¬B.IsOrtho (v i) (v i)) : LinearIndependent K v := by
classical rw [linearIndependent_iff'] intro s w hs i hi have : B (s.sum fun i : n => w i • v i) (v i) = 0 := by rw [hs, zero_left] have hsum : (s.sum fun j : n => w j * B (v j) (v i)) = w i * B (v i) (v i) := by apply Finset.sum_eq_single_of_mem i hi intro j _ hij rw [iIsOrtho_def.1 hv₁ _ _ hij, mul_zero] simp_rw [sum_left, smul_left, hsum] at this exact eq_zero_of_ne_zero_of_mul_right_eq_zero (hv₂ i) this
668
import Mathlib.Data.Matroid.Restrict variable {α : Type*} {M : Matroid α} {E B I X R J : Set α} namespace Matroid open Set section EmptyOn def emptyOn (α : Type*) : Matroid α where E := ∅ Base := (· = ∅) Indep := (· = ∅) indep_iff' := by simp [subset_empty_iff] exists_base := ⟨∅, rfl⟩ base_exchange := by rintro _ _ rfl; simp maximality := by rintro _ _ _ rfl -; exact ⟨∅, by simp [mem_maximals_iff]⟩ subset_ground := by simp @[simp] theorem emptyOn_ground : (emptyOn α).E = ∅ := rfl @[simp] theorem emptyOn_base_iff : (emptyOn α).Base B ↔ B = ∅ := Iff.rfl @[simp] theorem emptyOn_indep_iff : (emptyOn α).Indep I ↔ I = ∅ := Iff.rfl
Mathlib/Data/Matroid/Constructions.lean
57
59
theorem ground_eq_empty_iff : (M.E = ∅) ↔ M = emptyOn α := by
simp only [emptyOn, eq_iff_indep_iff_indep_forall, iff_self_and] exact fun h ↦ by simp [h, subset_empty_iff]
669
import Mathlib.Data.Matroid.Restrict variable {α : Type*} {M : Matroid α} {E B I X R J : Set α} namespace Matroid open Set section EmptyOn def emptyOn (α : Type*) : Matroid α where E := ∅ Base := (· = ∅) Indep := (· = ∅) indep_iff' := by simp [subset_empty_iff] exists_base := ⟨∅, rfl⟩ base_exchange := by rintro _ _ rfl; simp maximality := by rintro _ _ _ rfl -; exact ⟨∅, by simp [mem_maximals_iff]⟩ subset_ground := by simp @[simp] theorem emptyOn_ground : (emptyOn α).E = ∅ := rfl @[simp] theorem emptyOn_base_iff : (emptyOn α).Base B ↔ B = ∅ := Iff.rfl @[simp] theorem emptyOn_indep_iff : (emptyOn α).Indep I ↔ I = ∅ := Iff.rfl theorem ground_eq_empty_iff : (M.E = ∅) ↔ M = emptyOn α := by simp only [emptyOn, eq_iff_indep_iff_indep_forall, iff_self_and] exact fun h ↦ by simp [h, subset_empty_iff] @[simp] theorem emptyOn_dual_eq : (emptyOn α)✶ = emptyOn α := by rw [← ground_eq_empty_iff]; rfl @[simp] theorem restrict_empty (M : Matroid α) : M ↾ (∅ : Set α) = emptyOn α := by simp [← ground_eq_empty_iff]
Mathlib/Data/Matroid/Constructions.lean
67
69
theorem eq_emptyOn_or_nonempty (M : Matroid α) : M = emptyOn α ∨ Matroid.Nonempty M := by
rw [← ground_eq_empty_iff] exact M.E.eq_empty_or_nonempty.elim Or.inl (fun h ↦ Or.inr ⟨h⟩)
669
import Mathlib.Data.Matroid.Restrict variable {α : Type*} {M : Matroid α} {E B I X R J : Set α} namespace Matroid open Set section EmptyOn def emptyOn (α : Type*) : Matroid α where E := ∅ Base := (· = ∅) Indep := (· = ∅) indep_iff' := by simp [subset_empty_iff] exists_base := ⟨∅, rfl⟩ base_exchange := by rintro _ _ rfl; simp maximality := by rintro _ _ _ rfl -; exact ⟨∅, by simp [mem_maximals_iff]⟩ subset_ground := by simp @[simp] theorem emptyOn_ground : (emptyOn α).E = ∅ := rfl @[simp] theorem emptyOn_base_iff : (emptyOn α).Base B ↔ B = ∅ := Iff.rfl @[simp] theorem emptyOn_indep_iff : (emptyOn α).Indep I ↔ I = ∅ := Iff.rfl theorem ground_eq_empty_iff : (M.E = ∅) ↔ M = emptyOn α := by simp only [emptyOn, eq_iff_indep_iff_indep_forall, iff_self_and] exact fun h ↦ by simp [h, subset_empty_iff] @[simp] theorem emptyOn_dual_eq : (emptyOn α)✶ = emptyOn α := by rw [← ground_eq_empty_iff]; rfl @[simp] theorem restrict_empty (M : Matroid α) : M ↾ (∅ : Set α) = emptyOn α := by simp [← ground_eq_empty_iff] theorem eq_emptyOn_or_nonempty (M : Matroid α) : M = emptyOn α ∨ Matroid.Nonempty M := by rw [← ground_eq_empty_iff] exact M.E.eq_empty_or_nonempty.elim Or.inl (fun h ↦ Or.inr ⟨h⟩)
Mathlib/Data/Matroid/Constructions.lean
71
73
theorem eq_emptyOn [IsEmpty α] (M : Matroid α) : M = emptyOn α := by
rw [← ground_eq_empty_iff] exact M.E.eq_empty_of_isEmpty
669
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler namespace ZMod variable (p : ℕ) [Fact p.Prime]
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
48
57
theorem euler_criterion_units (x : (ZMod p)ˣ) : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ x ^ (p / 2) = 1 := by
by_cases hc : p = 2 · subst hc simp only [eq_iff_true_of_subsingleton, exists_const] · have h₀ := FiniteField.unit_isSquare_iff (by rwa [ringChar_zmod_n]) x have hs : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ IsSquare x := by rw [isSquare_iff_exists_sq x] simp_rw [eq_comm] rw [hs] rwa [card p] at h₀
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler namespace ZMod variable (p : ℕ) [Fact p.Prime] theorem euler_criterion_units (x : (ZMod p)ˣ) : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ x ^ (p / 2) = 1 := by by_cases hc : p = 2 · subst hc simp only [eq_iff_true_of_subsingleton, exists_const] · have h₀ := FiniteField.unit_isSquare_iff (by rwa [ringChar_zmod_n]) x have hs : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ IsSquare x := by rw [isSquare_iff_exists_sq x] simp_rw [eq_comm] rw [hs] rwa [card p] at h₀ #align zmod.euler_criterion_units ZMod.euler_criterion_units
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
61
70
theorem euler_criterion {a : ZMod p} (ha : a ≠ 0) : IsSquare (a : ZMod p) ↔ a ^ (p / 2) = 1 := by
apply (iff_congr _ (by simp [Units.ext_iff])).mp (euler_criterion_units p (Units.mk0 a ha)) simp only [Units.ext_iff, sq, Units.val_mk0, Units.val_mul] constructor · rintro ⟨y, hy⟩; exact ⟨y, hy.symm⟩ · rintro ⟨y, rfl⟩ have hy : y ≠ 0 := by rintro rfl simp [zero_pow, mul_zero, ne_eq, not_true] at ha refine ⟨Units.mk0 y hy, ?_⟩; simp
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler namespace ZMod variable (p : ℕ) [Fact p.Prime] theorem euler_criterion_units (x : (ZMod p)ˣ) : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ x ^ (p / 2) = 1 := by by_cases hc : p = 2 · subst hc simp only [eq_iff_true_of_subsingleton, exists_const] · have h₀ := FiniteField.unit_isSquare_iff (by rwa [ringChar_zmod_n]) x have hs : (∃ y : (ZMod p)ˣ, y ^ 2 = x) ↔ IsSquare x := by rw [isSquare_iff_exists_sq x] simp_rw [eq_comm] rw [hs] rwa [card p] at h₀ #align zmod.euler_criterion_units ZMod.euler_criterion_units theorem euler_criterion {a : ZMod p} (ha : a ≠ 0) : IsSquare (a : ZMod p) ↔ a ^ (p / 2) = 1 := by apply (iff_congr _ (by simp [Units.ext_iff])).mp (euler_criterion_units p (Units.mk0 a ha)) simp only [Units.ext_iff, sq, Units.val_mk0, Units.val_mul] constructor · rintro ⟨y, hy⟩; exact ⟨y, hy.symm⟩ · rintro ⟨y, rfl⟩ have hy : y ≠ 0 := by rintro rfl simp [zero_pow, mul_zero, ne_eq, not_true] at ha refine ⟨Units.mk0 y hy, ?_⟩; simp #align zmod.euler_criterion ZMod.euler_criterion
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
74
81
theorem pow_div_two_eq_neg_one_or_one {a : ZMod p} (ha : a ≠ 0) : a ^ (p / 2) = 1 ∨ a ^ (p / 2) = -1 := by
cases' Prime.eq_two_or_odd (@Fact.out p.Prime _) with hp2 hp_odd · subst p; revert a ha; intro a; fin_cases a · tauto · simp rw [← mul_self_eq_one_iff, ← pow_add, ← two_mul, two_mul_odd_div_two hp_odd] exact pow_card_sub_one_eq_one ha
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym namespace legendreSym
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
116
132
theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by
rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc · by_cases ha : (a : ZMod p) = 0 · rw [legendreSym, ha, quadraticChar_zero, zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne'] norm_cast · have := (ringChar_zmod_n p).symm.trans hc -- p = 2 subst p rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha] revert ha push_cast generalize (a : ZMod 2) = b; fin_cases b · tauto · simp · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym namespace legendreSym theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc · by_cases ha : (a : ZMod p) = 0 · rw [legendreSym, ha, quadraticChar_zero, zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne'] norm_cast · have := (ringChar_zmod_n p).symm.trans hc -- p = 2 subst p rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha] revert ha push_cast generalize (a : ZMod 2) = b; fin_cases b · tauto · simp · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm #align legendre_sym.eq_pow legendreSym.eq_pow theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ∨ legendreSym p a = -1 := quadraticChar_dichotomy ha #align legendre_sym.eq_one_or_neg_one legendreSym.eq_one_or_neg_one theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = -1 ↔ ¬legendreSym p a = 1 := quadraticChar_eq_neg_one_iff_not_one ha #align legendre_sym.eq_neg_one_iff_not_one legendreSym.eq_neg_one_iff_not_one theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 := quadraticChar_eq_zero_iff #align legendre_sym.eq_zero_iff legendreSym.eq_zero_iff @[simp]
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
152
152
theorem at_zero : legendreSym p 0 = 0 := by
rw [legendreSym, Int.cast_zero, MulChar.map_zero]
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym namespace legendreSym theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc · by_cases ha : (a : ZMod p) = 0 · rw [legendreSym, ha, quadraticChar_zero, zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne'] norm_cast · have := (ringChar_zmod_n p).symm.trans hc -- p = 2 subst p rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha] revert ha push_cast generalize (a : ZMod 2) = b; fin_cases b · tauto · simp · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm #align legendre_sym.eq_pow legendreSym.eq_pow theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ∨ legendreSym p a = -1 := quadraticChar_dichotomy ha #align legendre_sym.eq_one_or_neg_one legendreSym.eq_one_or_neg_one theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = -1 ↔ ¬legendreSym p a = 1 := quadraticChar_eq_neg_one_iff_not_one ha #align legendre_sym.eq_neg_one_iff_not_one legendreSym.eq_neg_one_iff_not_one theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 := quadraticChar_eq_zero_iff #align legendre_sym.eq_zero_iff legendreSym.eq_zero_iff @[simp] theorem at_zero : legendreSym p 0 = 0 := by rw [legendreSym, Int.cast_zero, MulChar.map_zero] #align legendre_sym.at_zero legendreSym.at_zero @[simp]
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
156
156
theorem at_one : legendreSym p 1 = 1 := by
rw [legendreSym, Int.cast_one, MulChar.map_one]
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym namespace legendreSym theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc · by_cases ha : (a : ZMod p) = 0 · rw [legendreSym, ha, quadraticChar_zero, zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne'] norm_cast · have := (ringChar_zmod_n p).symm.trans hc -- p = 2 subst p rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha] revert ha push_cast generalize (a : ZMod 2) = b; fin_cases b · tauto · simp · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm #align legendre_sym.eq_pow legendreSym.eq_pow theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ∨ legendreSym p a = -1 := quadraticChar_dichotomy ha #align legendre_sym.eq_one_or_neg_one legendreSym.eq_one_or_neg_one theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = -1 ↔ ¬legendreSym p a = 1 := quadraticChar_eq_neg_one_iff_not_one ha #align legendre_sym.eq_neg_one_iff_not_one legendreSym.eq_neg_one_iff_not_one theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 := quadraticChar_eq_zero_iff #align legendre_sym.eq_zero_iff legendreSym.eq_zero_iff @[simp] theorem at_zero : legendreSym p 0 = 0 := by rw [legendreSym, Int.cast_zero, MulChar.map_zero] #align legendre_sym.at_zero legendreSym.at_zero @[simp] theorem at_one : legendreSym p 1 = 1 := by rw [legendreSym, Int.cast_one, MulChar.map_one] #align legendre_sym.at_one legendreSym.at_one protected theorem mul (a b : ℤ) : legendreSym p (a * b) = legendreSym p a * legendreSym p b := by simp [legendreSym, Int.cast_mul, map_mul, quadraticCharFun_mul] #align legendre_sym.mul legendreSym.mul @[simps] def hom : ℤ →*₀ ℤ where toFun := legendreSym p map_zero' := at_zero p map_one' := at_one p map_mul' := legendreSym.mul p #align legendre_sym.hom legendreSym.hom theorem sq_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a ^ 2 = 1 := quadraticChar_sq_one ha #align legendre_sym.sq_one legendreSym.sq_one
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
179
182
theorem sq_one' {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p (a ^ 2) = 1 := by
dsimp only [legendreSym] rw [Int.cast_pow] exact quadraticChar_sq_one' ha
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym namespace legendreSym theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc · by_cases ha : (a : ZMod p) = 0 · rw [legendreSym, ha, quadraticChar_zero, zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne'] norm_cast · have := (ringChar_zmod_n p).symm.trans hc -- p = 2 subst p rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha] revert ha push_cast generalize (a : ZMod 2) = b; fin_cases b · tauto · simp · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm #align legendre_sym.eq_pow legendreSym.eq_pow theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ∨ legendreSym p a = -1 := quadraticChar_dichotomy ha #align legendre_sym.eq_one_or_neg_one legendreSym.eq_one_or_neg_one theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = -1 ↔ ¬legendreSym p a = 1 := quadraticChar_eq_neg_one_iff_not_one ha #align legendre_sym.eq_neg_one_iff_not_one legendreSym.eq_neg_one_iff_not_one theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 := quadraticChar_eq_zero_iff #align legendre_sym.eq_zero_iff legendreSym.eq_zero_iff @[simp] theorem at_zero : legendreSym p 0 = 0 := by rw [legendreSym, Int.cast_zero, MulChar.map_zero] #align legendre_sym.at_zero legendreSym.at_zero @[simp] theorem at_one : legendreSym p 1 = 1 := by rw [legendreSym, Int.cast_one, MulChar.map_one] #align legendre_sym.at_one legendreSym.at_one protected theorem mul (a b : ℤ) : legendreSym p (a * b) = legendreSym p a * legendreSym p b := by simp [legendreSym, Int.cast_mul, map_mul, quadraticCharFun_mul] #align legendre_sym.mul legendreSym.mul @[simps] def hom : ℤ →*₀ ℤ where toFun := legendreSym p map_zero' := at_zero p map_one' := at_one p map_mul' := legendreSym.mul p #align legendre_sym.hom legendreSym.hom theorem sq_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a ^ 2 = 1 := quadraticChar_sq_one ha #align legendre_sym.sq_one legendreSym.sq_one theorem sq_one' {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p (a ^ 2) = 1 := by dsimp only [legendreSym] rw [Int.cast_pow] exact quadraticChar_sq_one' ha #align legendre_sym.sq_one' legendreSym.sq_one' protected theorem mod (a : ℤ) : legendreSym p a = legendreSym p (a % p) := by simp only [legendreSym, intCast_mod] #align legendre_sym.mod legendreSym.mod theorem eq_one_iff {a : ℤ} (ha0 : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ↔ IsSquare (a : ZMod p) := quadraticChar_one_iff_isSquare ha0 #align legendre_sym.eq_one_iff legendreSym.eq_one_iff
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
195
199
theorem eq_one_iff' {a : ℕ} (ha0 : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ↔ IsSquare (a : ZMod p) := by
rw [eq_one_iff] · norm_cast · exact mod_cast ha0
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym namespace legendreSym theorem eq_pow (a : ℤ) : (legendreSym p a : ZMod p) = (a : ZMod p) ^ (p / 2) := by rcases eq_or_ne (ringChar (ZMod p)) 2 with hc | hc · by_cases ha : (a : ZMod p) = 0 · rw [legendreSym, ha, quadraticChar_zero, zero_pow (Nat.div_pos (@Fact.out p.Prime).two_le (succ_pos 1)).ne'] norm_cast · have := (ringChar_zmod_n p).symm.trans hc -- p = 2 subst p rw [legendreSym, quadraticChar_eq_one_of_char_two hc ha] revert ha push_cast generalize (a : ZMod 2) = b; fin_cases b · tauto · simp · convert quadraticChar_eq_pow_of_char_ne_two' hc (a : ZMod p) exact (card p).symm #align legendre_sym.eq_pow legendreSym.eq_pow theorem eq_one_or_neg_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ∨ legendreSym p a = -1 := quadraticChar_dichotomy ha #align legendre_sym.eq_one_or_neg_one legendreSym.eq_one_or_neg_one theorem eq_neg_one_iff_not_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a = -1 ↔ ¬legendreSym p a = 1 := quadraticChar_eq_neg_one_iff_not_one ha #align legendre_sym.eq_neg_one_iff_not_one legendreSym.eq_neg_one_iff_not_one theorem eq_zero_iff (a : ℤ) : legendreSym p a = 0 ↔ (a : ZMod p) = 0 := quadraticChar_eq_zero_iff #align legendre_sym.eq_zero_iff legendreSym.eq_zero_iff @[simp] theorem at_zero : legendreSym p 0 = 0 := by rw [legendreSym, Int.cast_zero, MulChar.map_zero] #align legendre_sym.at_zero legendreSym.at_zero @[simp] theorem at_one : legendreSym p 1 = 1 := by rw [legendreSym, Int.cast_one, MulChar.map_one] #align legendre_sym.at_one legendreSym.at_one protected theorem mul (a b : ℤ) : legendreSym p (a * b) = legendreSym p a * legendreSym p b := by simp [legendreSym, Int.cast_mul, map_mul, quadraticCharFun_mul] #align legendre_sym.mul legendreSym.mul @[simps] def hom : ℤ →*₀ ℤ where toFun := legendreSym p map_zero' := at_zero p map_one' := at_one p map_mul' := legendreSym.mul p #align legendre_sym.hom legendreSym.hom theorem sq_one {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p a ^ 2 = 1 := quadraticChar_sq_one ha #align legendre_sym.sq_one legendreSym.sq_one theorem sq_one' {a : ℤ} (ha : (a : ZMod p) ≠ 0) : legendreSym p (a ^ 2) = 1 := by dsimp only [legendreSym] rw [Int.cast_pow] exact quadraticChar_sq_one' ha #align legendre_sym.sq_one' legendreSym.sq_one' protected theorem mod (a : ℤ) : legendreSym p a = legendreSym p (a % p) := by simp only [legendreSym, intCast_mod] #align legendre_sym.mod legendreSym.mod theorem eq_one_iff {a : ℤ} (ha0 : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ↔ IsSquare (a : ZMod p) := quadraticChar_one_iff_isSquare ha0 #align legendre_sym.eq_one_iff legendreSym.eq_one_iff theorem eq_one_iff' {a : ℕ} (ha0 : (a : ZMod p) ≠ 0) : legendreSym p a = 1 ↔ IsSquare (a : ZMod p) := by rw [eq_one_iff] · norm_cast · exact mod_cast ha0 #align legendre_sym.eq_one_iff' legendreSym.eq_one_iff' theorem eq_neg_one_iff {a : ℤ} : legendreSym p a = -1 ↔ ¬IsSquare (a : ZMod p) := quadraticChar_neg_one_iff_not_isSquare #align legendre_sym.eq_neg_one_iff legendreSym.eq_neg_one_iff
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
207
208
theorem eq_neg_one_iff' {a : ℕ} : legendreSym p a = -1 ↔ ¬IsSquare (a : ZMod p) := by
rw [eq_neg_one_iff]; norm_cast
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym section Values variable {p : ℕ} [Fact p.Prime] open ZMod
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
294
296
theorem legendreSym.at_neg_one (hp : p ≠ 2) : legendreSym p (-1) = χ₄ p := by
simp only [legendreSym, card p, quadraticChar_neg_one ((ringChar_zmod_n p).substr hp), Int.cast_neg, Int.cast_one]
670
import Mathlib.NumberTheory.LegendreSymbol.QuadraticChar.Basic #align_import number_theory.legendre_symbol.basic from "leanprover-community/mathlib"@"5b2fe80501ff327b9109fb09b7cc8c325cd0d7d9" open Nat section Euler section Legendre open ZMod variable (p : ℕ) [Fact p.Prime] def legendreSym (a : ℤ) : ℤ := quadraticChar (ZMod p) a #align legendre_sym legendreSym section Values variable {p : ℕ} [Fact p.Prime] open ZMod theorem legendreSym.at_neg_one (hp : p ≠ 2) : legendreSym p (-1) = χ₄ p := by simp only [legendreSym, card p, quadraticChar_neg_one ((ringChar_zmod_n p).substr hp), Int.cast_neg, Int.cast_one] #align legendre_sym.at_neg_one legendreSym.at_neg_one namespace ZMod
Mathlib/NumberTheory/LegendreSymbol/Basic.lean
302
303
theorem exists_sq_eq_neg_one_iff : IsSquare (-1 : ZMod p) ↔ p % 4 ≠ 3 := by
rw [FiniteField.isSquare_neg_one_iff, card p]
670
import Mathlib.NumberTheory.LegendreSymbol.Basic import Mathlib.Analysis.Normed.Field.Basic #align_import number_theory.legendre_symbol.gauss_eisenstein_lemmas from "leanprover-community/mathlib"@"8818fdefc78642a7e6afcd20be5c184f3c7d9699" open Finset Nat open scoped Nat section GaussEisenstein namespace ZMod
Mathlib/NumberTheory/LegendreSymbol/GaussEisensteinLemmas.lean
30
60
theorem Ico_map_valMinAbs_natAbs_eq_Ico_map_id (p : ℕ) [hp : Fact p.Prime] (a : ZMod p) (hap : a ≠ 0) : ((Ico 1 (p / 2).succ).1.map fun (x : ℕ) => (a * x).valMinAbs.natAbs) = (Ico 1 (p / 2).succ).1.map fun a => a := by
have he : ∀ {x}, x ∈ Ico 1 (p / 2).succ → x ≠ 0 ∧ x ≤ p / 2 := by simp (config := { contextual := true }) [Nat.lt_succ_iff, Nat.succ_le_iff, pos_iff_ne_zero] have hep : ∀ {x}, x ∈ Ico 1 (p / 2).succ → x < p := fun hx => lt_of_le_of_lt (he hx).2 (Nat.div_lt_self hp.1.pos (by decide)) have hpe : ∀ {x}, x ∈ Ico 1 (p / 2).succ → ¬p ∣ x := fun hx hpx => not_lt_of_ge (le_of_dvd (Nat.pos_of_ne_zero (he hx).1) hpx) (hep hx) have hmem : ∀ (x : ℕ) (hx : x ∈ Ico 1 (p / 2).succ), (a * x : ZMod p).valMinAbs.natAbs ∈ Ico 1 (p / 2).succ := by intro x hx simp [hap, CharP.cast_eq_zero_iff (ZMod p) p, hpe hx, Nat.lt_succ_iff, succ_le_iff, pos_iff_ne_zero, natAbs_valMinAbs_le _] have hsurj : ∀ (b : ℕ) (hb : b ∈ Ico 1 (p / 2).succ), ∃ x, ∃ _ : x ∈ Ico 1 (p / 2).succ, (a * x : ZMod p).valMinAbs.natAbs = b := by intro b hb refine ⟨(b / a : ZMod p).valMinAbs.natAbs, mem_Ico.mpr ⟨?_, ?_⟩, ?_⟩ · apply Nat.pos_of_ne_zero simp only [div_eq_mul_inv, hap, CharP.cast_eq_zero_iff (ZMod p) p, hpe hb, not_false_iff, valMinAbs_eq_zero, inv_eq_zero, Int.natAbs_eq_zero, Ne, _root_.mul_eq_zero, or_self_iff] · apply lt_succ_of_le; apply natAbs_valMinAbs_le · rw [natCast_natAbs_valMinAbs] split_ifs · erw [mul_div_cancel₀ _ hap, valMinAbs_def_pos, val_cast_of_lt (hep hb), if_pos (le_of_lt_succ (mem_Ico.1 hb).2), Int.natAbs_ofNat] · erw [mul_neg, mul_div_cancel₀ _ hap, natAbs_valMinAbs_neg, valMinAbs_def_pos, val_cast_of_lt (hep hb), if_pos (le_of_lt_succ (mem_Ico.1 hb).2), Int.natAbs_ofNat] exact Multiset.map_eq_map_of_bij_of_nodup _ _ (Finset.nodup _) (Finset.nodup _) (fun x _ => (a * x : ZMod p).valMinAbs.natAbs) hmem (inj_on_of_surj_on_of_card_le _ hmem hsurj le_rfl) hsurj (fun _ _ => rfl)
671
import Mathlib.CategoryTheory.Preadditive.Injective import Mathlib.Algebra.Homology.ShortComplex.HomologicalComplex import Mathlib.Algebra.Homology.QuasiIso #align_import category_theory.preadditive.injective_resolution from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7" noncomputable section universe v u namespace CategoryTheory open Limits HomologicalComplex CochainComplex variable {C : Type u} [Category.{v} C] [HasZeroObject C] [HasZeroMorphisms C] -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] structure InjectiveResolution (Z : C) where cocomplex : CochainComplex C ℕ injective : ∀ n, Injective (cocomplex.X n) := by infer_instance [hasHomology : ∀ i, cocomplex.HasHomology i] ι : (single₀ C).obj Z ⟶ cocomplex quasiIso : QuasiIso ι := by infer_instance set_option linter.uppercaseLean3 false in #align category_theory.InjectiveResolution CategoryTheory.InjectiveResolution open InjectiveResolution in attribute [instance] injective hasHomology InjectiveResolution.quasiIso class HasInjectiveResolution (Z : C) : Prop where out : Nonempty (InjectiveResolution Z) #align category_theory.has_injective_resolution CategoryTheory.HasInjectiveResolution attribute [inherit_doc HasInjectiveResolution] HasInjectiveResolution.out section variable (C) class HasInjectiveResolutions : Prop where out : ∀ Z : C, HasInjectiveResolution Z #align category_theory.has_injective_resolutions CategoryTheory.HasInjectiveResolutions attribute [instance 100] HasInjectiveResolutions.out end namespace InjectiveResolution variable {Z : C} (I : InjectiveResolution Z) lemma cocomplex_exactAt_succ (n : ℕ) : I.cocomplex.ExactAt (n + 1) := by rw [← quasiIsoAt_iff_exactAt I.ι (n + 1) (exactAt_succ_single_obj _ _)] infer_instance lemma exact_succ (n : ℕ): (ShortComplex.mk _ _ (I.cocomplex.d_comp_d n (n + 1) (n + 2))).Exact := (HomologicalComplex.exactAt_iff' _ n (n + 1) (n + 2) (by simp) (by simp only [CochainComplex.next]; rfl)).1 (I.cocomplex_exactAt_succ n) @[simp] theorem ι_f_succ (n : ℕ) : I.ι.f (n + 1) = 0 := (isZero_single_obj_X _ _ _ _ (by simp)).eq_of_src _ _ set_option linter.uppercaseLean3 false in #align category_theory.InjectiveResolution.ι_f_succ CategoryTheory.InjectiveResolution.ι_f_succ -- Porting note (#10618): removed @[simp] simp can prove this @[reassoc]
Mathlib/CategoryTheory/Preadditive/InjectiveResolution.lean
104
106
theorem ι_f_zero_comp_complex_d : I.ι.f 0 ≫ I.cocomplex.d 0 1 = 0 := by
simp
672
import Mathlib.CategoryTheory.Preadditive.Injective import Mathlib.Algebra.Homology.ShortComplex.HomologicalComplex import Mathlib.Algebra.Homology.QuasiIso #align_import category_theory.preadditive.injective_resolution from "leanprover-community/mathlib"@"14b69e9f3c16630440a2cbd46f1ddad0d561dee7" noncomputable section universe v u namespace CategoryTheory open Limits HomologicalComplex CochainComplex variable {C : Type u} [Category.{v} C] [HasZeroObject C] [HasZeroMorphisms C] -- Porting note(#5171): this linter isn't ported yet. -- @[nolint has_nonempty_instance] structure InjectiveResolution (Z : C) where cocomplex : CochainComplex C ℕ injective : ∀ n, Injective (cocomplex.X n) := by infer_instance [hasHomology : ∀ i, cocomplex.HasHomology i] ι : (single₀ C).obj Z ⟶ cocomplex quasiIso : QuasiIso ι := by infer_instance set_option linter.uppercaseLean3 false in #align category_theory.InjectiveResolution CategoryTheory.InjectiveResolution open InjectiveResolution in attribute [instance] injective hasHomology InjectiveResolution.quasiIso class HasInjectiveResolution (Z : C) : Prop where out : Nonempty (InjectiveResolution Z) #align category_theory.has_injective_resolution CategoryTheory.HasInjectiveResolution attribute [inherit_doc HasInjectiveResolution] HasInjectiveResolution.out section variable (C) class HasInjectiveResolutions : Prop where out : ∀ Z : C, HasInjectiveResolution Z #align category_theory.has_injective_resolutions CategoryTheory.HasInjectiveResolutions attribute [instance 100] HasInjectiveResolutions.out end namespace InjectiveResolution variable {Z : C} (I : InjectiveResolution Z) lemma cocomplex_exactAt_succ (n : ℕ) : I.cocomplex.ExactAt (n + 1) := by rw [← quasiIsoAt_iff_exactAt I.ι (n + 1) (exactAt_succ_single_obj _ _)] infer_instance lemma exact_succ (n : ℕ): (ShortComplex.mk _ _ (I.cocomplex.d_comp_d n (n + 1) (n + 2))).Exact := (HomologicalComplex.exactAt_iff' _ n (n + 1) (n + 2) (by simp) (by simp only [CochainComplex.next]; rfl)).1 (I.cocomplex_exactAt_succ n) @[simp] theorem ι_f_succ (n : ℕ) : I.ι.f (n + 1) = 0 := (isZero_single_obj_X _ _ _ _ (by simp)).eq_of_src _ _ set_option linter.uppercaseLean3 false in #align category_theory.InjectiveResolution.ι_f_succ CategoryTheory.InjectiveResolution.ι_f_succ -- Porting note (#10618): removed @[simp] simp can prove this @[reassoc] theorem ι_f_zero_comp_complex_d : I.ι.f 0 ≫ I.cocomplex.d 0 1 = 0 := by simp set_option linter.uppercaseLean3 false in #align category_theory.InjectiveResolution.ι_f_zero_comp_complex_d CategoryTheory.InjectiveResolution.ι_f_zero_comp_complex_d -- Porting note (#10618): removed @[simp] simp can prove this
Mathlib/CategoryTheory/Preadditive/InjectiveResolution.lean
111
113
theorem complex_d_comp (n : ℕ) : I.cocomplex.d n (n + 1) ≫ I.cocomplex.d (n + 1) (n + 2) = 0 := by
simp
672
import Mathlib.CategoryTheory.Limits.Shapes.Biproducts import Mathlib.CategoryTheory.Limits.Preserves.Shapes.Zero #align_import category_theory.limits.preserves.shapes.biproducts from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe w₁ w₂ v₁ v₂ u₁ u₂ noncomputable section open CategoryTheory open CategoryTheory.Limits namespace CategoryTheory variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D] section HasZeroMorphisms variable [HasZeroMorphisms C] [HasZeroMorphisms D] namespace Functor section Map variable (F : C ⥤ D) [PreservesZeroMorphisms F] variable (F : C ⥤ D) (X Y : C) [HasBinaryBiproduct X Y] section variable [HasBinaryBiproduct (F.obj X) (F.obj Y)] def biprodComparison : F.obj (X ⊞ Y) ⟶ F.obj X ⊞ F.obj Y := biprod.lift (F.map biprod.fst) (F.map biprod.snd) #align category_theory.functor.biprod_comparison CategoryTheory.Functor.biprodComparison @[reassoc (attr := simp)] theorem biprodComparison_fst : biprodComparison F X Y ≫ biprod.fst = F.map biprod.fst := biprod.lift_fst _ _ #align category_theory.functor.biprod_comparison_fst CategoryTheory.Functor.biprodComparison_fst @[reassoc (attr := simp)] theorem biprodComparison_snd : biprodComparison F X Y ≫ biprod.snd = F.map biprod.snd := biprod.lift_snd _ _ #align category_theory.functor.biprod_comparison_snd CategoryTheory.Functor.biprodComparison_snd def biprodComparison' : F.obj X ⊞ F.obj Y ⟶ F.obj (X ⊞ Y) := biprod.desc (F.map biprod.inl) (F.map biprod.inr) #align category_theory.functor.biprod_comparison' CategoryTheory.Functor.biprodComparison' @[reassoc (attr := simp)] theorem inl_biprodComparison' : biprod.inl ≫ biprodComparison' F X Y = F.map biprod.inl := biprod.inl_desc _ _ #align category_theory.functor.inl_biprod_comparison' CategoryTheory.Functor.inl_biprodComparison' @[reassoc (attr := simp)] theorem inr_biprodComparison' : biprod.inr ≫ biprodComparison' F X Y = F.map biprod.inr := biprod.inr_desc _ _ #align category_theory.functor.inr_biprod_comparison' CategoryTheory.Functor.inr_biprodComparison' variable [PreservesZeroMorphisms F] @[reassoc (attr := simp)]
Mathlib/CategoryTheory/Limits/Preserves/Shapes/Biproducts.lean
349
351
theorem biprodComparison'_comp_biprodComparison : biprodComparison' F X Y ≫ biprodComparison F X Y = 𝟙 (F.obj X ⊞ F.obj Y) := by
ext <;> simp [← Functor.map_comp]
673
import Mathlib.MeasureTheory.MeasurableSpace.Defs import Mathlib.Order.Filter.CountableInter open Filter Set MeasurableSpace variable {α : Type*} (m : MeasurableSpace α) (l : Filter α) [CountableInterFilter l] {s t : Set α} def EventuallyMeasurableSpace : MeasurableSpace α where MeasurableSet' s := ∃ t, MeasurableSet t ∧ s =ᶠ[l] t measurableSet_empty := ⟨∅, MeasurableSet.empty, EventuallyEq.refl _ _ ⟩ measurableSet_compl := fun s ⟨t, ht, hts⟩ => ⟨tᶜ, ht.compl, hts.compl⟩ measurableSet_iUnion s hs := by choose t ht hts using hs exact ⟨⋃ i, t i, MeasurableSet.iUnion ht, EventuallyEq.countable_iUnion hts⟩ def EventuallyMeasurableSet (s : Set α) : Prop := @MeasurableSet _ (EventuallyMeasurableSpace m l) s variable {l m} theorem MeasurableSet.eventuallyMeasurableSet (hs : MeasurableSet s) : EventuallyMeasurableSet m l s := ⟨s, hs, EventuallyEq.refl _ _⟩ theorem EventuallyMeasurableSpace.measurable_le : m ≤ EventuallyMeasurableSpace m l := fun _ hs => hs.eventuallyMeasurableSet theorem eventuallyMeasurableSet_of_mem_filter (hs : s ∈ l) : EventuallyMeasurableSet m l s := ⟨univ, MeasurableSet.univ, eventuallyEq_univ.mpr hs⟩
Mathlib/MeasureTheory/Constructions/EventuallyMeasurable.lean
67
70
theorem EventuallyMeasurableSet.congr (ht : EventuallyMeasurableSet m l t) (hst : s =ᶠ[l] t) : EventuallyMeasurableSet m l s := by
rcases ht with ⟨t', ht', htt'⟩ exact ⟨t', ht', hst.trans htt'⟩
674
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section Factorial variable {m n : ℕ} @[simp] theorem factorial_zero : 0! = 1 := rfl #align nat.factorial_zero Nat.factorial_zero theorem factorial_succ (n : ℕ) : (n + 1)! = (n + 1) * n ! := rfl #align nat.factorial_succ Nat.factorial_succ @[simp] theorem factorial_one : 1! = 1 := rfl #align nat.factorial_one Nat.factorial_one @[simp] theorem factorial_two : 2! = 2 := rfl #align nat.factorial_two Nat.factorial_two theorem mul_factorial_pred (hn : 0 < n) : n * (n - 1)! = n ! := Nat.sub_add_cancel (Nat.succ_le_of_lt hn) ▸ rfl #align nat.mul_factorial_pred Nat.mul_factorial_pred theorem factorial_pos : ∀ n, 0 < n ! | 0 => Nat.zero_lt_one | succ n => Nat.mul_pos (succ_pos _) (factorial_pos n) #align nat.factorial_pos Nat.factorial_pos theorem factorial_ne_zero (n : ℕ) : n ! ≠ 0 := ne_of_gt (factorial_pos _) #align nat.factorial_ne_zero Nat.factorial_ne_zero
Mathlib/Data/Nat/Factorial/Basic.lean
73
76
theorem factorial_dvd_factorial {m n} (h : m ≤ n) : m ! ∣ n ! := by
induction' h with n _ ih · exact Nat.dvd_refl _ · exact Nat.dvd_trans ih (Nat.dvd_mul_left _ _)
675
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section Factorial variable {m n : ℕ} @[simp] theorem factorial_zero : 0! = 1 := rfl #align nat.factorial_zero Nat.factorial_zero theorem factorial_succ (n : ℕ) : (n + 1)! = (n + 1) * n ! := rfl #align nat.factorial_succ Nat.factorial_succ @[simp] theorem factorial_one : 1! = 1 := rfl #align nat.factorial_one Nat.factorial_one @[simp] theorem factorial_two : 2! = 2 := rfl #align nat.factorial_two Nat.factorial_two theorem mul_factorial_pred (hn : 0 < n) : n * (n - 1)! = n ! := Nat.sub_add_cancel (Nat.succ_le_of_lt hn) ▸ rfl #align nat.mul_factorial_pred Nat.mul_factorial_pred theorem factorial_pos : ∀ n, 0 < n ! | 0 => Nat.zero_lt_one | succ n => Nat.mul_pos (succ_pos _) (factorial_pos n) #align nat.factorial_pos Nat.factorial_pos theorem factorial_ne_zero (n : ℕ) : n ! ≠ 0 := ne_of_gt (factorial_pos _) #align nat.factorial_ne_zero Nat.factorial_ne_zero theorem factorial_dvd_factorial {m n} (h : m ≤ n) : m ! ∣ n ! := by induction' h with n _ ih · exact Nat.dvd_refl _ · exact Nat.dvd_trans ih (Nat.dvd_mul_left _ _) #align nat.factorial_dvd_factorial Nat.factorial_dvd_factorial theorem dvd_factorial : ∀ {m n}, 0 < m → m ≤ n → m ∣ n ! | succ _, _, _, h => Nat.dvd_trans (Nat.dvd_mul_right _ _) (factorial_dvd_factorial h) #align nat.dvd_factorial Nat.dvd_factorial @[mono, gcongr] theorem factorial_le {m n} (h : m ≤ n) : m ! ≤ n ! := le_of_dvd (factorial_pos _) (factorial_dvd_factorial h) #align nat.factorial_le Nat.factorial_le theorem factorial_mul_pow_le_factorial : ∀ {m n : ℕ}, m ! * (m + 1) ^ n ≤ (m + n)! | m, 0 => by simp | m, n + 1 => by rw [← Nat.add_assoc, factorial_succ, Nat.mul_comm (_ + 1), Nat.pow_succ, ← Nat.mul_assoc] exact Nat.mul_le_mul factorial_mul_pow_le_factorial (succ_le_succ (le_add_right _ _)) #align nat.factorial_mul_pow_le_factorial Nat.factorial_mul_pow_le_factorial
Mathlib/Data/Nat/Factorial/Basic.lean
95
103
theorem factorial_lt (hn : 0 < n) : n ! < m ! ↔ n < m := by
refine ⟨fun h => not_le.mp fun hmn => Nat.not_le_of_lt h (factorial_le hmn), fun h => ?_⟩ have : ∀ {n}, 0 < n → n ! < (n + 1)! := by intro k hk rw [factorial_succ, succ_mul, Nat.lt_add_left_iff_pos] exact Nat.mul_pos hk k.factorial_pos induction' h with k hnk ih generalizing hn · exact this hn · exact lt_trans (ih hn) $ this <| lt_trans hn <| lt_of_succ_le hnk
675
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section Factorial variable {m n : ℕ} @[simp] theorem factorial_zero : 0! = 1 := rfl #align nat.factorial_zero Nat.factorial_zero theorem factorial_succ (n : ℕ) : (n + 1)! = (n + 1) * n ! := rfl #align nat.factorial_succ Nat.factorial_succ @[simp] theorem factorial_one : 1! = 1 := rfl #align nat.factorial_one Nat.factorial_one @[simp] theorem factorial_two : 2! = 2 := rfl #align nat.factorial_two Nat.factorial_two theorem mul_factorial_pred (hn : 0 < n) : n * (n - 1)! = n ! := Nat.sub_add_cancel (Nat.succ_le_of_lt hn) ▸ rfl #align nat.mul_factorial_pred Nat.mul_factorial_pred theorem factorial_pos : ∀ n, 0 < n ! | 0 => Nat.zero_lt_one | succ n => Nat.mul_pos (succ_pos _) (factorial_pos n) #align nat.factorial_pos Nat.factorial_pos theorem factorial_ne_zero (n : ℕ) : n ! ≠ 0 := ne_of_gt (factorial_pos _) #align nat.factorial_ne_zero Nat.factorial_ne_zero theorem factorial_dvd_factorial {m n} (h : m ≤ n) : m ! ∣ n ! := by induction' h with n _ ih · exact Nat.dvd_refl _ · exact Nat.dvd_trans ih (Nat.dvd_mul_left _ _) #align nat.factorial_dvd_factorial Nat.factorial_dvd_factorial theorem dvd_factorial : ∀ {m n}, 0 < m → m ≤ n → m ∣ n ! | succ _, _, _, h => Nat.dvd_trans (Nat.dvd_mul_right _ _) (factorial_dvd_factorial h) #align nat.dvd_factorial Nat.dvd_factorial @[mono, gcongr] theorem factorial_le {m n} (h : m ≤ n) : m ! ≤ n ! := le_of_dvd (factorial_pos _) (factorial_dvd_factorial h) #align nat.factorial_le Nat.factorial_le theorem factorial_mul_pow_le_factorial : ∀ {m n : ℕ}, m ! * (m + 1) ^ n ≤ (m + n)! | m, 0 => by simp | m, n + 1 => by rw [← Nat.add_assoc, factorial_succ, Nat.mul_comm (_ + 1), Nat.pow_succ, ← Nat.mul_assoc] exact Nat.mul_le_mul factorial_mul_pow_le_factorial (succ_le_succ (le_add_right _ _)) #align nat.factorial_mul_pow_le_factorial Nat.factorial_mul_pow_le_factorial theorem factorial_lt (hn : 0 < n) : n ! < m ! ↔ n < m := by refine ⟨fun h => not_le.mp fun hmn => Nat.not_le_of_lt h (factorial_le hmn), fun h => ?_⟩ have : ∀ {n}, 0 < n → n ! < (n + 1)! := by intro k hk rw [factorial_succ, succ_mul, Nat.lt_add_left_iff_pos] exact Nat.mul_pos hk k.factorial_pos induction' h with k hnk ih generalizing hn · exact this hn · exact lt_trans (ih hn) $ this <| lt_trans hn <| lt_of_succ_le hnk #align nat.factorial_lt Nat.factorial_lt @[gcongr] lemma factorial_lt_of_lt {m n : ℕ} (hn : 0 < n) (h : n < m) : n ! < m ! := (factorial_lt hn).mpr h @[simp] lemma one_lt_factorial : 1 < n ! ↔ 1 < n := factorial_lt Nat.one_pos #align nat.one_lt_factorial Nat.one_lt_factorial @[simp]
Mathlib/Data/Nat/Factorial/Basic.lean
113
118
theorem factorial_eq_one : n ! = 1 ↔ n ≤ 1 := by
constructor · intro h rw [← not_lt, ← one_lt_factorial, h] apply lt_irrefl · rintro (_|_|_) <;> rfl
675
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section Factorial variable {m n : ℕ} @[simp] theorem factorial_zero : 0! = 1 := rfl #align nat.factorial_zero Nat.factorial_zero theorem factorial_succ (n : ℕ) : (n + 1)! = (n + 1) * n ! := rfl #align nat.factorial_succ Nat.factorial_succ @[simp] theorem factorial_one : 1! = 1 := rfl #align nat.factorial_one Nat.factorial_one @[simp] theorem factorial_two : 2! = 2 := rfl #align nat.factorial_two Nat.factorial_two theorem mul_factorial_pred (hn : 0 < n) : n * (n - 1)! = n ! := Nat.sub_add_cancel (Nat.succ_le_of_lt hn) ▸ rfl #align nat.mul_factorial_pred Nat.mul_factorial_pred theorem factorial_pos : ∀ n, 0 < n ! | 0 => Nat.zero_lt_one | succ n => Nat.mul_pos (succ_pos _) (factorial_pos n) #align nat.factorial_pos Nat.factorial_pos theorem factorial_ne_zero (n : ℕ) : n ! ≠ 0 := ne_of_gt (factorial_pos _) #align nat.factorial_ne_zero Nat.factorial_ne_zero theorem factorial_dvd_factorial {m n} (h : m ≤ n) : m ! ∣ n ! := by induction' h with n _ ih · exact Nat.dvd_refl _ · exact Nat.dvd_trans ih (Nat.dvd_mul_left _ _) #align nat.factorial_dvd_factorial Nat.factorial_dvd_factorial theorem dvd_factorial : ∀ {m n}, 0 < m → m ≤ n → m ∣ n ! | succ _, _, _, h => Nat.dvd_trans (Nat.dvd_mul_right _ _) (factorial_dvd_factorial h) #align nat.dvd_factorial Nat.dvd_factorial @[mono, gcongr] theorem factorial_le {m n} (h : m ≤ n) : m ! ≤ n ! := le_of_dvd (factorial_pos _) (factorial_dvd_factorial h) #align nat.factorial_le Nat.factorial_le theorem factorial_mul_pow_le_factorial : ∀ {m n : ℕ}, m ! * (m + 1) ^ n ≤ (m + n)! | m, 0 => by simp | m, n + 1 => by rw [← Nat.add_assoc, factorial_succ, Nat.mul_comm (_ + 1), Nat.pow_succ, ← Nat.mul_assoc] exact Nat.mul_le_mul factorial_mul_pow_le_factorial (succ_le_succ (le_add_right _ _)) #align nat.factorial_mul_pow_le_factorial Nat.factorial_mul_pow_le_factorial theorem factorial_lt (hn : 0 < n) : n ! < m ! ↔ n < m := by refine ⟨fun h => not_le.mp fun hmn => Nat.not_le_of_lt h (factorial_le hmn), fun h => ?_⟩ have : ∀ {n}, 0 < n → n ! < (n + 1)! := by intro k hk rw [factorial_succ, succ_mul, Nat.lt_add_left_iff_pos] exact Nat.mul_pos hk k.factorial_pos induction' h with k hnk ih generalizing hn · exact this hn · exact lt_trans (ih hn) $ this <| lt_trans hn <| lt_of_succ_le hnk #align nat.factorial_lt Nat.factorial_lt @[gcongr] lemma factorial_lt_of_lt {m n : ℕ} (hn : 0 < n) (h : n < m) : n ! < m ! := (factorial_lt hn).mpr h @[simp] lemma one_lt_factorial : 1 < n ! ↔ 1 < n := factorial_lt Nat.one_pos #align nat.one_lt_factorial Nat.one_lt_factorial @[simp] theorem factorial_eq_one : n ! = 1 ↔ n ≤ 1 := by constructor · intro h rw [← not_lt, ← one_lt_factorial, h] apply lt_irrefl · rintro (_|_|_) <;> rfl #align nat.factorial_eq_one Nat.factorial_eq_one
Mathlib/Data/Nat/Factorial/Basic.lean
121
129
theorem factorial_inj (hn : 1 < n) : n ! = m ! ↔ n = m := by
refine ⟨fun h => ?_, congr_arg _⟩ obtain hnm | rfl | hnm := lt_trichotomy n m · rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm · rfl rw [← one_lt_factorial, h, one_lt_factorial] at hn rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm
675
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section Factorial variable {m n : ℕ} @[simp] theorem factorial_zero : 0! = 1 := rfl #align nat.factorial_zero Nat.factorial_zero theorem factorial_succ (n : ℕ) : (n + 1)! = (n + 1) * n ! := rfl #align nat.factorial_succ Nat.factorial_succ @[simp] theorem factorial_one : 1! = 1 := rfl #align nat.factorial_one Nat.factorial_one @[simp] theorem factorial_two : 2! = 2 := rfl #align nat.factorial_two Nat.factorial_two theorem mul_factorial_pred (hn : 0 < n) : n * (n - 1)! = n ! := Nat.sub_add_cancel (Nat.succ_le_of_lt hn) ▸ rfl #align nat.mul_factorial_pred Nat.mul_factorial_pred theorem factorial_pos : ∀ n, 0 < n ! | 0 => Nat.zero_lt_one | succ n => Nat.mul_pos (succ_pos _) (factorial_pos n) #align nat.factorial_pos Nat.factorial_pos theorem factorial_ne_zero (n : ℕ) : n ! ≠ 0 := ne_of_gt (factorial_pos _) #align nat.factorial_ne_zero Nat.factorial_ne_zero theorem factorial_dvd_factorial {m n} (h : m ≤ n) : m ! ∣ n ! := by induction' h with n _ ih · exact Nat.dvd_refl _ · exact Nat.dvd_trans ih (Nat.dvd_mul_left _ _) #align nat.factorial_dvd_factorial Nat.factorial_dvd_factorial theorem dvd_factorial : ∀ {m n}, 0 < m → m ≤ n → m ∣ n ! | succ _, _, _, h => Nat.dvd_trans (Nat.dvd_mul_right _ _) (factorial_dvd_factorial h) #align nat.dvd_factorial Nat.dvd_factorial @[mono, gcongr] theorem factorial_le {m n} (h : m ≤ n) : m ! ≤ n ! := le_of_dvd (factorial_pos _) (factorial_dvd_factorial h) #align nat.factorial_le Nat.factorial_le theorem factorial_mul_pow_le_factorial : ∀ {m n : ℕ}, m ! * (m + 1) ^ n ≤ (m + n)! | m, 0 => by simp | m, n + 1 => by rw [← Nat.add_assoc, factorial_succ, Nat.mul_comm (_ + 1), Nat.pow_succ, ← Nat.mul_assoc] exact Nat.mul_le_mul factorial_mul_pow_le_factorial (succ_le_succ (le_add_right _ _)) #align nat.factorial_mul_pow_le_factorial Nat.factorial_mul_pow_le_factorial theorem factorial_lt (hn : 0 < n) : n ! < m ! ↔ n < m := by refine ⟨fun h => not_le.mp fun hmn => Nat.not_le_of_lt h (factorial_le hmn), fun h => ?_⟩ have : ∀ {n}, 0 < n → n ! < (n + 1)! := by intro k hk rw [factorial_succ, succ_mul, Nat.lt_add_left_iff_pos] exact Nat.mul_pos hk k.factorial_pos induction' h with k hnk ih generalizing hn · exact this hn · exact lt_trans (ih hn) $ this <| lt_trans hn <| lt_of_succ_le hnk #align nat.factorial_lt Nat.factorial_lt @[gcongr] lemma factorial_lt_of_lt {m n : ℕ} (hn : 0 < n) (h : n < m) : n ! < m ! := (factorial_lt hn).mpr h @[simp] lemma one_lt_factorial : 1 < n ! ↔ 1 < n := factorial_lt Nat.one_pos #align nat.one_lt_factorial Nat.one_lt_factorial @[simp] theorem factorial_eq_one : n ! = 1 ↔ n ≤ 1 := by constructor · intro h rw [← not_lt, ← one_lt_factorial, h] apply lt_irrefl · rintro (_|_|_) <;> rfl #align nat.factorial_eq_one Nat.factorial_eq_one theorem factorial_inj (hn : 1 < n) : n ! = m ! ↔ n = m := by refine ⟨fun h => ?_, congr_arg _⟩ obtain hnm | rfl | hnm := lt_trichotomy n m · rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm · rfl rw [← one_lt_factorial, h, one_lt_factorial] at hn rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm #align nat.factorial_inj Nat.factorial_inj
Mathlib/Data/Nat/Factorial/Basic.lean
132
135
theorem factorial_inj' (h : 1 < n ∨ 1 < m) : n ! = m ! ↔ n = m := by
obtain hn|hm := h · exact factorial_inj hn · rw [eq_comm, factorial_inj hm, eq_comm]
675
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section Factorial variable {m n : ℕ} @[simp] theorem factorial_zero : 0! = 1 := rfl #align nat.factorial_zero Nat.factorial_zero theorem factorial_succ (n : ℕ) : (n + 1)! = (n + 1) * n ! := rfl #align nat.factorial_succ Nat.factorial_succ @[simp] theorem factorial_one : 1! = 1 := rfl #align nat.factorial_one Nat.factorial_one @[simp] theorem factorial_two : 2! = 2 := rfl #align nat.factorial_two Nat.factorial_two theorem mul_factorial_pred (hn : 0 < n) : n * (n - 1)! = n ! := Nat.sub_add_cancel (Nat.succ_le_of_lt hn) ▸ rfl #align nat.mul_factorial_pred Nat.mul_factorial_pred theorem factorial_pos : ∀ n, 0 < n ! | 0 => Nat.zero_lt_one | succ n => Nat.mul_pos (succ_pos _) (factorial_pos n) #align nat.factorial_pos Nat.factorial_pos theorem factorial_ne_zero (n : ℕ) : n ! ≠ 0 := ne_of_gt (factorial_pos _) #align nat.factorial_ne_zero Nat.factorial_ne_zero theorem factorial_dvd_factorial {m n} (h : m ≤ n) : m ! ∣ n ! := by induction' h with n _ ih · exact Nat.dvd_refl _ · exact Nat.dvd_trans ih (Nat.dvd_mul_left _ _) #align nat.factorial_dvd_factorial Nat.factorial_dvd_factorial theorem dvd_factorial : ∀ {m n}, 0 < m → m ≤ n → m ∣ n ! | succ _, _, _, h => Nat.dvd_trans (Nat.dvd_mul_right _ _) (factorial_dvd_factorial h) #align nat.dvd_factorial Nat.dvd_factorial @[mono, gcongr] theorem factorial_le {m n} (h : m ≤ n) : m ! ≤ n ! := le_of_dvd (factorial_pos _) (factorial_dvd_factorial h) #align nat.factorial_le Nat.factorial_le theorem factorial_mul_pow_le_factorial : ∀ {m n : ℕ}, m ! * (m + 1) ^ n ≤ (m + n)! | m, 0 => by simp | m, n + 1 => by rw [← Nat.add_assoc, factorial_succ, Nat.mul_comm (_ + 1), Nat.pow_succ, ← Nat.mul_assoc] exact Nat.mul_le_mul factorial_mul_pow_le_factorial (succ_le_succ (le_add_right _ _)) #align nat.factorial_mul_pow_le_factorial Nat.factorial_mul_pow_le_factorial theorem factorial_lt (hn : 0 < n) : n ! < m ! ↔ n < m := by refine ⟨fun h => not_le.mp fun hmn => Nat.not_le_of_lt h (factorial_le hmn), fun h => ?_⟩ have : ∀ {n}, 0 < n → n ! < (n + 1)! := by intro k hk rw [factorial_succ, succ_mul, Nat.lt_add_left_iff_pos] exact Nat.mul_pos hk k.factorial_pos induction' h with k hnk ih generalizing hn · exact this hn · exact lt_trans (ih hn) $ this <| lt_trans hn <| lt_of_succ_le hnk #align nat.factorial_lt Nat.factorial_lt @[gcongr] lemma factorial_lt_of_lt {m n : ℕ} (hn : 0 < n) (h : n < m) : n ! < m ! := (factorial_lt hn).mpr h @[simp] lemma one_lt_factorial : 1 < n ! ↔ 1 < n := factorial_lt Nat.one_pos #align nat.one_lt_factorial Nat.one_lt_factorial @[simp] theorem factorial_eq_one : n ! = 1 ↔ n ≤ 1 := by constructor · intro h rw [← not_lt, ← one_lt_factorial, h] apply lt_irrefl · rintro (_|_|_) <;> rfl #align nat.factorial_eq_one Nat.factorial_eq_one theorem factorial_inj (hn : 1 < n) : n ! = m ! ↔ n = m := by refine ⟨fun h => ?_, congr_arg _⟩ obtain hnm | rfl | hnm := lt_trichotomy n m · rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm · rfl rw [← one_lt_factorial, h, one_lt_factorial] at hn rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm #align nat.factorial_inj Nat.factorial_inj theorem factorial_inj' (h : 1 < n ∨ 1 < m) : n ! = m ! ↔ n = m := by obtain hn|hm := h · exact factorial_inj hn · rw [eq_comm, factorial_inj hm, eq_comm] theorem self_le_factorial : ∀ n : ℕ, n ≤ n ! | 0 => Nat.zero_le _ | k + 1 => Nat.le_mul_of_pos_right _ (Nat.one_le_of_lt k.factorial_pos) #align nat.self_le_factorial Nat.self_le_factorial
Mathlib/Data/Nat/Factorial/Basic.lean
142
147
theorem lt_factorial_self {n : ℕ} (hi : 3 ≤ n) : n < n ! := by
have : 0 < n := by omega have hn : 1 < pred n := le_pred_of_lt (succ_le_iff.mp hi) rw [← succ_pred_eq_of_pos ‹0 < n›, factorial_succ] exact (Nat.lt_mul_iff_one_lt_right (pred n).succ_pos).2 ((Nat.lt_of_lt_of_le hn (self_le_factorial _)))
675
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section Factorial variable {m n : ℕ} @[simp] theorem factorial_zero : 0! = 1 := rfl #align nat.factorial_zero Nat.factorial_zero theorem factorial_succ (n : ℕ) : (n + 1)! = (n + 1) * n ! := rfl #align nat.factorial_succ Nat.factorial_succ @[simp] theorem factorial_one : 1! = 1 := rfl #align nat.factorial_one Nat.factorial_one @[simp] theorem factorial_two : 2! = 2 := rfl #align nat.factorial_two Nat.factorial_two theorem mul_factorial_pred (hn : 0 < n) : n * (n - 1)! = n ! := Nat.sub_add_cancel (Nat.succ_le_of_lt hn) ▸ rfl #align nat.mul_factorial_pred Nat.mul_factorial_pred theorem factorial_pos : ∀ n, 0 < n ! | 0 => Nat.zero_lt_one | succ n => Nat.mul_pos (succ_pos _) (factorial_pos n) #align nat.factorial_pos Nat.factorial_pos theorem factorial_ne_zero (n : ℕ) : n ! ≠ 0 := ne_of_gt (factorial_pos _) #align nat.factorial_ne_zero Nat.factorial_ne_zero theorem factorial_dvd_factorial {m n} (h : m ≤ n) : m ! ∣ n ! := by induction' h with n _ ih · exact Nat.dvd_refl _ · exact Nat.dvd_trans ih (Nat.dvd_mul_left _ _) #align nat.factorial_dvd_factorial Nat.factorial_dvd_factorial theorem dvd_factorial : ∀ {m n}, 0 < m → m ≤ n → m ∣ n ! | succ _, _, _, h => Nat.dvd_trans (Nat.dvd_mul_right _ _) (factorial_dvd_factorial h) #align nat.dvd_factorial Nat.dvd_factorial @[mono, gcongr] theorem factorial_le {m n} (h : m ≤ n) : m ! ≤ n ! := le_of_dvd (factorial_pos _) (factorial_dvd_factorial h) #align nat.factorial_le Nat.factorial_le theorem factorial_mul_pow_le_factorial : ∀ {m n : ℕ}, m ! * (m + 1) ^ n ≤ (m + n)! | m, 0 => by simp | m, n + 1 => by rw [← Nat.add_assoc, factorial_succ, Nat.mul_comm (_ + 1), Nat.pow_succ, ← Nat.mul_assoc] exact Nat.mul_le_mul factorial_mul_pow_le_factorial (succ_le_succ (le_add_right _ _)) #align nat.factorial_mul_pow_le_factorial Nat.factorial_mul_pow_le_factorial theorem factorial_lt (hn : 0 < n) : n ! < m ! ↔ n < m := by refine ⟨fun h => not_le.mp fun hmn => Nat.not_le_of_lt h (factorial_le hmn), fun h => ?_⟩ have : ∀ {n}, 0 < n → n ! < (n + 1)! := by intro k hk rw [factorial_succ, succ_mul, Nat.lt_add_left_iff_pos] exact Nat.mul_pos hk k.factorial_pos induction' h with k hnk ih generalizing hn · exact this hn · exact lt_trans (ih hn) $ this <| lt_trans hn <| lt_of_succ_le hnk #align nat.factorial_lt Nat.factorial_lt @[gcongr] lemma factorial_lt_of_lt {m n : ℕ} (hn : 0 < n) (h : n < m) : n ! < m ! := (factorial_lt hn).mpr h @[simp] lemma one_lt_factorial : 1 < n ! ↔ 1 < n := factorial_lt Nat.one_pos #align nat.one_lt_factorial Nat.one_lt_factorial @[simp] theorem factorial_eq_one : n ! = 1 ↔ n ≤ 1 := by constructor · intro h rw [← not_lt, ← one_lt_factorial, h] apply lt_irrefl · rintro (_|_|_) <;> rfl #align nat.factorial_eq_one Nat.factorial_eq_one theorem factorial_inj (hn : 1 < n) : n ! = m ! ↔ n = m := by refine ⟨fun h => ?_, congr_arg _⟩ obtain hnm | rfl | hnm := lt_trichotomy n m · rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm · rfl rw [← one_lt_factorial, h, one_lt_factorial] at hn rw [← factorial_lt <| lt_of_succ_lt hn, h] at hnm cases lt_irrefl _ hnm #align nat.factorial_inj Nat.factorial_inj theorem factorial_inj' (h : 1 < n ∨ 1 < m) : n ! = m ! ↔ n = m := by obtain hn|hm := h · exact factorial_inj hn · rw [eq_comm, factorial_inj hm, eq_comm] theorem self_le_factorial : ∀ n : ℕ, n ≤ n ! | 0 => Nat.zero_le _ | k + 1 => Nat.le_mul_of_pos_right _ (Nat.one_le_of_lt k.factorial_pos) #align nat.self_le_factorial Nat.self_le_factorial theorem lt_factorial_self {n : ℕ} (hi : 3 ≤ n) : n < n ! := by have : 0 < n := by omega have hn : 1 < pred n := le_pred_of_lt (succ_le_iff.mp hi) rw [← succ_pred_eq_of_pos ‹0 < n›, factorial_succ] exact (Nat.lt_mul_iff_one_lt_right (pred n).succ_pos).2 ((Nat.lt_of_lt_of_le hn (self_le_factorial _))) #align nat.lt_factorial_self Nat.lt_factorial_self
Mathlib/Data/Nat/Factorial/Basic.lean
150
155
theorem add_factorial_succ_lt_factorial_add_succ {i : ℕ} (n : ℕ) (hi : 2 ≤ i) : i + (n + 1)! < (i + n + 1)! := by
rw [factorial_succ (i + _), Nat.add_mul, Nat.one_mul] have := (i + n).self_le_factorial refine Nat.add_lt_add_of_lt_of_le (Nat.lt_of_le_of_lt ?_ ((Nat.lt_mul_iff_one_lt_right ?_).2 ?_)) (factorial_le ?_) <;> omega
675
import Mathlib.Data.Nat.Defs import Mathlib.Tactic.GCongr.Core import Mathlib.Tactic.Common import Mathlib.Tactic.Monotonicity.Attr #align_import data.nat.factorial.basic from "leanprover-community/mathlib"@"d012cd09a9b256d870751284dd6a29882b0be105" namespace Nat def factorial : ℕ → ℕ | 0 => 1 | succ n => succ n * factorial n #align nat.factorial Nat.factorial scoped notation:10000 n "!" => Nat.factorial n section DescFactorial def descFactorial (n : ℕ) : ℕ → ℕ | 0 => 1 | k + 1 => (n - k) * descFactorial n k #align nat.desc_factorial Nat.descFactorial @[simp] theorem descFactorial_zero (n : ℕ) : n.descFactorial 0 = 1 := rfl #align nat.desc_factorial_zero Nat.descFactorial_zero @[simp] theorem descFactorial_succ (n k : ℕ) : n.descFactorial (k + 1) = (n - k) * n.descFactorial k := rfl #align nat.desc_factorial_succ Nat.descFactorial_succ
Mathlib/Data/Nat/Factorial/Basic.lean
340
341
theorem zero_descFactorial_succ (k : ℕ) : (0 : ℕ).descFactorial (k + 1) = 0 := by
rw [descFactorial_succ, Nat.zero_sub, Nat.zero_mul]
675