state
stringlengths 0
159k
| srcUpToTactic
stringlengths 387
167k
| nextTactic
stringlengths 3
9k
| declUpToTactic
stringlengths 22
11.5k
| declId
stringlengths 38
95
| decl
stringlengths 16
1.89k
| file_tag
stringlengths 17
73
|
---|---|---|---|---|---|---|
๐โ : Type u_1
instโโต : NontriviallyNormedField ๐โ
Eโ : Type u_2
instโโด : SeminormedAddCommGroup Eโ
instโยณ : NormedSpace ๐โ Eโ
๐ : Type u_3
E : Type u_4
instโยฒ : IsROrC ๐
instโยน : NormedAddCommGroup E
instโ : NormedSpace ๐ E
r : โ
hr : 0 < r
x' : Dual ๐ E
h : x' โ polar ๐ (closedBall 0 r)
โข โx'โ โค rโปยน
|
/-
Copyright (c) 2020 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.NormedSpace.HahnBanach.Extension
import Mathlib.Analysis.NormedSpace.IsROrC
import Mathlib.Analysis.LocallyConvex.Polar
#align_import analysis.normed_space.dual from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# The topological dual of a normed space
In this file we define the topological dual `NormedSpace.Dual` of a normed space, and the
continuous linear map `NormedSpace.inclusionInDoubleDual` from a normed space into its double
dual.
For base field `๐ = โ` or `๐ = โ`, this map is actually an isometric embedding; we provide a
version `NormedSpace.inclusionInDoubleDualLi` of the map which is of type a bundled linear
isometric embedding, `E โโแตข[๐] (Dual ๐ (Dual ๐ E))`.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `SeminormedAddCommGroup` and we specialize to `NormedAddCommGroup` when needed.
## Main definitions
* `inclusionInDoubleDual` and `inclusionInDoubleDualLi` are the inclusion of a normed space
in its double dual, considered as a bounded linear map and as a linear isometry, respectively.
* `polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals `x'` for which
`โx' zโ โค 1` for every `z โ s`.
## Tags
dual
-/
noncomputable section
open Classical Topology Bornology
universe u v
namespace NormedSpace
section General
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable (E : Type*) [SeminormedAddCommGroup E] [NormedSpace ๐ E]
variable (F : Type*) [NormedAddCommGroup F] [NormedSpace ๐ F]
/-- The topological dual of a seminormed space `E`. -/
abbrev Dual : Type _ := E โL[๐] ๐
#align normed_space.dual NormedSpace.Dual
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_eq until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : NormedSpace ๐ (Dual ๐ E) := inferInstance
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_le until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : SeminormedAddCommGroup (Dual ๐ E) := inferInstance
/-- The inclusion of a normed space in its double (topological) dual, considered
as a bounded linear map. -/
def inclusionInDoubleDual : E โL[๐] Dual ๐ (Dual ๐ E) :=
ContinuousLinearMap.apply ๐ ๐
#align normed_space.inclusion_in_double_dual NormedSpace.inclusionInDoubleDual
@[simp]
theorem dual_def (x : E) (f : Dual ๐ E) : inclusionInDoubleDual ๐ E x f = f x :=
rfl
#align normed_space.dual_def NormedSpace.dual_def
theorem inclusionInDoubleDual_norm_eq :
โinclusionInDoubleDual ๐ Eโ = โContinuousLinearMap.id ๐ (Dual ๐ E)โ :=
ContinuousLinearMap.op_norm_flip _
#align normed_space.inclusion_in_double_dual_norm_eq NormedSpace.inclusionInDoubleDual_norm_eq
theorem inclusionInDoubleDual_norm_le : โinclusionInDoubleDual ๐ Eโ โค 1 := by
rw [inclusionInDoubleDual_norm_eq]
exact ContinuousLinearMap.norm_id_le
#align normed_space.inclusion_in_double_dual_norm_le NormedSpace.inclusionInDoubleDual_norm_le
theorem double_dual_bound (x : E) : โ(inclusionInDoubleDual ๐ E) xโ โค โxโ := by
simpa using ContinuousLinearMap.le_of_op_norm_le _ (inclusionInDoubleDual_norm_le ๐ E) x
#align normed_space.double_dual_bound NormedSpace.double_dual_bound
/-- The dual pairing as a bilinear form. -/
def dualPairing : Dual ๐ E โโ[๐] E โโ[๐] ๐ :=
ContinuousLinearMap.coeLM ๐
#align normed_space.dual_pairing NormedSpace.dualPairing
@[simp]
theorem dualPairing_apply {v : Dual ๐ E} {x : E} : dualPairing ๐ E v x = v x :=
rfl
#align normed_space.dual_pairing_apply NormedSpace.dualPairing_apply
theorem dualPairing_separatingLeft : (dualPairing ๐ E).SeparatingLeft := by
rw [LinearMap.separatingLeft_iff_ker_eq_bot, LinearMap.ker_eq_bot]
exact ContinuousLinearMap.coe_injective
#align normed_space.dual_pairing_separating_left NormedSpace.dualPairing_separatingLeft
end General
section BidualIsometry
variable (๐ : Type v) [IsROrC ๐] {E : Type u} [NormedAddCommGroup E] [NormedSpace ๐ E]
/-- If one controls the norm of every `f x`, then one controls the norm of `x`.
Compare `ContinuousLinearMap.op_norm_le_bound`. -/
theorem norm_le_dual_bound (x : E) {M : โ} (hMp : 0 โค M) (hM : โ f : Dual ๐ E, โf xโ โค M * โfโ) :
โxโ โค M := by
classical
by_cases h : x = 0
ยท simp only [h, hMp, norm_zero]
ยท obtain โจf, hfโ, hfxโฉ : โ f : E โL[๐] ๐, โfโ = 1 โง f x = โxโ := exists_dual_vector ๐ x h
calc
โxโ = โ(โxโ : ๐)โ := IsROrC.norm_coe_norm.symm
_ = โf xโ := by rw [hfx]
_ โค M * โfโ := (hM f)
_ = M := by rw [hfโ, mul_one]
#align normed_space.norm_le_dual_bound NormedSpace.norm_le_dual_bound
theorem eq_zero_of_forall_dual_eq_zero {x : E} (h : โ f : Dual ๐ E, f x = (0 : ๐)) : x = 0 :=
norm_le_zero_iff.mp (norm_le_dual_bound ๐ x le_rfl fun f => by simp [h f])
#align normed_space.eq_zero_of_forall_dual_eq_zero NormedSpace.eq_zero_of_forall_dual_eq_zero
theorem eq_zero_iff_forall_dual_eq_zero (x : E) : x = 0 โ โ g : Dual ๐ E, g x = 0 :=
โจfun hx => by simp [hx], fun h => eq_zero_of_forall_dual_eq_zero ๐ hโฉ
#align normed_space.eq_zero_iff_forall_dual_eq_zero NormedSpace.eq_zero_iff_forall_dual_eq_zero
/-- See also `geometric_hahn_banach_point_point`. -/
theorem eq_iff_forall_dual_eq {x y : E} : x = y โ โ g : Dual ๐ E, g x = g y := by
rw [โ sub_eq_zero, eq_zero_iff_forall_dual_eq_zero ๐ (x - y)]
simp [sub_eq_zero]
#align normed_space.eq_iff_forall_dual_eq NormedSpace.eq_iff_forall_dual_eq
/-- The inclusion of a normed space in its double dual is an isometry onto its image.-/
def inclusionInDoubleDualLi : E โโแตข[๐] Dual ๐ (Dual ๐ E) :=
{ inclusionInDoubleDual ๐ E with
norm_map' := by
intro x
apply le_antisymm
ยท exact double_dual_bound ๐ E x
rw [ContinuousLinearMap.norm_def]
refine' le_csInf ContinuousLinearMap.bounds_nonempty _
rintro c โจhc1, hc2โฉ
exact norm_le_dual_bound ๐ x hc1 hc2 }
#align normed_space.inclusion_in_double_dual_li NormedSpace.inclusionInDoubleDualLi
end BidualIsometry
section PolarSets
open Metric Set NormedSpace
/-- Given a subset `s` in a normed space `E` (over a field `๐`), the polar
`polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals which
evaluate to something of norm at most one at all points `z โ s`. -/
def polar (๐ : Type*) [NontriviallyNormedField ๐] {E : Type*} [SeminormedAddCommGroup E]
[NormedSpace ๐ E] : Set E โ Set (Dual ๐ E) :=
(dualPairing ๐ E).flip.polar
#align normed_space.polar NormedSpace.polar
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ๐ E]
theorem mem_polar_iff {x' : Dual ๐ E} (s : Set E) : x' โ polar ๐ s โ โ z โ s, โx' zโ โค 1 :=
Iff.rfl
#align normed_space.mem_polar_iff NormedSpace.mem_polar_iff
@[simp]
theorem polar_univ : polar ๐ (univ : Set E) = {(0 : Dual ๐ E)} :=
(dualPairing ๐ E).flip.polar_univ
(LinearMap.flip_separatingRight.mpr (dualPairing_separatingLeft ๐ E))
#align normed_space.polar_univ NormedSpace.polar_univ
theorem isClosed_polar (s : Set E) : IsClosed (polar ๐ s) := by
dsimp only [NormedSpace.polar]
simp only [LinearMap.polar_eq_iInter, LinearMap.flip_apply]
refine' isClosed_biInter fun z _ => _
exact isClosed_Iic.preimage (ContinuousLinearMap.apply ๐ ๐ z).continuous.norm
#align normed_space.is_closed_polar NormedSpace.isClosed_polar
@[simp]
theorem polar_closure (s : Set E) : polar ๐ (closure s) = polar ๐ s :=
((dualPairing ๐ E).flip.polar_antitone subset_closure).antisymm <|
(dualPairing ๐ E).flip.polar_gc.l_le <|
closure_minimal ((dualPairing ๐ E).flip.polar_gc.le_u_l s) <| by
simpa [LinearMap.flip_flip] using
(isClosed_polar _ _).preimage (inclusionInDoubleDual ๐ E).continuous
#align normed_space.polar_closure NormedSpace.polar_closure
variable {๐}
/-- If `x'` is a dual element such that the norms `โx' zโ` are bounded for `z โ s`, then a
small scalar multiple of `x'` is in `polar ๐ s`. -/
theorem smul_mem_polar {s : Set E} {x' : Dual ๐ E} {c : ๐} (hc : โ z, z โ s โ โx' zโ โค โcโ) :
cโปยน โข x' โ polar ๐ s := by
by_cases c_zero : c = 0
ยท simp only [c_zero, inv_zero, zero_smul]
exact (dualPairing ๐ E).flip.zero_mem_polar _
have eq : โ z, โcโปยน โข x' zโ = โcโปยนโ * โx' zโ := fun z => norm_smul cโปยน _
have le : โ z, z โ s โ โcโปยน โข x' zโ โค โcโปยนโ * โcโ := by
intro z hzs
rw [eq z]
apply mul_le_mul (le_of_eq rfl) (hc z hzs) (norm_nonneg _) (norm_nonneg _)
have cancel : โcโปยนโ * โcโ = 1 := by
simp only [c_zero, norm_eq_zero, Ne.def, not_false_iff, inv_mul_cancel, norm_inv]
rwa [cancel] at le
#align normed_space.smul_mem_polar NormedSpace.smul_mem_polar
theorem polar_ball_subset_closedBall_div {c : ๐} (hc : 1 < โcโ) {r : โ} (hr : 0 < r) :
polar ๐ (ball (0 : E) r) โ closedBall (0 : Dual ๐ E) (โcโ / r) := by
intro x' hx'
rw [mem_polar_iff] at hx'
simp only [polar, mem_setOf, mem_closedBall_zero_iff, mem_ball_zero_iff] at *
have hcr : 0 < โcโ / r := div_pos (zero_lt_one.trans hc) hr
refine' ContinuousLinearMap.op_norm_le_of_shell hr hcr.le hc fun x hโ hโ => _
calc
โx' xโ โค 1 := hx' _ hโ
_ โค โcโ / r * โxโ := (inv_pos_le_iff_one_le_mul' hcr).1 (by rwa [inv_div])
#align normed_space.polar_ball_subset_closed_ball_div NormedSpace.polar_ball_subset_closedBall_div
variable (๐)
theorem closedBall_inv_subset_polar_closedBall {r : โ} :
closedBall (0 : Dual ๐ E) rโปยน โ polar ๐ (closedBall (0 : E) r) := fun x' hx' x hx =>
calc
โx' xโ โค โx'โ * โxโ := x'.le_op_norm x
_ โค rโปยน * r :=
(mul_le_mul (mem_closedBall_zero_iff.1 hx') (mem_closedBall_zero_iff.1 hx) (norm_nonneg _)
(dist_nonneg.trans hx'))
_ = r / r := (inv_mul_eq_div _ _)
_ โค 1 := div_self_le_one r
#align normed_space.closed_ball_inv_subset_polar_closed_ball NormedSpace.closedBall_inv_subset_polar_closedBall
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน := by
refine' Subset.antisymm _ (closedBall_inv_subset_polar_closedBall ๐)
intro x' h
simp only [mem_closedBall_zero_iff]
|
refine' ContinuousLinearMap.op_norm_le_of_ball hr (inv_nonneg.mpr hr.le) fun z _ => _
|
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน := by
refine' Subset.antisymm _ (closedBall_inv_subset_polar_closedBall ๐)
intro x' h
simp only [mem_closedBall_zero_iff]
|
Mathlib.Analysis.NormedSpace.Dual.243_0.WirVfj6f5oiZZ2w
|
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน
|
Mathlib_Analysis_NormedSpace_Dual
|
๐โ : Type u_1
instโโต : NontriviallyNormedField ๐โ
Eโ : Type u_2
instโโด : SeminormedAddCommGroup Eโ
instโยณ : NormedSpace ๐โ Eโ
๐ : Type u_3
E : Type u_4
instโยฒ : IsROrC ๐
instโยน : NormedAddCommGroup E
instโ : NormedSpace ๐ E
r : โ
hr : 0 < r
x' : Dual ๐ E
h : x' โ polar ๐ (closedBall 0 r)
z : E
xโ : z โ ball 0 r
โข โx' zโ โค rโปยน * โzโ
|
/-
Copyright (c) 2020 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.NormedSpace.HahnBanach.Extension
import Mathlib.Analysis.NormedSpace.IsROrC
import Mathlib.Analysis.LocallyConvex.Polar
#align_import analysis.normed_space.dual from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# The topological dual of a normed space
In this file we define the topological dual `NormedSpace.Dual` of a normed space, and the
continuous linear map `NormedSpace.inclusionInDoubleDual` from a normed space into its double
dual.
For base field `๐ = โ` or `๐ = โ`, this map is actually an isometric embedding; we provide a
version `NormedSpace.inclusionInDoubleDualLi` of the map which is of type a bundled linear
isometric embedding, `E โโแตข[๐] (Dual ๐ (Dual ๐ E))`.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `SeminormedAddCommGroup` and we specialize to `NormedAddCommGroup` when needed.
## Main definitions
* `inclusionInDoubleDual` and `inclusionInDoubleDualLi` are the inclusion of a normed space
in its double dual, considered as a bounded linear map and as a linear isometry, respectively.
* `polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals `x'` for which
`โx' zโ โค 1` for every `z โ s`.
## Tags
dual
-/
noncomputable section
open Classical Topology Bornology
universe u v
namespace NormedSpace
section General
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable (E : Type*) [SeminormedAddCommGroup E] [NormedSpace ๐ E]
variable (F : Type*) [NormedAddCommGroup F] [NormedSpace ๐ F]
/-- The topological dual of a seminormed space `E`. -/
abbrev Dual : Type _ := E โL[๐] ๐
#align normed_space.dual NormedSpace.Dual
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_eq until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : NormedSpace ๐ (Dual ๐ E) := inferInstance
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_le until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : SeminormedAddCommGroup (Dual ๐ E) := inferInstance
/-- The inclusion of a normed space in its double (topological) dual, considered
as a bounded linear map. -/
def inclusionInDoubleDual : E โL[๐] Dual ๐ (Dual ๐ E) :=
ContinuousLinearMap.apply ๐ ๐
#align normed_space.inclusion_in_double_dual NormedSpace.inclusionInDoubleDual
@[simp]
theorem dual_def (x : E) (f : Dual ๐ E) : inclusionInDoubleDual ๐ E x f = f x :=
rfl
#align normed_space.dual_def NormedSpace.dual_def
theorem inclusionInDoubleDual_norm_eq :
โinclusionInDoubleDual ๐ Eโ = โContinuousLinearMap.id ๐ (Dual ๐ E)โ :=
ContinuousLinearMap.op_norm_flip _
#align normed_space.inclusion_in_double_dual_norm_eq NormedSpace.inclusionInDoubleDual_norm_eq
theorem inclusionInDoubleDual_norm_le : โinclusionInDoubleDual ๐ Eโ โค 1 := by
rw [inclusionInDoubleDual_norm_eq]
exact ContinuousLinearMap.norm_id_le
#align normed_space.inclusion_in_double_dual_norm_le NormedSpace.inclusionInDoubleDual_norm_le
theorem double_dual_bound (x : E) : โ(inclusionInDoubleDual ๐ E) xโ โค โxโ := by
simpa using ContinuousLinearMap.le_of_op_norm_le _ (inclusionInDoubleDual_norm_le ๐ E) x
#align normed_space.double_dual_bound NormedSpace.double_dual_bound
/-- The dual pairing as a bilinear form. -/
def dualPairing : Dual ๐ E โโ[๐] E โโ[๐] ๐ :=
ContinuousLinearMap.coeLM ๐
#align normed_space.dual_pairing NormedSpace.dualPairing
@[simp]
theorem dualPairing_apply {v : Dual ๐ E} {x : E} : dualPairing ๐ E v x = v x :=
rfl
#align normed_space.dual_pairing_apply NormedSpace.dualPairing_apply
theorem dualPairing_separatingLeft : (dualPairing ๐ E).SeparatingLeft := by
rw [LinearMap.separatingLeft_iff_ker_eq_bot, LinearMap.ker_eq_bot]
exact ContinuousLinearMap.coe_injective
#align normed_space.dual_pairing_separating_left NormedSpace.dualPairing_separatingLeft
end General
section BidualIsometry
variable (๐ : Type v) [IsROrC ๐] {E : Type u} [NormedAddCommGroup E] [NormedSpace ๐ E]
/-- If one controls the norm of every `f x`, then one controls the norm of `x`.
Compare `ContinuousLinearMap.op_norm_le_bound`. -/
theorem norm_le_dual_bound (x : E) {M : โ} (hMp : 0 โค M) (hM : โ f : Dual ๐ E, โf xโ โค M * โfโ) :
โxโ โค M := by
classical
by_cases h : x = 0
ยท simp only [h, hMp, norm_zero]
ยท obtain โจf, hfโ, hfxโฉ : โ f : E โL[๐] ๐, โfโ = 1 โง f x = โxโ := exists_dual_vector ๐ x h
calc
โxโ = โ(โxโ : ๐)โ := IsROrC.norm_coe_norm.symm
_ = โf xโ := by rw [hfx]
_ โค M * โfโ := (hM f)
_ = M := by rw [hfโ, mul_one]
#align normed_space.norm_le_dual_bound NormedSpace.norm_le_dual_bound
theorem eq_zero_of_forall_dual_eq_zero {x : E} (h : โ f : Dual ๐ E, f x = (0 : ๐)) : x = 0 :=
norm_le_zero_iff.mp (norm_le_dual_bound ๐ x le_rfl fun f => by simp [h f])
#align normed_space.eq_zero_of_forall_dual_eq_zero NormedSpace.eq_zero_of_forall_dual_eq_zero
theorem eq_zero_iff_forall_dual_eq_zero (x : E) : x = 0 โ โ g : Dual ๐ E, g x = 0 :=
โจfun hx => by simp [hx], fun h => eq_zero_of_forall_dual_eq_zero ๐ hโฉ
#align normed_space.eq_zero_iff_forall_dual_eq_zero NormedSpace.eq_zero_iff_forall_dual_eq_zero
/-- See also `geometric_hahn_banach_point_point`. -/
theorem eq_iff_forall_dual_eq {x y : E} : x = y โ โ g : Dual ๐ E, g x = g y := by
rw [โ sub_eq_zero, eq_zero_iff_forall_dual_eq_zero ๐ (x - y)]
simp [sub_eq_zero]
#align normed_space.eq_iff_forall_dual_eq NormedSpace.eq_iff_forall_dual_eq
/-- The inclusion of a normed space in its double dual is an isometry onto its image.-/
def inclusionInDoubleDualLi : E โโแตข[๐] Dual ๐ (Dual ๐ E) :=
{ inclusionInDoubleDual ๐ E with
norm_map' := by
intro x
apply le_antisymm
ยท exact double_dual_bound ๐ E x
rw [ContinuousLinearMap.norm_def]
refine' le_csInf ContinuousLinearMap.bounds_nonempty _
rintro c โจhc1, hc2โฉ
exact norm_le_dual_bound ๐ x hc1 hc2 }
#align normed_space.inclusion_in_double_dual_li NormedSpace.inclusionInDoubleDualLi
end BidualIsometry
section PolarSets
open Metric Set NormedSpace
/-- Given a subset `s` in a normed space `E` (over a field `๐`), the polar
`polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals which
evaluate to something of norm at most one at all points `z โ s`. -/
def polar (๐ : Type*) [NontriviallyNormedField ๐] {E : Type*} [SeminormedAddCommGroup E]
[NormedSpace ๐ E] : Set E โ Set (Dual ๐ E) :=
(dualPairing ๐ E).flip.polar
#align normed_space.polar NormedSpace.polar
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ๐ E]
theorem mem_polar_iff {x' : Dual ๐ E} (s : Set E) : x' โ polar ๐ s โ โ z โ s, โx' zโ โค 1 :=
Iff.rfl
#align normed_space.mem_polar_iff NormedSpace.mem_polar_iff
@[simp]
theorem polar_univ : polar ๐ (univ : Set E) = {(0 : Dual ๐ E)} :=
(dualPairing ๐ E).flip.polar_univ
(LinearMap.flip_separatingRight.mpr (dualPairing_separatingLeft ๐ E))
#align normed_space.polar_univ NormedSpace.polar_univ
theorem isClosed_polar (s : Set E) : IsClosed (polar ๐ s) := by
dsimp only [NormedSpace.polar]
simp only [LinearMap.polar_eq_iInter, LinearMap.flip_apply]
refine' isClosed_biInter fun z _ => _
exact isClosed_Iic.preimage (ContinuousLinearMap.apply ๐ ๐ z).continuous.norm
#align normed_space.is_closed_polar NormedSpace.isClosed_polar
@[simp]
theorem polar_closure (s : Set E) : polar ๐ (closure s) = polar ๐ s :=
((dualPairing ๐ E).flip.polar_antitone subset_closure).antisymm <|
(dualPairing ๐ E).flip.polar_gc.l_le <|
closure_minimal ((dualPairing ๐ E).flip.polar_gc.le_u_l s) <| by
simpa [LinearMap.flip_flip] using
(isClosed_polar _ _).preimage (inclusionInDoubleDual ๐ E).continuous
#align normed_space.polar_closure NormedSpace.polar_closure
variable {๐}
/-- If `x'` is a dual element such that the norms `โx' zโ` are bounded for `z โ s`, then a
small scalar multiple of `x'` is in `polar ๐ s`. -/
theorem smul_mem_polar {s : Set E} {x' : Dual ๐ E} {c : ๐} (hc : โ z, z โ s โ โx' zโ โค โcโ) :
cโปยน โข x' โ polar ๐ s := by
by_cases c_zero : c = 0
ยท simp only [c_zero, inv_zero, zero_smul]
exact (dualPairing ๐ E).flip.zero_mem_polar _
have eq : โ z, โcโปยน โข x' zโ = โcโปยนโ * โx' zโ := fun z => norm_smul cโปยน _
have le : โ z, z โ s โ โcโปยน โข x' zโ โค โcโปยนโ * โcโ := by
intro z hzs
rw [eq z]
apply mul_le_mul (le_of_eq rfl) (hc z hzs) (norm_nonneg _) (norm_nonneg _)
have cancel : โcโปยนโ * โcโ = 1 := by
simp only [c_zero, norm_eq_zero, Ne.def, not_false_iff, inv_mul_cancel, norm_inv]
rwa [cancel] at le
#align normed_space.smul_mem_polar NormedSpace.smul_mem_polar
theorem polar_ball_subset_closedBall_div {c : ๐} (hc : 1 < โcโ) {r : โ} (hr : 0 < r) :
polar ๐ (ball (0 : E) r) โ closedBall (0 : Dual ๐ E) (โcโ / r) := by
intro x' hx'
rw [mem_polar_iff] at hx'
simp only [polar, mem_setOf, mem_closedBall_zero_iff, mem_ball_zero_iff] at *
have hcr : 0 < โcโ / r := div_pos (zero_lt_one.trans hc) hr
refine' ContinuousLinearMap.op_norm_le_of_shell hr hcr.le hc fun x hโ hโ => _
calc
โx' xโ โค 1 := hx' _ hโ
_ โค โcโ / r * โxโ := (inv_pos_le_iff_one_le_mul' hcr).1 (by rwa [inv_div])
#align normed_space.polar_ball_subset_closed_ball_div NormedSpace.polar_ball_subset_closedBall_div
variable (๐)
theorem closedBall_inv_subset_polar_closedBall {r : โ} :
closedBall (0 : Dual ๐ E) rโปยน โ polar ๐ (closedBall (0 : E) r) := fun x' hx' x hx =>
calc
โx' xโ โค โx'โ * โxโ := x'.le_op_norm x
_ โค rโปยน * r :=
(mul_le_mul (mem_closedBall_zero_iff.1 hx') (mem_closedBall_zero_iff.1 hx) (norm_nonneg _)
(dist_nonneg.trans hx'))
_ = r / r := (inv_mul_eq_div _ _)
_ โค 1 := div_self_le_one r
#align normed_space.closed_ball_inv_subset_polar_closed_ball NormedSpace.closedBall_inv_subset_polar_closedBall
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน := by
refine' Subset.antisymm _ (closedBall_inv_subset_polar_closedBall ๐)
intro x' h
simp only [mem_closedBall_zero_iff]
refine' ContinuousLinearMap.op_norm_le_of_ball hr (inv_nonneg.mpr hr.le) fun z _ => _
|
simpa only [one_div] using LinearMap.bound_of_ball_bound' hr 1 x'.toLinearMap h z
|
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน := by
refine' Subset.antisymm _ (closedBall_inv_subset_polar_closedBall ๐)
intro x' h
simp only [mem_closedBall_zero_iff]
refine' ContinuousLinearMap.op_norm_le_of_ball hr (inv_nonneg.mpr hr.le) fun z _ => _
|
Mathlib.Analysis.NormedSpace.Dual.243_0.WirVfj6f5oiZZ2w
|
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน
|
Mathlib_Analysis_NormedSpace_Dual
|
๐ : Type u_1
instโยฒ : NontriviallyNormedField ๐
E : Type u_2
instโยน : SeminormedAddCommGroup E
instโ : NormedSpace ๐ E
s : Set E
s_nhd : s โ ๐ 0
โข IsBounded (polar ๐ s)
|
/-
Copyright (c) 2020 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.NormedSpace.HahnBanach.Extension
import Mathlib.Analysis.NormedSpace.IsROrC
import Mathlib.Analysis.LocallyConvex.Polar
#align_import analysis.normed_space.dual from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# The topological dual of a normed space
In this file we define the topological dual `NormedSpace.Dual` of a normed space, and the
continuous linear map `NormedSpace.inclusionInDoubleDual` from a normed space into its double
dual.
For base field `๐ = โ` or `๐ = โ`, this map is actually an isometric embedding; we provide a
version `NormedSpace.inclusionInDoubleDualLi` of the map which is of type a bundled linear
isometric embedding, `E โโแตข[๐] (Dual ๐ (Dual ๐ E))`.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `SeminormedAddCommGroup` and we specialize to `NormedAddCommGroup` when needed.
## Main definitions
* `inclusionInDoubleDual` and `inclusionInDoubleDualLi` are the inclusion of a normed space
in its double dual, considered as a bounded linear map and as a linear isometry, respectively.
* `polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals `x'` for which
`โx' zโ โค 1` for every `z โ s`.
## Tags
dual
-/
noncomputable section
open Classical Topology Bornology
universe u v
namespace NormedSpace
section General
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable (E : Type*) [SeminormedAddCommGroup E] [NormedSpace ๐ E]
variable (F : Type*) [NormedAddCommGroup F] [NormedSpace ๐ F]
/-- The topological dual of a seminormed space `E`. -/
abbrev Dual : Type _ := E โL[๐] ๐
#align normed_space.dual NormedSpace.Dual
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_eq until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : NormedSpace ๐ (Dual ๐ E) := inferInstance
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_le until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : SeminormedAddCommGroup (Dual ๐ E) := inferInstance
/-- The inclusion of a normed space in its double (topological) dual, considered
as a bounded linear map. -/
def inclusionInDoubleDual : E โL[๐] Dual ๐ (Dual ๐ E) :=
ContinuousLinearMap.apply ๐ ๐
#align normed_space.inclusion_in_double_dual NormedSpace.inclusionInDoubleDual
@[simp]
theorem dual_def (x : E) (f : Dual ๐ E) : inclusionInDoubleDual ๐ E x f = f x :=
rfl
#align normed_space.dual_def NormedSpace.dual_def
theorem inclusionInDoubleDual_norm_eq :
โinclusionInDoubleDual ๐ Eโ = โContinuousLinearMap.id ๐ (Dual ๐ E)โ :=
ContinuousLinearMap.op_norm_flip _
#align normed_space.inclusion_in_double_dual_norm_eq NormedSpace.inclusionInDoubleDual_norm_eq
theorem inclusionInDoubleDual_norm_le : โinclusionInDoubleDual ๐ Eโ โค 1 := by
rw [inclusionInDoubleDual_norm_eq]
exact ContinuousLinearMap.norm_id_le
#align normed_space.inclusion_in_double_dual_norm_le NormedSpace.inclusionInDoubleDual_norm_le
theorem double_dual_bound (x : E) : โ(inclusionInDoubleDual ๐ E) xโ โค โxโ := by
simpa using ContinuousLinearMap.le_of_op_norm_le _ (inclusionInDoubleDual_norm_le ๐ E) x
#align normed_space.double_dual_bound NormedSpace.double_dual_bound
/-- The dual pairing as a bilinear form. -/
def dualPairing : Dual ๐ E โโ[๐] E โโ[๐] ๐ :=
ContinuousLinearMap.coeLM ๐
#align normed_space.dual_pairing NormedSpace.dualPairing
@[simp]
theorem dualPairing_apply {v : Dual ๐ E} {x : E} : dualPairing ๐ E v x = v x :=
rfl
#align normed_space.dual_pairing_apply NormedSpace.dualPairing_apply
theorem dualPairing_separatingLeft : (dualPairing ๐ E).SeparatingLeft := by
rw [LinearMap.separatingLeft_iff_ker_eq_bot, LinearMap.ker_eq_bot]
exact ContinuousLinearMap.coe_injective
#align normed_space.dual_pairing_separating_left NormedSpace.dualPairing_separatingLeft
end General
section BidualIsometry
variable (๐ : Type v) [IsROrC ๐] {E : Type u} [NormedAddCommGroup E] [NormedSpace ๐ E]
/-- If one controls the norm of every `f x`, then one controls the norm of `x`.
Compare `ContinuousLinearMap.op_norm_le_bound`. -/
theorem norm_le_dual_bound (x : E) {M : โ} (hMp : 0 โค M) (hM : โ f : Dual ๐ E, โf xโ โค M * โfโ) :
โxโ โค M := by
classical
by_cases h : x = 0
ยท simp only [h, hMp, norm_zero]
ยท obtain โจf, hfโ, hfxโฉ : โ f : E โL[๐] ๐, โfโ = 1 โง f x = โxโ := exists_dual_vector ๐ x h
calc
โxโ = โ(โxโ : ๐)โ := IsROrC.norm_coe_norm.symm
_ = โf xโ := by rw [hfx]
_ โค M * โfโ := (hM f)
_ = M := by rw [hfโ, mul_one]
#align normed_space.norm_le_dual_bound NormedSpace.norm_le_dual_bound
theorem eq_zero_of_forall_dual_eq_zero {x : E} (h : โ f : Dual ๐ E, f x = (0 : ๐)) : x = 0 :=
norm_le_zero_iff.mp (norm_le_dual_bound ๐ x le_rfl fun f => by simp [h f])
#align normed_space.eq_zero_of_forall_dual_eq_zero NormedSpace.eq_zero_of_forall_dual_eq_zero
theorem eq_zero_iff_forall_dual_eq_zero (x : E) : x = 0 โ โ g : Dual ๐ E, g x = 0 :=
โจfun hx => by simp [hx], fun h => eq_zero_of_forall_dual_eq_zero ๐ hโฉ
#align normed_space.eq_zero_iff_forall_dual_eq_zero NormedSpace.eq_zero_iff_forall_dual_eq_zero
/-- See also `geometric_hahn_banach_point_point`. -/
theorem eq_iff_forall_dual_eq {x y : E} : x = y โ โ g : Dual ๐ E, g x = g y := by
rw [โ sub_eq_zero, eq_zero_iff_forall_dual_eq_zero ๐ (x - y)]
simp [sub_eq_zero]
#align normed_space.eq_iff_forall_dual_eq NormedSpace.eq_iff_forall_dual_eq
/-- The inclusion of a normed space in its double dual is an isometry onto its image.-/
def inclusionInDoubleDualLi : E โโแตข[๐] Dual ๐ (Dual ๐ E) :=
{ inclusionInDoubleDual ๐ E with
norm_map' := by
intro x
apply le_antisymm
ยท exact double_dual_bound ๐ E x
rw [ContinuousLinearMap.norm_def]
refine' le_csInf ContinuousLinearMap.bounds_nonempty _
rintro c โจhc1, hc2โฉ
exact norm_le_dual_bound ๐ x hc1 hc2 }
#align normed_space.inclusion_in_double_dual_li NormedSpace.inclusionInDoubleDualLi
end BidualIsometry
section PolarSets
open Metric Set NormedSpace
/-- Given a subset `s` in a normed space `E` (over a field `๐`), the polar
`polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals which
evaluate to something of norm at most one at all points `z โ s`. -/
def polar (๐ : Type*) [NontriviallyNormedField ๐] {E : Type*} [SeminormedAddCommGroup E]
[NormedSpace ๐ E] : Set E โ Set (Dual ๐ E) :=
(dualPairing ๐ E).flip.polar
#align normed_space.polar NormedSpace.polar
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ๐ E]
theorem mem_polar_iff {x' : Dual ๐ E} (s : Set E) : x' โ polar ๐ s โ โ z โ s, โx' zโ โค 1 :=
Iff.rfl
#align normed_space.mem_polar_iff NormedSpace.mem_polar_iff
@[simp]
theorem polar_univ : polar ๐ (univ : Set E) = {(0 : Dual ๐ E)} :=
(dualPairing ๐ E).flip.polar_univ
(LinearMap.flip_separatingRight.mpr (dualPairing_separatingLeft ๐ E))
#align normed_space.polar_univ NormedSpace.polar_univ
theorem isClosed_polar (s : Set E) : IsClosed (polar ๐ s) := by
dsimp only [NormedSpace.polar]
simp only [LinearMap.polar_eq_iInter, LinearMap.flip_apply]
refine' isClosed_biInter fun z _ => _
exact isClosed_Iic.preimage (ContinuousLinearMap.apply ๐ ๐ z).continuous.norm
#align normed_space.is_closed_polar NormedSpace.isClosed_polar
@[simp]
theorem polar_closure (s : Set E) : polar ๐ (closure s) = polar ๐ s :=
((dualPairing ๐ E).flip.polar_antitone subset_closure).antisymm <|
(dualPairing ๐ E).flip.polar_gc.l_le <|
closure_minimal ((dualPairing ๐ E).flip.polar_gc.le_u_l s) <| by
simpa [LinearMap.flip_flip] using
(isClosed_polar _ _).preimage (inclusionInDoubleDual ๐ E).continuous
#align normed_space.polar_closure NormedSpace.polar_closure
variable {๐}
/-- If `x'` is a dual element such that the norms `โx' zโ` are bounded for `z โ s`, then a
small scalar multiple of `x'` is in `polar ๐ s`. -/
theorem smul_mem_polar {s : Set E} {x' : Dual ๐ E} {c : ๐} (hc : โ z, z โ s โ โx' zโ โค โcโ) :
cโปยน โข x' โ polar ๐ s := by
by_cases c_zero : c = 0
ยท simp only [c_zero, inv_zero, zero_smul]
exact (dualPairing ๐ E).flip.zero_mem_polar _
have eq : โ z, โcโปยน โข x' zโ = โcโปยนโ * โx' zโ := fun z => norm_smul cโปยน _
have le : โ z, z โ s โ โcโปยน โข x' zโ โค โcโปยนโ * โcโ := by
intro z hzs
rw [eq z]
apply mul_le_mul (le_of_eq rfl) (hc z hzs) (norm_nonneg _) (norm_nonneg _)
have cancel : โcโปยนโ * โcโ = 1 := by
simp only [c_zero, norm_eq_zero, Ne.def, not_false_iff, inv_mul_cancel, norm_inv]
rwa [cancel] at le
#align normed_space.smul_mem_polar NormedSpace.smul_mem_polar
theorem polar_ball_subset_closedBall_div {c : ๐} (hc : 1 < โcโ) {r : โ} (hr : 0 < r) :
polar ๐ (ball (0 : E) r) โ closedBall (0 : Dual ๐ E) (โcโ / r) := by
intro x' hx'
rw [mem_polar_iff] at hx'
simp only [polar, mem_setOf, mem_closedBall_zero_iff, mem_ball_zero_iff] at *
have hcr : 0 < โcโ / r := div_pos (zero_lt_one.trans hc) hr
refine' ContinuousLinearMap.op_norm_le_of_shell hr hcr.le hc fun x hโ hโ => _
calc
โx' xโ โค 1 := hx' _ hโ
_ โค โcโ / r * โxโ := (inv_pos_le_iff_one_le_mul' hcr).1 (by rwa [inv_div])
#align normed_space.polar_ball_subset_closed_ball_div NormedSpace.polar_ball_subset_closedBall_div
variable (๐)
theorem closedBall_inv_subset_polar_closedBall {r : โ} :
closedBall (0 : Dual ๐ E) rโปยน โ polar ๐ (closedBall (0 : E) r) := fun x' hx' x hx =>
calc
โx' xโ โค โx'โ * โxโ := x'.le_op_norm x
_ โค rโปยน * r :=
(mul_le_mul (mem_closedBall_zero_iff.1 hx') (mem_closedBall_zero_iff.1 hx) (norm_nonneg _)
(dist_nonneg.trans hx'))
_ = r / r := (inv_mul_eq_div _ _)
_ โค 1 := div_self_le_one r
#align normed_space.closed_ball_inv_subset_polar_closed_ball NormedSpace.closedBall_inv_subset_polar_closedBall
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน := by
refine' Subset.antisymm _ (closedBall_inv_subset_polar_closedBall ๐)
intro x' h
simp only [mem_closedBall_zero_iff]
refine' ContinuousLinearMap.op_norm_le_of_ball hr (inv_nonneg.mpr hr.le) fun z _ => _
simpa only [one_div] using LinearMap.bound_of_ball_bound' hr 1 x'.toLinearMap h z
#align normed_space.polar_closed_ball NormedSpace.polar_closedBall
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s) := by
|
obtain โจa, haโฉ : โ a : ๐, 1 < โaโ := NormedField.exists_one_lt_norm ๐
|
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s) := by
|
Mathlib.Analysis.NormedSpace.Dual.254_0.WirVfj6f5oiZZ2w
|
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s)
|
Mathlib_Analysis_NormedSpace_Dual
|
case intro
๐ : Type u_1
instโยฒ : NontriviallyNormedField ๐
E : Type u_2
instโยน : SeminormedAddCommGroup E
instโ : NormedSpace ๐ E
s : Set E
s_nhd : s โ ๐ 0
a : ๐
ha : 1 < โaโ
โข IsBounded (polar ๐ s)
|
/-
Copyright (c) 2020 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.NormedSpace.HahnBanach.Extension
import Mathlib.Analysis.NormedSpace.IsROrC
import Mathlib.Analysis.LocallyConvex.Polar
#align_import analysis.normed_space.dual from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# The topological dual of a normed space
In this file we define the topological dual `NormedSpace.Dual` of a normed space, and the
continuous linear map `NormedSpace.inclusionInDoubleDual` from a normed space into its double
dual.
For base field `๐ = โ` or `๐ = โ`, this map is actually an isometric embedding; we provide a
version `NormedSpace.inclusionInDoubleDualLi` of the map which is of type a bundled linear
isometric embedding, `E โโแตข[๐] (Dual ๐ (Dual ๐ E))`.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `SeminormedAddCommGroup` and we specialize to `NormedAddCommGroup` when needed.
## Main definitions
* `inclusionInDoubleDual` and `inclusionInDoubleDualLi` are the inclusion of a normed space
in its double dual, considered as a bounded linear map and as a linear isometry, respectively.
* `polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals `x'` for which
`โx' zโ โค 1` for every `z โ s`.
## Tags
dual
-/
noncomputable section
open Classical Topology Bornology
universe u v
namespace NormedSpace
section General
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable (E : Type*) [SeminormedAddCommGroup E] [NormedSpace ๐ E]
variable (F : Type*) [NormedAddCommGroup F] [NormedSpace ๐ F]
/-- The topological dual of a seminormed space `E`. -/
abbrev Dual : Type _ := E โL[๐] ๐
#align normed_space.dual NormedSpace.Dual
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_eq until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : NormedSpace ๐ (Dual ๐ E) := inferInstance
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_le until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : SeminormedAddCommGroup (Dual ๐ E) := inferInstance
/-- The inclusion of a normed space in its double (topological) dual, considered
as a bounded linear map. -/
def inclusionInDoubleDual : E โL[๐] Dual ๐ (Dual ๐ E) :=
ContinuousLinearMap.apply ๐ ๐
#align normed_space.inclusion_in_double_dual NormedSpace.inclusionInDoubleDual
@[simp]
theorem dual_def (x : E) (f : Dual ๐ E) : inclusionInDoubleDual ๐ E x f = f x :=
rfl
#align normed_space.dual_def NormedSpace.dual_def
theorem inclusionInDoubleDual_norm_eq :
โinclusionInDoubleDual ๐ Eโ = โContinuousLinearMap.id ๐ (Dual ๐ E)โ :=
ContinuousLinearMap.op_norm_flip _
#align normed_space.inclusion_in_double_dual_norm_eq NormedSpace.inclusionInDoubleDual_norm_eq
theorem inclusionInDoubleDual_norm_le : โinclusionInDoubleDual ๐ Eโ โค 1 := by
rw [inclusionInDoubleDual_norm_eq]
exact ContinuousLinearMap.norm_id_le
#align normed_space.inclusion_in_double_dual_norm_le NormedSpace.inclusionInDoubleDual_norm_le
theorem double_dual_bound (x : E) : โ(inclusionInDoubleDual ๐ E) xโ โค โxโ := by
simpa using ContinuousLinearMap.le_of_op_norm_le _ (inclusionInDoubleDual_norm_le ๐ E) x
#align normed_space.double_dual_bound NormedSpace.double_dual_bound
/-- The dual pairing as a bilinear form. -/
def dualPairing : Dual ๐ E โโ[๐] E โโ[๐] ๐ :=
ContinuousLinearMap.coeLM ๐
#align normed_space.dual_pairing NormedSpace.dualPairing
@[simp]
theorem dualPairing_apply {v : Dual ๐ E} {x : E} : dualPairing ๐ E v x = v x :=
rfl
#align normed_space.dual_pairing_apply NormedSpace.dualPairing_apply
theorem dualPairing_separatingLeft : (dualPairing ๐ E).SeparatingLeft := by
rw [LinearMap.separatingLeft_iff_ker_eq_bot, LinearMap.ker_eq_bot]
exact ContinuousLinearMap.coe_injective
#align normed_space.dual_pairing_separating_left NormedSpace.dualPairing_separatingLeft
end General
section BidualIsometry
variable (๐ : Type v) [IsROrC ๐] {E : Type u} [NormedAddCommGroup E] [NormedSpace ๐ E]
/-- If one controls the norm of every `f x`, then one controls the norm of `x`.
Compare `ContinuousLinearMap.op_norm_le_bound`. -/
theorem norm_le_dual_bound (x : E) {M : โ} (hMp : 0 โค M) (hM : โ f : Dual ๐ E, โf xโ โค M * โfโ) :
โxโ โค M := by
classical
by_cases h : x = 0
ยท simp only [h, hMp, norm_zero]
ยท obtain โจf, hfโ, hfxโฉ : โ f : E โL[๐] ๐, โfโ = 1 โง f x = โxโ := exists_dual_vector ๐ x h
calc
โxโ = โ(โxโ : ๐)โ := IsROrC.norm_coe_norm.symm
_ = โf xโ := by rw [hfx]
_ โค M * โfโ := (hM f)
_ = M := by rw [hfโ, mul_one]
#align normed_space.norm_le_dual_bound NormedSpace.norm_le_dual_bound
theorem eq_zero_of_forall_dual_eq_zero {x : E} (h : โ f : Dual ๐ E, f x = (0 : ๐)) : x = 0 :=
norm_le_zero_iff.mp (norm_le_dual_bound ๐ x le_rfl fun f => by simp [h f])
#align normed_space.eq_zero_of_forall_dual_eq_zero NormedSpace.eq_zero_of_forall_dual_eq_zero
theorem eq_zero_iff_forall_dual_eq_zero (x : E) : x = 0 โ โ g : Dual ๐ E, g x = 0 :=
โจfun hx => by simp [hx], fun h => eq_zero_of_forall_dual_eq_zero ๐ hโฉ
#align normed_space.eq_zero_iff_forall_dual_eq_zero NormedSpace.eq_zero_iff_forall_dual_eq_zero
/-- See also `geometric_hahn_banach_point_point`. -/
theorem eq_iff_forall_dual_eq {x y : E} : x = y โ โ g : Dual ๐ E, g x = g y := by
rw [โ sub_eq_zero, eq_zero_iff_forall_dual_eq_zero ๐ (x - y)]
simp [sub_eq_zero]
#align normed_space.eq_iff_forall_dual_eq NormedSpace.eq_iff_forall_dual_eq
/-- The inclusion of a normed space in its double dual is an isometry onto its image.-/
def inclusionInDoubleDualLi : E โโแตข[๐] Dual ๐ (Dual ๐ E) :=
{ inclusionInDoubleDual ๐ E with
norm_map' := by
intro x
apply le_antisymm
ยท exact double_dual_bound ๐ E x
rw [ContinuousLinearMap.norm_def]
refine' le_csInf ContinuousLinearMap.bounds_nonempty _
rintro c โจhc1, hc2โฉ
exact norm_le_dual_bound ๐ x hc1 hc2 }
#align normed_space.inclusion_in_double_dual_li NormedSpace.inclusionInDoubleDualLi
end BidualIsometry
section PolarSets
open Metric Set NormedSpace
/-- Given a subset `s` in a normed space `E` (over a field `๐`), the polar
`polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals which
evaluate to something of norm at most one at all points `z โ s`. -/
def polar (๐ : Type*) [NontriviallyNormedField ๐] {E : Type*} [SeminormedAddCommGroup E]
[NormedSpace ๐ E] : Set E โ Set (Dual ๐ E) :=
(dualPairing ๐ E).flip.polar
#align normed_space.polar NormedSpace.polar
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ๐ E]
theorem mem_polar_iff {x' : Dual ๐ E} (s : Set E) : x' โ polar ๐ s โ โ z โ s, โx' zโ โค 1 :=
Iff.rfl
#align normed_space.mem_polar_iff NormedSpace.mem_polar_iff
@[simp]
theorem polar_univ : polar ๐ (univ : Set E) = {(0 : Dual ๐ E)} :=
(dualPairing ๐ E).flip.polar_univ
(LinearMap.flip_separatingRight.mpr (dualPairing_separatingLeft ๐ E))
#align normed_space.polar_univ NormedSpace.polar_univ
theorem isClosed_polar (s : Set E) : IsClosed (polar ๐ s) := by
dsimp only [NormedSpace.polar]
simp only [LinearMap.polar_eq_iInter, LinearMap.flip_apply]
refine' isClosed_biInter fun z _ => _
exact isClosed_Iic.preimage (ContinuousLinearMap.apply ๐ ๐ z).continuous.norm
#align normed_space.is_closed_polar NormedSpace.isClosed_polar
@[simp]
theorem polar_closure (s : Set E) : polar ๐ (closure s) = polar ๐ s :=
((dualPairing ๐ E).flip.polar_antitone subset_closure).antisymm <|
(dualPairing ๐ E).flip.polar_gc.l_le <|
closure_minimal ((dualPairing ๐ E).flip.polar_gc.le_u_l s) <| by
simpa [LinearMap.flip_flip] using
(isClosed_polar _ _).preimage (inclusionInDoubleDual ๐ E).continuous
#align normed_space.polar_closure NormedSpace.polar_closure
variable {๐}
/-- If `x'` is a dual element such that the norms `โx' zโ` are bounded for `z โ s`, then a
small scalar multiple of `x'` is in `polar ๐ s`. -/
theorem smul_mem_polar {s : Set E} {x' : Dual ๐ E} {c : ๐} (hc : โ z, z โ s โ โx' zโ โค โcโ) :
cโปยน โข x' โ polar ๐ s := by
by_cases c_zero : c = 0
ยท simp only [c_zero, inv_zero, zero_smul]
exact (dualPairing ๐ E).flip.zero_mem_polar _
have eq : โ z, โcโปยน โข x' zโ = โcโปยนโ * โx' zโ := fun z => norm_smul cโปยน _
have le : โ z, z โ s โ โcโปยน โข x' zโ โค โcโปยนโ * โcโ := by
intro z hzs
rw [eq z]
apply mul_le_mul (le_of_eq rfl) (hc z hzs) (norm_nonneg _) (norm_nonneg _)
have cancel : โcโปยนโ * โcโ = 1 := by
simp only [c_zero, norm_eq_zero, Ne.def, not_false_iff, inv_mul_cancel, norm_inv]
rwa [cancel] at le
#align normed_space.smul_mem_polar NormedSpace.smul_mem_polar
theorem polar_ball_subset_closedBall_div {c : ๐} (hc : 1 < โcโ) {r : โ} (hr : 0 < r) :
polar ๐ (ball (0 : E) r) โ closedBall (0 : Dual ๐ E) (โcโ / r) := by
intro x' hx'
rw [mem_polar_iff] at hx'
simp only [polar, mem_setOf, mem_closedBall_zero_iff, mem_ball_zero_iff] at *
have hcr : 0 < โcโ / r := div_pos (zero_lt_one.trans hc) hr
refine' ContinuousLinearMap.op_norm_le_of_shell hr hcr.le hc fun x hโ hโ => _
calc
โx' xโ โค 1 := hx' _ hโ
_ โค โcโ / r * โxโ := (inv_pos_le_iff_one_le_mul' hcr).1 (by rwa [inv_div])
#align normed_space.polar_ball_subset_closed_ball_div NormedSpace.polar_ball_subset_closedBall_div
variable (๐)
theorem closedBall_inv_subset_polar_closedBall {r : โ} :
closedBall (0 : Dual ๐ E) rโปยน โ polar ๐ (closedBall (0 : E) r) := fun x' hx' x hx =>
calc
โx' xโ โค โx'โ * โxโ := x'.le_op_norm x
_ โค rโปยน * r :=
(mul_le_mul (mem_closedBall_zero_iff.1 hx') (mem_closedBall_zero_iff.1 hx) (norm_nonneg _)
(dist_nonneg.trans hx'))
_ = r / r := (inv_mul_eq_div _ _)
_ โค 1 := div_self_le_one r
#align normed_space.closed_ball_inv_subset_polar_closed_ball NormedSpace.closedBall_inv_subset_polar_closedBall
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน := by
refine' Subset.antisymm _ (closedBall_inv_subset_polar_closedBall ๐)
intro x' h
simp only [mem_closedBall_zero_iff]
refine' ContinuousLinearMap.op_norm_le_of_ball hr (inv_nonneg.mpr hr.le) fun z _ => _
simpa only [one_div] using LinearMap.bound_of_ball_bound' hr 1 x'.toLinearMap h z
#align normed_space.polar_closed_ball NormedSpace.polar_closedBall
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s) := by
obtain โจa, haโฉ : โ a : ๐, 1 < โaโ := NormedField.exists_one_lt_norm ๐
|
obtain โจr, r_pos, r_ballโฉ : โ r : โ, 0 < r โง ball 0 r โ s := Metric.mem_nhds_iff.1 s_nhd
|
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s) := by
obtain โจa, haโฉ : โ a : ๐, 1 < โaโ := NormedField.exists_one_lt_norm ๐
|
Mathlib.Analysis.NormedSpace.Dual.254_0.WirVfj6f5oiZZ2w
|
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s)
|
Mathlib_Analysis_NormedSpace_Dual
|
case intro.intro.intro
๐ : Type u_1
instโยฒ : NontriviallyNormedField ๐
E : Type u_2
instโยน : SeminormedAddCommGroup E
instโ : NormedSpace ๐ E
s : Set E
s_nhd : s โ ๐ 0
a : ๐
ha : 1 < โaโ
r : โ
r_pos : 0 < r
r_ball : ball 0 r โ s
โข IsBounded (polar ๐ s)
|
/-
Copyright (c) 2020 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.NormedSpace.HahnBanach.Extension
import Mathlib.Analysis.NormedSpace.IsROrC
import Mathlib.Analysis.LocallyConvex.Polar
#align_import analysis.normed_space.dual from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# The topological dual of a normed space
In this file we define the topological dual `NormedSpace.Dual` of a normed space, and the
continuous linear map `NormedSpace.inclusionInDoubleDual` from a normed space into its double
dual.
For base field `๐ = โ` or `๐ = โ`, this map is actually an isometric embedding; we provide a
version `NormedSpace.inclusionInDoubleDualLi` of the map which is of type a bundled linear
isometric embedding, `E โโแตข[๐] (Dual ๐ (Dual ๐ E))`.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `SeminormedAddCommGroup` and we specialize to `NormedAddCommGroup` when needed.
## Main definitions
* `inclusionInDoubleDual` and `inclusionInDoubleDualLi` are the inclusion of a normed space
in its double dual, considered as a bounded linear map and as a linear isometry, respectively.
* `polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals `x'` for which
`โx' zโ โค 1` for every `z โ s`.
## Tags
dual
-/
noncomputable section
open Classical Topology Bornology
universe u v
namespace NormedSpace
section General
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable (E : Type*) [SeminormedAddCommGroup E] [NormedSpace ๐ E]
variable (F : Type*) [NormedAddCommGroup F] [NormedSpace ๐ F]
/-- The topological dual of a seminormed space `E`. -/
abbrev Dual : Type _ := E โL[๐] ๐
#align normed_space.dual NormedSpace.Dual
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_eq until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : NormedSpace ๐ (Dual ๐ E) := inferInstance
-- TODO: helper instance for elaboration of inclusionInDoubleDual_norm_le until
-- leanprover/lean4#2522 is resolved; remove once fixed
instance : SeminormedAddCommGroup (Dual ๐ E) := inferInstance
/-- The inclusion of a normed space in its double (topological) dual, considered
as a bounded linear map. -/
def inclusionInDoubleDual : E โL[๐] Dual ๐ (Dual ๐ E) :=
ContinuousLinearMap.apply ๐ ๐
#align normed_space.inclusion_in_double_dual NormedSpace.inclusionInDoubleDual
@[simp]
theorem dual_def (x : E) (f : Dual ๐ E) : inclusionInDoubleDual ๐ E x f = f x :=
rfl
#align normed_space.dual_def NormedSpace.dual_def
theorem inclusionInDoubleDual_norm_eq :
โinclusionInDoubleDual ๐ Eโ = โContinuousLinearMap.id ๐ (Dual ๐ E)โ :=
ContinuousLinearMap.op_norm_flip _
#align normed_space.inclusion_in_double_dual_norm_eq NormedSpace.inclusionInDoubleDual_norm_eq
theorem inclusionInDoubleDual_norm_le : โinclusionInDoubleDual ๐ Eโ โค 1 := by
rw [inclusionInDoubleDual_norm_eq]
exact ContinuousLinearMap.norm_id_le
#align normed_space.inclusion_in_double_dual_norm_le NormedSpace.inclusionInDoubleDual_norm_le
theorem double_dual_bound (x : E) : โ(inclusionInDoubleDual ๐ E) xโ โค โxโ := by
simpa using ContinuousLinearMap.le_of_op_norm_le _ (inclusionInDoubleDual_norm_le ๐ E) x
#align normed_space.double_dual_bound NormedSpace.double_dual_bound
/-- The dual pairing as a bilinear form. -/
def dualPairing : Dual ๐ E โโ[๐] E โโ[๐] ๐ :=
ContinuousLinearMap.coeLM ๐
#align normed_space.dual_pairing NormedSpace.dualPairing
@[simp]
theorem dualPairing_apply {v : Dual ๐ E} {x : E} : dualPairing ๐ E v x = v x :=
rfl
#align normed_space.dual_pairing_apply NormedSpace.dualPairing_apply
theorem dualPairing_separatingLeft : (dualPairing ๐ E).SeparatingLeft := by
rw [LinearMap.separatingLeft_iff_ker_eq_bot, LinearMap.ker_eq_bot]
exact ContinuousLinearMap.coe_injective
#align normed_space.dual_pairing_separating_left NormedSpace.dualPairing_separatingLeft
end General
section BidualIsometry
variable (๐ : Type v) [IsROrC ๐] {E : Type u} [NormedAddCommGroup E] [NormedSpace ๐ E]
/-- If one controls the norm of every `f x`, then one controls the norm of `x`.
Compare `ContinuousLinearMap.op_norm_le_bound`. -/
theorem norm_le_dual_bound (x : E) {M : โ} (hMp : 0 โค M) (hM : โ f : Dual ๐ E, โf xโ โค M * โfโ) :
โxโ โค M := by
classical
by_cases h : x = 0
ยท simp only [h, hMp, norm_zero]
ยท obtain โจf, hfโ, hfxโฉ : โ f : E โL[๐] ๐, โfโ = 1 โง f x = โxโ := exists_dual_vector ๐ x h
calc
โxโ = โ(โxโ : ๐)โ := IsROrC.norm_coe_norm.symm
_ = โf xโ := by rw [hfx]
_ โค M * โfโ := (hM f)
_ = M := by rw [hfโ, mul_one]
#align normed_space.norm_le_dual_bound NormedSpace.norm_le_dual_bound
theorem eq_zero_of_forall_dual_eq_zero {x : E} (h : โ f : Dual ๐ E, f x = (0 : ๐)) : x = 0 :=
norm_le_zero_iff.mp (norm_le_dual_bound ๐ x le_rfl fun f => by simp [h f])
#align normed_space.eq_zero_of_forall_dual_eq_zero NormedSpace.eq_zero_of_forall_dual_eq_zero
theorem eq_zero_iff_forall_dual_eq_zero (x : E) : x = 0 โ โ g : Dual ๐ E, g x = 0 :=
โจfun hx => by simp [hx], fun h => eq_zero_of_forall_dual_eq_zero ๐ hโฉ
#align normed_space.eq_zero_iff_forall_dual_eq_zero NormedSpace.eq_zero_iff_forall_dual_eq_zero
/-- See also `geometric_hahn_banach_point_point`. -/
theorem eq_iff_forall_dual_eq {x y : E} : x = y โ โ g : Dual ๐ E, g x = g y := by
rw [โ sub_eq_zero, eq_zero_iff_forall_dual_eq_zero ๐ (x - y)]
simp [sub_eq_zero]
#align normed_space.eq_iff_forall_dual_eq NormedSpace.eq_iff_forall_dual_eq
/-- The inclusion of a normed space in its double dual is an isometry onto its image.-/
def inclusionInDoubleDualLi : E โโแตข[๐] Dual ๐ (Dual ๐ E) :=
{ inclusionInDoubleDual ๐ E with
norm_map' := by
intro x
apply le_antisymm
ยท exact double_dual_bound ๐ E x
rw [ContinuousLinearMap.norm_def]
refine' le_csInf ContinuousLinearMap.bounds_nonempty _
rintro c โจhc1, hc2โฉ
exact norm_le_dual_bound ๐ x hc1 hc2 }
#align normed_space.inclusion_in_double_dual_li NormedSpace.inclusionInDoubleDualLi
end BidualIsometry
section PolarSets
open Metric Set NormedSpace
/-- Given a subset `s` in a normed space `E` (over a field `๐`), the polar
`polar ๐ s` is the subset of `Dual ๐ E` consisting of those functionals which
evaluate to something of norm at most one at all points `z โ s`. -/
def polar (๐ : Type*) [NontriviallyNormedField ๐] {E : Type*} [SeminormedAddCommGroup E]
[NormedSpace ๐ E] : Set E โ Set (Dual ๐ E) :=
(dualPairing ๐ E).flip.polar
#align normed_space.polar NormedSpace.polar
variable (๐ : Type*) [NontriviallyNormedField ๐]
variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ๐ E]
theorem mem_polar_iff {x' : Dual ๐ E} (s : Set E) : x' โ polar ๐ s โ โ z โ s, โx' zโ โค 1 :=
Iff.rfl
#align normed_space.mem_polar_iff NormedSpace.mem_polar_iff
@[simp]
theorem polar_univ : polar ๐ (univ : Set E) = {(0 : Dual ๐ E)} :=
(dualPairing ๐ E).flip.polar_univ
(LinearMap.flip_separatingRight.mpr (dualPairing_separatingLeft ๐ E))
#align normed_space.polar_univ NormedSpace.polar_univ
theorem isClosed_polar (s : Set E) : IsClosed (polar ๐ s) := by
dsimp only [NormedSpace.polar]
simp only [LinearMap.polar_eq_iInter, LinearMap.flip_apply]
refine' isClosed_biInter fun z _ => _
exact isClosed_Iic.preimage (ContinuousLinearMap.apply ๐ ๐ z).continuous.norm
#align normed_space.is_closed_polar NormedSpace.isClosed_polar
@[simp]
theorem polar_closure (s : Set E) : polar ๐ (closure s) = polar ๐ s :=
((dualPairing ๐ E).flip.polar_antitone subset_closure).antisymm <|
(dualPairing ๐ E).flip.polar_gc.l_le <|
closure_minimal ((dualPairing ๐ E).flip.polar_gc.le_u_l s) <| by
simpa [LinearMap.flip_flip] using
(isClosed_polar _ _).preimage (inclusionInDoubleDual ๐ E).continuous
#align normed_space.polar_closure NormedSpace.polar_closure
variable {๐}
/-- If `x'` is a dual element such that the norms `โx' zโ` are bounded for `z โ s`, then a
small scalar multiple of `x'` is in `polar ๐ s`. -/
theorem smul_mem_polar {s : Set E} {x' : Dual ๐ E} {c : ๐} (hc : โ z, z โ s โ โx' zโ โค โcโ) :
cโปยน โข x' โ polar ๐ s := by
by_cases c_zero : c = 0
ยท simp only [c_zero, inv_zero, zero_smul]
exact (dualPairing ๐ E).flip.zero_mem_polar _
have eq : โ z, โcโปยน โข x' zโ = โcโปยนโ * โx' zโ := fun z => norm_smul cโปยน _
have le : โ z, z โ s โ โcโปยน โข x' zโ โค โcโปยนโ * โcโ := by
intro z hzs
rw [eq z]
apply mul_le_mul (le_of_eq rfl) (hc z hzs) (norm_nonneg _) (norm_nonneg _)
have cancel : โcโปยนโ * โcโ = 1 := by
simp only [c_zero, norm_eq_zero, Ne.def, not_false_iff, inv_mul_cancel, norm_inv]
rwa [cancel] at le
#align normed_space.smul_mem_polar NormedSpace.smul_mem_polar
theorem polar_ball_subset_closedBall_div {c : ๐} (hc : 1 < โcโ) {r : โ} (hr : 0 < r) :
polar ๐ (ball (0 : E) r) โ closedBall (0 : Dual ๐ E) (โcโ / r) := by
intro x' hx'
rw [mem_polar_iff] at hx'
simp only [polar, mem_setOf, mem_closedBall_zero_iff, mem_ball_zero_iff] at *
have hcr : 0 < โcโ / r := div_pos (zero_lt_one.trans hc) hr
refine' ContinuousLinearMap.op_norm_le_of_shell hr hcr.le hc fun x hโ hโ => _
calc
โx' xโ โค 1 := hx' _ hโ
_ โค โcโ / r * โxโ := (inv_pos_le_iff_one_le_mul' hcr).1 (by rwa [inv_div])
#align normed_space.polar_ball_subset_closed_ball_div NormedSpace.polar_ball_subset_closedBall_div
variable (๐)
theorem closedBall_inv_subset_polar_closedBall {r : โ} :
closedBall (0 : Dual ๐ E) rโปยน โ polar ๐ (closedBall (0 : E) r) := fun x' hx' x hx =>
calc
โx' xโ โค โx'โ * โxโ := x'.le_op_norm x
_ โค rโปยน * r :=
(mul_le_mul (mem_closedBall_zero_iff.1 hx') (mem_closedBall_zero_iff.1 hx) (norm_nonneg _)
(dist_nonneg.trans hx'))
_ = r / r := (inv_mul_eq_div _ _)
_ โค 1 := div_self_le_one r
#align normed_space.closed_ball_inv_subset_polar_closed_ball NormedSpace.closedBall_inv_subset_polar_closedBall
/-- The `polar` of closed ball in a normed space `E` is the closed ball of the dual with
inverse radius. -/
theorem polar_closedBall {๐ E : Type*} [IsROrC ๐] [NormedAddCommGroup E] [NormedSpace ๐ E] {r : โ}
(hr : 0 < r) : polar ๐ (closedBall (0 : E) r) = closedBall (0 : Dual ๐ E) rโปยน := by
refine' Subset.antisymm _ (closedBall_inv_subset_polar_closedBall ๐)
intro x' h
simp only [mem_closedBall_zero_iff]
refine' ContinuousLinearMap.op_norm_le_of_ball hr (inv_nonneg.mpr hr.le) fun z _ => _
simpa only [one_div] using LinearMap.bound_of_ball_bound' hr 1 x'.toLinearMap h z
#align normed_space.polar_closed_ball NormedSpace.polar_closedBall
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s) := by
obtain โจa, haโฉ : โ a : ๐, 1 < โaโ := NormedField.exists_one_lt_norm ๐
obtain โจr, r_pos, r_ballโฉ : โ r : โ, 0 < r โง ball 0 r โ s := Metric.mem_nhds_iff.1 s_nhd
|
exact isBounded_closedBall.subset
(((dualPairing ๐ E).flip.polar_antitone r_ball).trans <|
polar_ball_subset_closedBall_div ha r_pos)
|
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s) := by
obtain โจa, haโฉ : โ a : ๐, 1 < โaโ := NormedField.exists_one_lt_norm ๐
obtain โจr, r_pos, r_ballโฉ : โ r : โ, 0 < r โง ball 0 r โ s := Metric.mem_nhds_iff.1 s_nhd
|
Mathlib.Analysis.NormedSpace.Dual.254_0.WirVfj6f5oiZZ2w
|
/-- Given a neighborhood `s` of the origin in a normed space `E`, the dual norms
of all elements of the polar `polar ๐ s` are bounded by a constant. -/
theorem isBounded_polar_of_mem_nhds_zero {s : Set E} (s_nhd : s โ ๐ (0 : E)) :
IsBounded (polar ๐ s)
|
Mathlib_Analysis_NormedSpace_Dual
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
โข CutExpand r โค InvImage (Finsupp.Lex (rแถ โ fun x x_1 => x โ x_1) fun x x_1 => x < x_1) โtoFinsupp
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
|
rintro s t โจu, a, hr, heโฉ
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ u, r a' a
he : s + {a} = t + u
โข InvImage (Finsupp.Lex (rแถ โ fun x x_1 => x โ x_1) fun x x_1 => x < x_1) (โtoFinsupp) s t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
|
replace hr := fun a' โฆ mt (hr a')
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
he : s + {a} = t + u
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
โข InvImage (Finsupp.Lex (rแถ โ fun x x_1 => x โ x_1) fun x x_1 => x < x_1) (โtoFinsupp) s t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
|
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
he : s + {a} = t + u
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
โข InvImage (Finsupp.Lex (rแถ โ fun x x_1 => x โ x_1) fun x x_1 => x < x_1) (โtoFinsupp) s t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
|
refine โจa, fun b h โฆ ?_, ?_โฉ
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.refine_1
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
he : s + {a} = t + u
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
b : ฮฑ
h : (rแถ โ fun x x_1 => x โ x_1) b a
โข (toFinsupp s) b = (toFinsupp t) b
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;>
|
simp_rw [toFinsupp_apply]
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;>
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.refine_2
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
he : s + {a} = t + u
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
โข (fun {i} x x_1 => x < x_1) ((toFinsupp s) a) ((toFinsupp t) a)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;>
|
simp_rw [toFinsupp_apply]
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;>
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.refine_1
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
he : s + {a} = t + u
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
b : ฮฑ
h : (rแถ โ fun x x_1 => x โ x_1) b a
โข count b s = count b t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท
|
apply_fun count b at he
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.refine_1
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
b : ฮฑ
h : (rแถ โ fun x x_1 => x โ x_1) b a
he : count b (s + {a}) = count b (t + u)
โข count b s = count b t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
|
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.refine_2
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
he : s + {a} = t + u
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
โข count a s < count a t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท
|
apply_fun count a at he
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.refine_2
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
he : count a (s + {a}) = count a (t + u)
โข count a s < count a t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
|
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.refine_2
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t u : Multiset ฮฑ
a : ฮฑ
hr : โ (a' : ฮฑ), ยฌr a' a โ a' โ u
he : count a s + 1 = count a t
โข count a s < count a t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
|
exact he โธ Nat.lt_succ_self _
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
|
Mathlib.Logic.Hydra.62_0.cWRHz2gehQLFc75
|
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
x' x : ฮฑ
hโ : r x' x
a : ฮฑ
h : a โ {x'}
โข r a x
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by
|
rwa [mem_singleton.1 h]
|
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by
|
Mathlib.Logic.Hydra.81_0.cWRHz2gehQLFc75
|
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x}
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
t u s xโยน : Multiset ฮฑ
xโ : ฮฑ
โข s + t + {xโ} = s + u + xโยน โ t + {xโ} = u + xโยน
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by
|
rw [add_assoc, add_assoc, add_left_cancel_iff]
|
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by
|
Mathlib.Logic.Hydra.85_0.cWRHz2gehQLFc75
|
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s' s : Multiset ฮฑ
โข CutExpand r s' s โ โ t a, (โ a' โ t, r a' a) โง a โ s โง s' = erase s a + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
|
simp_rw [CutExpand, add_singleton_eq_iff]
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
|
Mathlib.Logic.Hydra.89_0.cWRHz2gehQLFc75
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s' s : Multiset ฮฑ
โข (โ t a, (โ a' โ t, r a' a) โง a โ s + t โง s' = erase (s + t) a) โ
โ t a, (โ a' โ t, r a' a) โง a โ s โง s' = erase s a + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
|
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
|
Mathlib.Logic.Hydra.89_0.cWRHz2gehQLFc75
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t
|
Mathlib_Logic_Hydra
|
case refine'_1
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s' s t : Multiset ฮฑ
a : ฮฑ
โข (โ a' โ t, r a' a) โง a โ s + t โง s' = erase (s + t) a โ (โ a' โ t, r a' a) โง a โ s โง s' = erase s a + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท
|
rintro โจht, ha, rflโฉ
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท
|
Mathlib.Logic.Hydra.89_0.cWRHz2gehQLFc75
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t
|
Mathlib_Logic_Hydra
|
case refine'_1.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t : Multiset ฮฑ
a : ฮฑ
ht : โ a' โ t, r a' a
ha : a โ s + t
โข (โ a' โ t, r a' a) โง a โ s โง erase (s + t) a = erase s a + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
|
obtain h | h := mem_add.1 ha
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
|
Mathlib.Logic.Hydra.89_0.cWRHz2gehQLFc75
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t
|
Mathlib_Logic_Hydra
|
case refine'_1.intro.intro.inl
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t : Multiset ฮฑ
a : ฮฑ
ht : โ a' โ t, r a' a
ha : a โ s + t
h : a โ s
โข (โ a' โ t, r a' a) โง a โ s โง erase (s + t) a = erase s a + t
case refine'_1.intro.intro.inr
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t : Multiset ฮฑ
a : ฮฑ
ht : โ a' โ t, r a' a
ha : a โ s + t
h : a โ t
โข (โ a' โ t, r a' a) โง a โ s โง erase (s + t) a = erase s a + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
|
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
|
Mathlib.Logic.Hydra.89_0.cWRHz2gehQLFc75
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t
|
Mathlib_Logic_Hydra
|
case refine'_2
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s' s t : Multiset ฮฑ
a : ฮฑ
โข (โ a' โ t, r a' a) โง a โ s โง s' = erase s a + t โ (โ a' โ t, r a' a) โง a โ s + t โง s' = erase (s + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท
|
rintro โจht, h, rflโฉ
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท
|
Mathlib.Logic.Hydra.89_0.cWRHz2gehQLFc75
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t
|
Mathlib_Logic_Hydra
|
case refine'_2.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโยน : DecidableEq ฮฑ
instโ : IsIrrefl ฮฑ r
s t : Multiset ฮฑ
a : ฮฑ
ht : โ a' โ t, r a' a
h : a โ s
โข (โ a' โ t, r a' a) โง a โ s + t โง erase s a + t = erase (s + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
|
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
|
Mathlib.Logic.Hydra.89_0.cWRHz2gehQLFc75
|
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
s : Multiset ฮฑ
โข ยฌCutExpand r s 0
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
|
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
|
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
|
Mathlib.Logic.Hydra.101_0.cWRHz2gehQLFc75
|
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
s : Multiset ฮฑ
โข ยฌCutExpand r s 0
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
|
rw [cutExpand_iff]
|
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
|
Mathlib.Logic.Hydra.101_0.cWRHz2gehQLFc75
|
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
s : Multiset ฮฑ
โข ยฌโ t a, (โ a' โ t, r a' a) โง a โ 0 โง s = erase 0 a + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
|
rintro โจ_, _, _, โจโฉ, _โฉ
|
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
|
Mathlib.Logic.Hydra.101_0.cWRHz2gehQLFc75
|
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
โข Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s => s.1 + s.2
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
|
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ s t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : s + {a} = (fun s => s.1 + s.2) (sโ, sโ) + t
โข โ a', GameAdd (CutExpand r) (CutExpand r) a' (sโ, sโ) โง (fun s => s.1 + s.2) a' = s
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ;
|
dsimp at he โข
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ;
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ s t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : s + {a} = sโ + sโ + t
โข โ a', GameAdd (CutExpand r) (CutExpand r) a' (sโ, sโ) โง a'.1 + a'.2 = s
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
|
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ s t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : s + {a} = sโ + sโ + t
โข โ a', GameAdd (CutExpand r) (CutExpand r) a' (sโ, sโ) โง a'.1 + a'.2 = s
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
|
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
ha : a โ sโ + sโ + t
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
โข โ a', GameAdd (CutExpand r) (CutExpand r) a' (sโ, sโ) โง a'.1 + a'.2 = erase (sโ + sโ + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
|
rw [add_assoc, mem_add] at ha
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
ha : a โ sโ โจ a โ sโ + t
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
โข โ a', GameAdd (CutExpand r) (CutExpand r) a' (sโ, sโ) โง a'.1 + a'.2 = erase (sโ + sโ + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
|
obtain h | h := ha
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro.inl
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
h : a โ sโ
โข โ a', GameAdd (CutExpand r) (CutExpand r) a' (sโ, sโ) โง a'.1 + a'.2 = erase (sโ + sโ + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท
|
refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro.inl.refine'_1
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
h : a โ sโ
โข erase sโ a + t + {a} = sโ + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท
|
rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro.inl.refine'_2
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
h : a โ sโ
โข (erase sโ a + t, sโ).1 + (erase sโ a + t, sโ).2 = erase (sโ + sโ + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท
|
rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro.inr
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
h : a โ sโ + t
โข โ a', GameAdd (CutExpand r) (CutExpand r) a' (sโ, sโ) โง a'.1 + a'.2 = erase (sโ + sโ + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท
|
refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro.inr.refine'_1
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
h : a โ sโ + t
โข erase (sโ + t) a + {a} = sโ + t
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท
|
rw [add_comm, singleton_add, cons_erase h]
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
case mk.intro.intro.intro.intro.inr.refine'_2
ฮฑ : Type u_1
rโ r : ฮฑ โ ฮฑ โ Prop
sโ sโ t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
he : erase (sโ + sโ + t) a + {a} = sโ + sโ + t
h : a โ sโ + t
โข (sโ, erase (sโ + t) a).1 + (sโ, erase (sโ + t) a).2 = erase (sโ + sโ + t) a
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท
|
rw [add_assoc, erase_add_right_pos _ h]
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท
|
Mathlib.Logic.Hydra.107_0.cWRHz2gehQLFc75
|
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
s : Multiset ฮฑ
hs : โ a โ s, Acc (CutExpand r) {a}
โข Acc (CutExpand r) s
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
|
induction s using Multiset.induction
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
case empty
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
hs : โ a โ 0, Acc (CutExpand r) {a}
โข Acc (CutExpand r) 0
case cons
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโยน : ฮฑ
sโ : Multiset ฮฑ
aโ : (โ a โ sโ, Acc (CutExpand r) {a}) โ Acc (CutExpand r) sโ
hs : โ a โ aโยน ::โ sโ, Acc (CutExpand r) {a}
โข Acc (CutExpand r) (aโยน ::โ sโ)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
|
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
hs : โ a โ 0, Acc (CutExpand r) {a}
โข Acc (CutExpand r) 0
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
|
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
hs : โ a โ 0, Acc (CutExpand r) {a}
โข Acc (CutExpand r) 0
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty =>
|
exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty =>
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
case cons
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโยน : ฮฑ
sโ : Multiset ฮฑ
aโ : (โ a โ sโ, Acc (CutExpand r) {a}) โ Acc (CutExpand r) sโ
hs : โ a โ aโยน ::โ sโ, Acc (CutExpand r) {a}
โข Acc (CutExpand r) (aโยน ::โ sโ)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
|
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
a : ฮฑ
s : Multiset ฮฑ
ihs : (โ a โ s, Acc (CutExpand r) {a}) โ Acc (CutExpand r) s
hs : โ a_1 โ a ::โ s, Acc (CutExpand r) {a_1}
โข Acc (CutExpand r) (a ::โ s)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
|
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
a : ฮฑ
s : Multiset ฮฑ
ihs : (โ a โ s, Acc (CutExpand r) {a}) โ Acc (CutExpand r) s
hs : โ a_1 โ a ::โ s, Acc (CutExpand r) {a_1}
โข Acc (CutExpand r) (a ::โ s)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
|
rw [โ s.singleton_add a]
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
a : ฮฑ
s : Multiset ฮฑ
ihs : (โ a โ s, Acc (CutExpand r) {a}) โ Acc (CutExpand r) s
hs : โ a_1 โ a ::โ s, Acc (CutExpand r) {a_1}
โข Acc (CutExpand r) ({a} + s)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
|
rw [forall_mem_cons] at hs
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
a : ฮฑ
s : Multiset ฮฑ
ihs : (โ a โ s, Acc (CutExpand r) {a}) โ Acc (CutExpand r) s
hs : Acc (CutExpand r) {a} โง โ x โ s, Acc (CutExpand r) {x}
โข Acc (CutExpand r) ({a} + s)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
|
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
|
Mathlib.Logic.Hydra.124_0.cWRHz2gehQLFc75
|
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s
|
Mathlib_Logic_Hydra
|
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
a : ฮฑ
hacc : Acc r a
โข Acc (CutExpand r) {a}
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
|
induction' hacc with a h ih
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
case intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโ a : ฮฑ
h : โ (y : ฮฑ), r y a โ Acc r y
ih : โ (y : ฮฑ), r y a โ Acc (CutExpand r) {y}
โข Acc (CutExpand r) {a}
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
|
refine' Acc.intro _ fun s โฆ _
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
case intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโ a : ฮฑ
h : โ (y : ฮฑ), r y a โ Acc r y
ih : โ (y : ฮฑ), r y a โ Acc (CutExpand r) {y}
s : Multiset ฮฑ
โข CutExpand r s {a} โ Acc (CutExpand r) s
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
|
classical
simp only [cutExpand_iff, mem_singleton]
rintro โจt, a, hr, rfl, rflโฉ
refine' acc_of_singleton fun a' โฆ _
rw [erase_singleton, zero_add]
exact ih a' โ hr a'
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
case intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโ a : ฮฑ
h : โ (y : ฮฑ), r y a โ Acc r y
ih : โ (y : ฮฑ), r y a โ Acc (CutExpand r) {y}
s : Multiset ฮฑ
โข CutExpand r s {a} โ Acc (CutExpand r) s
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
|
simp only [cutExpand_iff, mem_singleton]
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
case intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโ a : ฮฑ
h : โ (y : ฮฑ), r y a โ Acc r y
ih : โ (y : ฮฑ), r y a โ Acc (CutExpand r) {y}
s : Multiset ฮฑ
โข (โ t a_1, (โ a' โ t, r a' a_1) โง a_1 = a โง s = erase {a} a_1 + t) โ Acc (CutExpand r) s
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
|
rintro โจt, a, hr, rfl, rflโฉ
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโ : ฮฑ
t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
h : โ (y : ฮฑ), r y a โ Acc r y
ih : โ (y : ฮฑ), r y a โ Acc (CutExpand r) {y}
โข Acc (CutExpand r) (erase {a} a + t)
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
rintro โจt, a, hr, rfl, rflโฉ
|
refine' acc_of_singleton fun a' โฆ _
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
rintro โจt, a, hr, rfl, rflโฉ
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโ : ฮฑ
t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
h : โ (y : ฮฑ), r y a โ Acc r y
ih : โ (y : ฮฑ), r y a โ Acc (CutExpand r) {y}
a' : ฮฑ
โข a' โ erase {a} a + t โ Acc (CutExpand r) {a'}
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
rintro โจt, a, hr, rfl, rflโฉ
refine' acc_of_singleton fun a' โฆ _
|
rw [erase_singleton, zero_add]
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
rintro โจt, a, hr, rfl, rflโฉ
refine' acc_of_singleton fun a' โฆ _
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
case intro.intro.intro.intro.intro
ฮฑ : Type u_1
r : ฮฑ โ ฮฑ โ Prop
instโ : IsIrrefl ฮฑ r
aโ : ฮฑ
t : Multiset ฮฑ
a : ฮฑ
hr : โ a' โ t, r a' a
h : โ (y : ฮฑ), r y a โ Acc r y
ih : โ (y : ฮฑ), r y a โ Acc (CutExpand r) {y}
a' : ฮฑ
โข a' โ t โ Acc (CutExpand r) {a'}
|
/-
Copyright (c) 2022 Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Junyan Xu
-/
import Mathlib.Data.Finsupp.Lex
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.GameAdd
#align_import logic.hydra from "leanprover-community/mathlib"@"48085f140e684306f9e7da907cd5932056d1aded"
/-!
# Termination of a hydra game
This file deals with the following version of the hydra game: each head of the hydra is
labelled by an element in a type `ฮฑ`, and when you cut off one head with label `a`, it
grows back an arbitrary but finite number of heads, all labelled by elements smaller than
`a` with respect to a well-founded relation `r` on `ฮฑ`. We show that no matter how (in
what order) you choose cut off the heads, the game always terminates, i.e. all heads will
eventually be cut off (but of course it can last arbitrarily long, i.e. takes an
arbitrary finite number of steps).
This result is stated as the well-foundedness of the `CutExpand` relation defined in
this file: we model the heads of the hydra as a multiset of elements of `ฮฑ`, and the
valid "moves" of the game are modelled by the relation `CutExpand r` on `Multiset ฮฑ`:
`CutExpand r s' s` is true iff `s'` is obtained by removing one head `a โ s` and
adding back an arbitrary multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
We follow the proof by Peter LeFanu Lumsdaine at https://mathoverflow.net/a/229084/3332.
TODO: formalize the relations corresponding to more powerful (e.g. KirbyโParis and Buchholz)
hydras, and prove their well-foundedness.
-/
namespace Relation
open Multiset Prod
variable {ฮฑ : Type*}
/-- The relation that specifies valid moves in our hydra game. `CutExpand r s' s`
means that `s'` is obtained by removing one head `a โ s` and adding back an arbitrary
multiset `t` of heads such that all `a' โ t` satisfy `r a' a`.
This is most directly translated into `s' = s.erase a + t`, but `Multiset.erase` requires
`DecidableEq ฮฑ`, so we use the equivalent condition `s' + {a} = s + t` instead, which
is also easier to verify for explicit multisets `s'`, `s` and `t`.
We also don't include the condition `a โ s` because `s' + {a} = s + t` already
guarantees `a โ s + t`, and if `r` is irreflexive then `a โ t`, which is the
case when `r` is well-founded, the case we are primarily interested in.
The lemma `Relation.cutExpand_iff` below converts between this convenient definition
and the direct translation when `r` is irreflexive. -/
def CutExpand (r : ฮฑ โ ฮฑ โ Prop) (s' s : Multiset ฮฑ) : Prop :=
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง s' + {a} = s + t
#align relation.cut_expand Relation.CutExpand
variable {r : ฮฑ โ ฮฑ โ Prop}
theorem cutExpand_le_invImage_lex [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] :
CutExpand r โค InvImage (Finsupp.Lex (rแถ โ (ยท โ ยท)) (ยท < ยท)) toFinsupp := by
rintro s t โจu, a, hr, heโฉ
replace hr := fun a' โฆ mt (hr a')
classical
refine โจa, fun b h โฆ ?_, ?_โฉ <;> simp_rw [toFinsupp_apply]
ยท apply_fun count b at he
simpa only [count_add, count_singleton, if_neg h.2, add_zero, count_eq_zero.2 (hr b h.1)]
using he
ยท apply_fun count a at he
simp only [count_add, count_singleton_self, count_eq_zero.2 (hr _ (irrefl_of r a)),
add_zero] at he
exact he โธ Nat.lt_succ_self _
#align relation.cut_expand_le_inv_image_lex Relation.cutExpand_le_invImage_lex
theorem cutExpand_singleton {s x} (h : โ x' โ s, r x' x) : CutExpand r s {x} :=
โจs, x, h, add_comm s _โฉ
#align relation.cut_expand_singleton Relation.cutExpand_singleton
theorem cutExpand_singleton_singleton {x' x} (h : r x' x) : CutExpand r {x'} {x} :=
cutExpand_singleton fun a h โฆ by rwa [mem_singleton.1 h]
#align relation.cut_expand_singleton_singleton Relation.cutExpand_singleton_singleton
theorem cutExpand_add_left {t u} (s) : CutExpand r (s + t) (s + u) โ CutExpand r t u :=
existsโ_congr fun _ _ โฆ and_congr Iff.rfl <| by rw [add_assoc, add_assoc, add_left_cancel_iff]
#align relation.cut_expand_add_left Relation.cutExpand_add_left
theorem cutExpand_iff [DecidableEq ฮฑ] [IsIrrefl ฮฑ r] {s' s : Multiset ฮฑ} :
CutExpand r s' s โ
โ (t : Multiset ฮฑ) (a : ฮฑ), (โ a' โ t, r a' a) โง a โ s โง s' = s.erase a + t := by
simp_rw [CutExpand, add_singleton_eq_iff]
refine' existsโ_congr fun t a โฆ โจ_, _โฉ
ยท rintro โจht, ha, rflโฉ
obtain h | h := mem_add.1 ha
exacts [โจht, h, erase_add_left_pos t hโฉ, (@irrefl ฮฑ r _ a (ht a h)).elim]
ยท rintro โจht, h, rflโฉ
exact โจht, mem_add.2 (Or.inl h), (erase_add_left_pos t h).symmโฉ
#align relation.cut_expand_iff Relation.cutExpand_iff
theorem not_cutExpand_zero [IsIrrefl ฮฑ r] (s) : ยฌCutExpand r s 0 := by
classical
rw [cutExpand_iff]
rintro โจ_, _, _, โจโฉ, _โฉ
#align relation.not_cut_expand_zero Relation.not_cutExpand_zero
/-- For any relation `r` on `ฮฑ`, multiset addition `Multiset ฮฑ ร Multiset ฮฑ โ Multiset ฮฑ` is a
fibration between the game sum of `CutExpand r` with itself and `CutExpand r` itself. -/
theorem cutExpand_fibration (r : ฮฑ โ ฮฑ โ Prop) :
Fibration (GameAdd (CutExpand r) (CutExpand r)) (CutExpand r) fun s โฆ s.1 + s.2 := by
rintro โจsโ, sโโฉ s โจt, a, hr, heโฉ; dsimp at he โข
classical
obtain โจha, rflโฉ := add_singleton_eq_iff.1 he
rw [add_assoc, mem_add] at ha
obtain h | h := ha
ยท refine' โจ(sโ.erase a + t, sโ), GameAdd.fst โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, โ add_assoc, singleton_add, cons_erase h]
ยท rw [add_assoc sโ, erase_add_left_pos _ h, add_right_comm, add_assoc]
ยท refine' โจ(sโ, (sโ + t).erase a), GameAdd.snd โจt, a, hr, _โฉ, _โฉ
ยท rw [add_comm, singleton_add, cons_erase h]
ยท rw [add_assoc, erase_add_right_pos _ h]
#align relation.cut_expand_fibration Relation.cutExpand_fibration
/-- A multiset is accessible under `CutExpand` if all its singleton subsets are,
assuming `r` is irreflexive. -/
theorem acc_of_singleton [IsIrrefl ฮฑ r] {s : Multiset ฮฑ} (hs : โ a โ s, Acc (CutExpand r) {a}) :
Acc (CutExpand r) s := by
induction s using Multiset.induction
case empty => exact Acc.intro 0 fun s h โฆ (not_cutExpand_zero s h).elim
case cons a s ihs =>
rw [โ s.singleton_add a]
rw [forall_mem_cons] at hs
exact (hs.1.prod_gameAdd <| ihs fun a ha โฆ hs.2 a ha).of_fibration _ (cutExpand_fibration r)
#align relation.acc_of_singleton Relation.acc_of_singleton
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
rintro โจt, a, hr, rfl, rflโฉ
refine' acc_of_singleton fun a' โฆ _
rw [erase_singleton, zero_add]
|
exact ih a' โ hr a'
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a} := by
induction' hacc with a h ih
refine' Acc.intro _ fun s โฆ _
classical
simp only [cutExpand_iff, mem_singleton]
rintro โจt, a, hr, rfl, rflโฉ
refine' acc_of_singleton fun a' โฆ _
rw [erase_singleton, zero_add]
|
Mathlib.Logic.Hydra.136_0.cWRHz2gehQLFc75
|
/-- A singleton `{a}` is accessible under `CutExpand r` if `a` is accessible under `r`,
assuming `r` is irreflexive. -/
theorem _root_.Acc.cutExpand [IsIrrefl ฮฑ r] {a : ฮฑ} (hacc : Acc r a) : Acc (CutExpand r) {a}
|
Mathlib_Logic_Hydra
|
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m n : โ
R : Type u_1
instโ : CommSemiring R
x y : R
โข (x + y) ^ 0 = x ^ 0 + โ0 * x ^ (0 - 1) * y + 0 * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by
|
simp
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m n : โ
R : Type u_1
instโ : CommSemiring R
x y : R
โข (x + y) ^ 1 = x ^ 1 + โ1 * x ^ (1 - 1) * y + 0 * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by
|
simp
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m nโ : โ
R : Type u_1
instโ : CommSemiring R
x y : R
n : โ
โข { k // (x + y) ^ (n + 2) = x ^ (n + 2) + โ(n + 2) * x ^ (n + 2 - 1) * y + k * y ^ 2 }
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
|
cases' (powAddExpansion x y (n + 1)) with z hz
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
case mk
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m nโ : โ
R : Type u_1
instโ : CommSemiring R
x y : R
n : โ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
โข { k // (x + y) ^ (n + 2) = x ^ (n + 2) + โ(n + 2) * x ^ (n + 2 - 1) * y + k * y ^ 2 }
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
|
exists x * z + (n + 1) * x ^ n + z * y
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
case mk
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m nโ : โ
R : Type u_1
instโ : CommSemiring R
x y : R
n : โ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
โข (x + y) ^ (n + 2) = x ^ (n + 2) + โ(n + 2) * x ^ (n + 2 - 1) * y + (x * z + (โn + 1) * x ^ n + z * y) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
|
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m nโ : โ
R : Type u_1
instโ : CommSemiring R
x y : R
n : โ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
โข (x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by
|
ring
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m nโ : โ
R : Type u_1
instโ : CommSemiring R
x y : R
n : โ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
โข (x + y) * (x + y) ^ (n + 1) = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by
|
rw [hz]
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m nโ : โ
R : Type u_1
instโ : CommSemiring R
x y : R
n : โ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
โข (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) =
x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (โn + 1) * x ^ n + z * y) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
|
push_cast
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
Rโ : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : Rโ
m nโ : โ
R : Type u_1
instโ : CommSemiring R
x y : R
n : โ
z : R
hz : (x + y) ^ (n + 1) = x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2
โข (x + y) * (x ^ (n + 1) + (โn + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) =
x ^ (n + 2) + (โn + 2) * x ^ (n + 1) * y + (x * z + (โn + 1) * x ^ n + z * y) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
|
ring!
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
|
Mathlib.Data.Polynomial.Identities.37_0.o6IrpyrTENfZuiK
|
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1)
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
aโ b : R
m n : โ
instโ : CommRing R
x y : R
e : โ
a : R
โข { k // a * (x + y) ^ e = a * (x ^ e + โe * x ^ (e - 1) * y + k * y ^ 2) }
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
|
exists (powAddExpansion x y e).val
|
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
|
Mathlib.Data.Polynomial.Identities.56_0.o6IrpyrTENfZuiK
|
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
aโ b : R
m n : โ
instโ : CommRing R
x y : R
e : โ
a : R
โข a * (x + y) ^ e = a * (x ^ e + โe * x ^ (e - 1) * y + โ(powAddExpansion x y e) * y ^ 2)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
|
congr
|
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
|
Mathlib.Data.Polynomial.Identities.56_0.o6IrpyrTENfZuiK
|
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) }
|
Mathlib_Data_Polynomial_Identities
|
case e_a
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
aโ b : R
m n : โ
instโ : CommRing R
x y : R
e : โ
a : R
โข (x + y) ^ e = x ^ e + โe * x ^ (e - 1) * y + โ(powAddExpansion x y e) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
|
apply (powAddExpansion _ _ _).property
|
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
|
Mathlib.Data.Polynomial.Identities.56_0.o6IrpyrTENfZuiK
|
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข eval (x + y) f = sum f fun e a => a * (x ^ e + โe * x ^ (e - 1) * y + โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
|
unfold eval
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
|
Mathlib.Data.Polynomial.Identities.62_0.o6IrpyrTENfZuiK
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2)
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข evalโ (RingHom.id R) (x + y) f =
sum f fun e a => a * (x ^ e + โe * x ^ (e - 1) * y + โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval;
|
rw [evalโ_eq_sum]
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval;
|
Mathlib.Data.Polynomial.Identities.62_0.o6IrpyrTENfZuiK
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2)
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (sum f fun e a => (RingHom.id R) a * (x + y) ^ e) =
sum f fun e a => a * (x ^ e + โe * x ^ (e - 1) * y + โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum];
|
congr with (n z)
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum];
|
Mathlib.Data.Polynomial.Identities.62_0.o6IrpyrTENfZuiK
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2)
|
Mathlib_Data_Polynomial_Identities
|
case e_f.h.h
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m nโ : โ
instโ : CommRing R
f : R[X]
x y : R
n : โ
z : R
โข (RingHom.id R) z * (x + y) ^ n = z * (x ^ n + โn * x ^ (n - 1) * y + โ(Polynomial.polyBinomAux1 x y n z) * y ^ 2)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
|
apply (polyBinomAux1 x y _ _).property
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
|
Mathlib.Data.Polynomial.Identities.62_0.o6IrpyrTENfZuiK
|
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2)
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข eval (x + y) f =
((sum f fun e a => a * x ^ e) + sum f fun e a => a * โe * x ^ (e - 1) * y) +
sum f fun e a => a * โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
|
rw [poly_binom_aux2]
|
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
|
Mathlib.Data.Polynomial.Identities.68_0.o6IrpyrTENfZuiK
|
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (sum f fun e a => a * (x ^ e + โe * x ^ (e - 1) * y + โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2)) =
((sum f fun e a => a * x ^ e) + sum f fun e a => a * โe * x ^ (e - 1) * y) +
sum f fun e a => a * โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
|
simp [left_distrib, sum_add, mul_assoc]
|
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
|
Mathlib.Data.Polynomial.Identities.68_0.o6IrpyrTENfZuiK
|
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข { k // eval (x + y) f = eval x f + eval x (derivative f) * y + k * y ^ 2 }
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
|
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
|
Mathlib.Data.Polynomial.Identities.75_0.o6IrpyrTENfZuiK
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข eval (x + y) f =
eval x f + eval x (derivative f) * y + (sum f fun e a => a * โ(Polynomial.polyBinomAux1 x y e a)) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
|
rw [poly_binom_aux3]
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
|
Mathlib.Data.Polynomial.Identities.75_0.o6IrpyrTENfZuiK
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (((sum f fun e a => a * x ^ e) + sum f fun e a => a * โe * x ^ (e - 1) * y) +
sum f fun e a => a * โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2) =
eval x f + eval x (derivative f) * y + (sum f fun e a => a * โ(Polynomial.polyBinomAux1 x y e a)) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
|
congr
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
|
Mathlib.Data.Polynomial.Identities.75_0.o6IrpyrTENfZuiK
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 }
|
Mathlib_Data_Polynomial_Identities
|
case e_a.e_a
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (sum f fun e a => a * x ^ e) = eval x f
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท
|
rw [โ eval_eq_sum]
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท
|
Mathlib.Data.Polynomial.Identities.75_0.o6IrpyrTENfZuiK
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 }
|
Mathlib_Data_Polynomial_Identities
|
case e_a.e_a
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (sum f fun e a => a * โe * x ^ (e - 1) * y) = eval x (derivative f) * y
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท
|
rw [derivative_eval]
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท
|
Mathlib.Data.Polynomial.Identities.75_0.o6IrpyrTENfZuiK
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 }
|
Mathlib_Data_Polynomial_Identities
|
case e_a.e_a
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (sum f fun e a => a * โe * x ^ (e - 1) * y) = (sum f fun n a => a * โn * x ^ (n - 1)) * y
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
|
exact Finset.sum_mul.symm
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
|
Mathlib.Data.Polynomial.Identities.75_0.o6IrpyrTENfZuiK
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 }
|
Mathlib_Data_Polynomial_Identities
|
case e_a
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (sum f fun e a => a * โ(Polynomial.polyBinomAux1 x y e a) * y ^ 2) =
(sum f fun e a => a * โ(Polynomial.polyBinomAux1 x y e a)) * y ^ 2
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท
|
exact Finset.sum_mul.symm
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท
|
Mathlib.Data.Polynomial.Identities.75_0.o6IrpyrTENfZuiK
|
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
x y : R
โข x ^ 0 - y ^ 0 = 0 * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by
|
simp
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by
|
Mathlib.Data.Polynomial.Identities.90_0.o6IrpyrTENfZuiK
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
x y : R
โข x ^ 1 - y ^ 1 = 1 * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by
|
simp
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by
|
Mathlib.Data.Polynomial.Identities.90_0.o6IrpyrTENfZuiK
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
kโ : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
x y : R
k : โ
โข { z // x ^ (k + 2) - y ^ (k + 2) = z * (x - y) }
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
|
cases' @powSubPowFactor x y (k + 1) with z hz
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
|
Mathlib.Data.Polynomial.Identities.90_0.o6IrpyrTENfZuiK
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm
|
Mathlib_Data_Polynomial_Identities
|
case mk
R : Type u
S : Type v
T : Type w
ฮน : Type x
kโ : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
x y : R
k : โ
z : R
hz : x ^ (k + 1) - y ^ (k + 1) = z * (x - y)
โข { z // x ^ (k + 2) - y ^ (k + 2) = z * (x - y) }
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
|
exists z * x + y ^ (k + 1)
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
|
Mathlib.Data.Polynomial.Identities.90_0.o6IrpyrTENfZuiK
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm
|
Mathlib_Data_Polynomial_Identities
|
case mk
R : Type u
S : Type v
T : Type w
ฮน : Type x
kโ : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
x y : R
k : โ
z : R
hz : x ^ (k + 1) - y ^ (k + 1) = z * (x - y)
โข x ^ (k + 2) - y ^ (k + 2) = (z * x + y ^ (k + 1)) * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
|
linear_combination (norm := ring) x * hz
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
|
Mathlib.Data.Polynomial.Identities.90_0.o6IrpyrTENfZuiK
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm
|
Mathlib_Data_Polynomial_Identities
|
case a
R : Type u
S : Type v
T : Type w
ฮน : Type x
kโ : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
x y : R
k : โ
z : R
hz : x ^ (k + 1) - y ^ (k + 1) = z * (x - y)
โข x ^ (k + 2) - y ^ (k + 2) - (z * x + y ^ (k + 1)) * (x - y) - (x * (x ^ (k + 1) - y ^ (k + 1)) - x * (z * (x - y))) =
0
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm :=
|
ring
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm :=
|
Mathlib.Data.Polynomial.Identities.90_0.o6IrpyrTENfZuiK
|
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข { z // eval x f - eval y f = z * (x - y) }
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm := ring) x * hz
#align polynomial.pow_sub_pow_factor Polynomial.powSubPowFactor
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
|
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
|
Mathlib.Data.Polynomial.Identities.101_0.o6IrpyrTENfZuiK
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข eval x f - eval y f = (sum f fun i r => r * โ(powSubPowFactor x y i)) * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm := ring) x * hz
#align polynomial.pow_sub_pow_factor Polynomial.powSubPowFactor
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
|
delta eval
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
|
Mathlib.Data.Polynomial.Identities.101_0.o6IrpyrTENfZuiK
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข evalโ (RingHom.id R) x f - evalโ (RingHom.id R) y f = (sum f fun i r => r * โ(powSubPowFactor x y i)) * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm := ring) x * hz
#align polynomial.pow_sub_pow_factor Polynomial.powSubPowFactor
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval;
|
rw [evalโ_eq_sum, evalโ_eq_sum]
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval;
|
Mathlib.Data.Polynomial.Identities.101_0.o6IrpyrTENfZuiK
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข ((sum f fun e a => (RingHom.id R) a * x ^ e) - sum f fun e a => (RingHom.id R) a * y ^ e) =
(sum f fun i r => r * โ(powSubPowFactor x y i)) * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm := ring) x * hz
#align polynomial.pow_sub_pow_factor Polynomial.powSubPowFactor
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
|
simp only [sum, โ Finset.sum_sub_distrib, Finset.sum_mul]
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
|
Mathlib.Data.Polynomial.Identities.101_0.o6IrpyrTENfZuiK
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (Finset.sum (support f) fun x_1 => (RingHom.id R) (coeff f x_1) * x ^ x_1 - (RingHom.id R) (coeff f x_1) * y ^ x_1) =
Finset.sum (support f) fun x_1 => coeff f x_1 * โ(powSubPowFactor x y x_1) * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm := ring) x * hz
#align polynomial.pow_sub_pow_factor Polynomial.powSubPowFactor
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
simp only [sum, โ Finset.sum_sub_distrib, Finset.sum_mul]
|
dsimp
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
simp only [sum, โ Finset.sum_sub_distrib, Finset.sum_mul]
|
Mathlib.Data.Polynomial.Identities.101_0.o6IrpyrTENfZuiK
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) }
|
Mathlib_Data_Polynomial_Identities
|
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
โข (Finset.sum (support f) fun x_1 => coeff f x_1 * x ^ x_1 - coeff f x_1 * y ^ x_1) =
Finset.sum (support f) fun x_1 => coeff f x_1 * โ(powSubPowFactor x y x_1) * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm := ring) x * hz
#align polynomial.pow_sub_pow_factor Polynomial.powSubPowFactor
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
simp only [sum, โ Finset.sum_sub_distrib, Finset.sum_mul]
dsimp
|
congr with i
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
simp only [sum, โ Finset.sum_sub_distrib, Finset.sum_mul]
dsimp
|
Mathlib.Data.Polynomial.Identities.101_0.o6IrpyrTENfZuiK
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) }
|
Mathlib_Data_Polynomial_Identities
|
case e_f.h
R : Type u
S : Type v
T : Type w
ฮน : Type x
k : Type y
A : Type z
a b : R
m n : โ
instโ : CommRing R
f : R[X]
x y : R
i : โ
โข coeff f i * x ^ i - coeff f i * y ^ i = coeff f i * โ(powSubPowFactor x y i) * (x - y)
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hรถlzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Data.Polynomial.Derivative
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Ring
#align_import data.polynomial.identities from "leanprover-community/mathlib"@"4e1eeebe63ac6d44585297e89c6e7ee5cbda487a"
/-!
# Theory of univariate polynomials
The main def is `Polynomial.binomExpansion`.
-/
noncomputable section
namespace Polynomial
open Polynomial
universe u v w x y z
variable {R : Type u} {S : Type v} {T : Type w} {ฮน : Type x} {k : Type y} {A : Type z} {a b : R}
{m n : โ}
section Identities
/- @TODO: `powAddExpansion` and `powSubPowFactor` are not specific to polynomials.
These belong somewhere else. But not in group_power because they depend on tactic.ring_exp
Maybe use `Data.Nat.Choose` to prove it.
-/
/-- `(x + y)^n` can be expressed as `x^n + n*x^(n-1)*y + k * y^2` for some `k` in the ring.
-/
def powAddExpansion {R : Type*} [CommSemiring R] (x y : R) :
โ n : โ, { k // (x + y) ^ n = x ^ n + n * x ^ (n - 1) * y + k * y ^ 2 }
| 0 => โจ0, by simpโฉ
| 1 => โจ0, by simpโฉ
| n + 2 => by
cases' (powAddExpansion x y (n + 1)) with z hz
exists x * z + (n + 1) * x ^ n + z * y
calc
(x + y) ^ (n + 2) = (x + y) * (x + y) ^ (n + 1) := by ring
_ = (x + y) * (x ^ (n + 1) + โ(n + 1) * x ^ (n + 1 - 1) * y + z * y ^ 2) := by rw [hz]
_ = x ^ (n + 2) + โ(n + 2) * x ^ (n + 1) * y + (x * z + (n + 1) * x ^ n + z * y) * y ^ 2 := by
push_cast
ring!
#align polynomial.pow_add_expansion Polynomial.powAddExpansion
variable [CommRing R]
private def polyBinomAux1 (x y : R) (e : โ) (a : R) :
{ k : R // a * (x + y) ^ e = a * (x ^ e + e * x ^ (e - 1) * y + k * y ^ 2) } := by
exists (powAddExpansion x y e).val
congr
apply (powAddExpansion _ _ _).property
private theorem poly_binom_aux2 (f : R[X]) (x y : R) :
f.eval (x + y) =
f.sum fun e a => a * (x ^ e + e * x ^ (e - 1) * y + (polyBinomAux1 x y e a).val * y ^ 2) := by
unfold eval; rw [evalโ_eq_sum]; congr with (n z)
apply (polyBinomAux1 x y _ _).property
private theorem poly_binom_aux3 (f : R[X]) (x y : R) :
f.eval (x + y) =
((f.sum fun e a => a * x ^ e) + f.sum fun e a => a * e * x ^ (e - 1) * y) +
f.sum fun e a => a * (polyBinomAux1 x y e a).val * y ^ 2 := by
rw [poly_binom_aux2]
simp [left_distrib, sum_add, mul_assoc]
/-- A polynomial `f` evaluated at `x + y` can be expressed as
the evaluation of `f` at `x`, plus `y` times the (polynomial) derivative of `f` at `x`,
plus some element `k : R` times `y^2`.
-/
def binomExpansion (f : R[X]) (x y : R) :
{ k : R // f.eval (x + y) = f.eval x + f.derivative.eval x * y + k * y ^ 2 } := by
exists f.sum fun e a => a * (polyBinomAux1 x y e a).val
rw [poly_binom_aux3]
congr
ยท rw [โ eval_eq_sum]
ยท rw [derivative_eval]
exact Finset.sum_mul.symm
ยท exact Finset.sum_mul.symm
#align polynomial.binom_expansion Polynomial.binomExpansion
/-- `x^n - y^n` can be expressed as `z * (x - y)` for some `z` in the ring.
-/
def powSubPowFactor (x y : R) : โ i : โ, { z : R // x ^ i - y ^ i = z * (x - y) }
| 0 => โจ0, by simpโฉ
| 1 => โจ1, by simpโฉ
| k + 2 => by
cases' @powSubPowFactor x y (k + 1) with z hz
exists z * x + y ^ (k + 1)
linear_combination (norm := ring) x * hz
#align polynomial.pow_sub_pow_factor Polynomial.powSubPowFactor
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
simp only [sum, โ Finset.sum_sub_distrib, Finset.sum_mul]
dsimp
congr with i
|
rw [mul_assoc, โ (powSubPowFactor x y _).prop, mul_sub]
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) } := by
refine' โจf.sum fun i r => r * (powSubPowFactor x y i).val, _โฉ
delta eval; rw [evalโ_eq_sum, evalโ_eq_sum];
simp only [sum, โ Finset.sum_sub_distrib, Finset.sum_mul]
dsimp
congr with i
|
Mathlib.Data.Polynomial.Identities.101_0.o6IrpyrTENfZuiK
|
/-- For any polynomial `f`, `f.eval x - f.eval y` can be expressed as `z * (x - y)`
for some `z` in the ring.
-/
def evalSubFactor (f : R[X]) (x y : R) : { z : R // f.eval x - f.eval y = z * (x - y) }
|
Mathlib_Data_Polynomial_Identities
|
ฮน : Type u_1
ฮฑ : Type u_2
M : Type u_3
N : Type u_4
X : Type u_5
instโยณ : TopologicalSpace X
instโยฒ : TopologicalSpace M
instโยน : Mul M
instโ : ContinuousMul M
a b : M
โข ๐ a * ๐ b โค ๐ (a * b)
|
/-
Copyright (c) 2017 Johannes Hรถlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hรถlzl, Mario Carneiro
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Order.Filter.Pointwise
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Topology.ContinuousFunction.Basic
#align_import topology.algebra.monoid from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353"
/-!
# Theory of topological monoids
In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many
applications the underlying type is a monoid (multiplicative or additive), we do not require this in
the definitions.
-/
universe u v
open Classical Set Filter TopologicalSpace
open Classical Topology BigOperators Pointwise
variable {ฮน ฮฑ M N X : Type*} [TopologicalSpace X]
@[to_additive (attr := continuity)]
theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X โ M) :=
@continuous_const _ _ _ _ 1
#align continuous_one continuous_one
#align continuous_zero continuous_zero
/-- Basic hypothesis to talk about a topological additive monoid or a topological additive
semigroup. A topological additive monoid over `M`, for example, is obtained by requiring both the
instances `AddMonoid M` and `ContinuousAdd M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstVAdd ฮฑ ฮฑ`/`ContinuousConstVAdd ฮฑแตแตแต ฮฑ`. -/
class ContinuousAdd (M : Type u) [TopologicalSpace M] [Add M] : Prop where
continuous_add : Continuous fun p : M ร M => p.1 + p.2
#align has_continuous_add ContinuousAdd
/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.
A topological monoid over `M`, for example, is obtained by requiring both the instances `Monoid M`
and `ContinuousMul M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstSMul ฮฑ ฮฑ`/`ContinuousConstSMul ฮฑแตแตแต ฮฑ`. -/
@[to_additive]
class ContinuousMul (M : Type u) [TopologicalSpace M] [Mul M] : Prop where
continuous_mul : Continuous fun p : M ร M => p.1 * p.2
#align has_continuous_mul ContinuousMul
section ContinuousMul
variable [TopologicalSpace M] [Mul M] [ContinuousMul M]
@[to_additive]
instance : ContinuousMul Mแตแต :=
โนContinuousMul Mโบ
@[to_additive (attr := continuity)]
theorem continuous_mul : Continuous fun p : M ร M => p.1 * p.2 :=
ContinuousMul.continuous_mul
#align continuous_mul continuous_mul
#align continuous_add continuous_add
@[to_additive]
instance ContinuousMul.to_continuousSMul : ContinuousSMul M M :=
โจcontinuous_mulโฉ
#align has_continuous_mul.to_has_continuous_smul ContinuousMul.to_continuousSMul
#align has_continuous_add.to_has_continuous_vadd ContinuousAdd.to_continuousVAdd
@[to_additive]
instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mแตแตแต M :=
โจshow Continuous ((fun p : M ร M => p.1 * p.2) โ Prod.swap โ Prod.map MulOpposite.unop id) from
continuous_mul.comp <|
continuous_swap.comp <| Continuous.prod_map MulOpposite.continuous_unop continuous_idโฉ
#align has_continuous_mul.to_has_continuous_smul_op ContinuousMul.to_continuousSMul_op
#align has_continuous_add.to_has_continuous_vadd_op ContinuousAdd.to_continuousVAdd_op
@[to_additive (attr := continuity)]
theorem Continuous.mul {f g : X โ M} (hf : Continuous f) (hg : Continuous g) :
Continuous fun x => f x * g x :=
continuous_mul.comp (hf.prod_mk hg : _)
#align continuous.mul Continuous.mul
#align continuous.add Continuous.add
@[to_additive (attr := continuity)]
theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b :=
continuous_const.mul continuous_id
#align continuous_mul_left continuous_mul_left
#align continuous_add_left continuous_add_left
@[to_additive (attr := continuity)]
theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a :=
continuous_id.mul continuous_const
#align continuous_mul_right continuous_mul_right
#align continuous_add_right continuous_add_right
@[to_additive]
theorem ContinuousOn.mul {f g : X โ M} {s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x => f x * g x) s :=
(continuous_mul.comp_continuousOn (hf.prod hg) : _)
#align continuous_on.mul ContinuousOn.mul
#align continuous_on.add ContinuousOn.add
@[to_additive]
theorem tendsto_mul {a b : M} : Tendsto (fun p : M ร M => p.fst * p.snd) (๐ (a, b)) (๐ (a * b)) :=
continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b)
#align tendsto_mul tendsto_mul
#align tendsto_add tendsto_add
@[to_additive]
theorem Filter.Tendsto.mul {f g : ฮฑ โ M} {x : Filter ฮฑ} {a b : M} (hf : Tendsto f x (๐ a))
(hg : Tendsto g x (๐ b)) : Tendsto (fun x => f x * g x) x (๐ (a * b)) :=
tendsto_mul.comp (hf.prod_mk_nhds hg)
#align filter.tendsto.mul Filter.Tendsto.mul
#align filter.tendsto.add Filter.Tendsto.add
@[to_additive]
theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => b * f k) l (๐ (b * c)) :=
tendsto_const_nhds.mul h
#align filter.tendsto.const_mul Filter.Tendsto.const_mul
#align filter.tendsto.const_add Filter.Tendsto.const_add
@[to_additive]
theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => f k * b) l (๐ (c * b)) :=
h.mul tendsto_const_nhds
#align filter.tendsto.mul_const Filter.Tendsto.mul_const
#align filter.tendsto.add_const Filter.Tendsto.add_const
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b) := by
|
rw [โ mapโ_mul, โ map_uncurry_prod, โ nhds_prod_eq]
|
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b) := by
|
Mathlib.Topology.Algebra.Monoid.139_0.3p9EZf9ZWFxWOAq
|
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b)
|
Mathlib_Topology_Algebra_Monoid
|
ฮน : Type u_1
ฮฑ : Type u_2
M : Type u_3
N : Type u_4
X : Type u_5
instโยณ : TopologicalSpace X
instโยฒ : TopologicalSpace M
instโยน : Mul M
instโ : ContinuousMul M
a b : M
โข map (Function.uncurry fun x x_1 => x * x_1) (๐ (a, b)) โค ๐ (a * b)
|
/-
Copyright (c) 2017 Johannes Hรถlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hรถlzl, Mario Carneiro
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Order.Filter.Pointwise
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Topology.ContinuousFunction.Basic
#align_import topology.algebra.monoid from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353"
/-!
# Theory of topological monoids
In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many
applications the underlying type is a monoid (multiplicative or additive), we do not require this in
the definitions.
-/
universe u v
open Classical Set Filter TopologicalSpace
open Classical Topology BigOperators Pointwise
variable {ฮน ฮฑ M N X : Type*} [TopologicalSpace X]
@[to_additive (attr := continuity)]
theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X โ M) :=
@continuous_const _ _ _ _ 1
#align continuous_one continuous_one
#align continuous_zero continuous_zero
/-- Basic hypothesis to talk about a topological additive monoid or a topological additive
semigroup. A topological additive monoid over `M`, for example, is obtained by requiring both the
instances `AddMonoid M` and `ContinuousAdd M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstVAdd ฮฑ ฮฑ`/`ContinuousConstVAdd ฮฑแตแตแต ฮฑ`. -/
class ContinuousAdd (M : Type u) [TopologicalSpace M] [Add M] : Prop where
continuous_add : Continuous fun p : M ร M => p.1 + p.2
#align has_continuous_add ContinuousAdd
/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.
A topological monoid over `M`, for example, is obtained by requiring both the instances `Monoid M`
and `ContinuousMul M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstSMul ฮฑ ฮฑ`/`ContinuousConstSMul ฮฑแตแตแต ฮฑ`. -/
@[to_additive]
class ContinuousMul (M : Type u) [TopologicalSpace M] [Mul M] : Prop where
continuous_mul : Continuous fun p : M ร M => p.1 * p.2
#align has_continuous_mul ContinuousMul
section ContinuousMul
variable [TopologicalSpace M] [Mul M] [ContinuousMul M]
@[to_additive]
instance : ContinuousMul Mแตแต :=
โนContinuousMul Mโบ
@[to_additive (attr := continuity)]
theorem continuous_mul : Continuous fun p : M ร M => p.1 * p.2 :=
ContinuousMul.continuous_mul
#align continuous_mul continuous_mul
#align continuous_add continuous_add
@[to_additive]
instance ContinuousMul.to_continuousSMul : ContinuousSMul M M :=
โจcontinuous_mulโฉ
#align has_continuous_mul.to_has_continuous_smul ContinuousMul.to_continuousSMul
#align has_continuous_add.to_has_continuous_vadd ContinuousAdd.to_continuousVAdd
@[to_additive]
instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mแตแตแต M :=
โจshow Continuous ((fun p : M ร M => p.1 * p.2) โ Prod.swap โ Prod.map MulOpposite.unop id) from
continuous_mul.comp <|
continuous_swap.comp <| Continuous.prod_map MulOpposite.continuous_unop continuous_idโฉ
#align has_continuous_mul.to_has_continuous_smul_op ContinuousMul.to_continuousSMul_op
#align has_continuous_add.to_has_continuous_vadd_op ContinuousAdd.to_continuousVAdd_op
@[to_additive (attr := continuity)]
theorem Continuous.mul {f g : X โ M} (hf : Continuous f) (hg : Continuous g) :
Continuous fun x => f x * g x :=
continuous_mul.comp (hf.prod_mk hg : _)
#align continuous.mul Continuous.mul
#align continuous.add Continuous.add
@[to_additive (attr := continuity)]
theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b :=
continuous_const.mul continuous_id
#align continuous_mul_left continuous_mul_left
#align continuous_add_left continuous_add_left
@[to_additive (attr := continuity)]
theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a :=
continuous_id.mul continuous_const
#align continuous_mul_right continuous_mul_right
#align continuous_add_right continuous_add_right
@[to_additive]
theorem ContinuousOn.mul {f g : X โ M} {s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x => f x * g x) s :=
(continuous_mul.comp_continuousOn (hf.prod hg) : _)
#align continuous_on.mul ContinuousOn.mul
#align continuous_on.add ContinuousOn.add
@[to_additive]
theorem tendsto_mul {a b : M} : Tendsto (fun p : M ร M => p.fst * p.snd) (๐ (a, b)) (๐ (a * b)) :=
continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b)
#align tendsto_mul tendsto_mul
#align tendsto_add tendsto_add
@[to_additive]
theorem Filter.Tendsto.mul {f g : ฮฑ โ M} {x : Filter ฮฑ} {a b : M} (hf : Tendsto f x (๐ a))
(hg : Tendsto g x (๐ b)) : Tendsto (fun x => f x * g x) x (๐ (a * b)) :=
tendsto_mul.comp (hf.prod_mk_nhds hg)
#align filter.tendsto.mul Filter.Tendsto.mul
#align filter.tendsto.add Filter.Tendsto.add
@[to_additive]
theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => b * f k) l (๐ (b * c)) :=
tendsto_const_nhds.mul h
#align filter.tendsto.const_mul Filter.Tendsto.const_mul
#align filter.tendsto.const_add Filter.Tendsto.const_add
@[to_additive]
theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => f k * b) l (๐ (c * b)) :=
h.mul tendsto_const_nhds
#align filter.tendsto.mul_const Filter.Tendsto.mul_const
#align filter.tendsto.add_const Filter.Tendsto.add_const
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b) := by
rw [โ mapโ_mul, โ map_uncurry_prod, โ nhds_prod_eq]
|
exact continuous_mul.tendsto _
|
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b) := by
rw [โ mapโ_mul, โ map_uncurry_prod, โ nhds_prod_eq]
|
Mathlib.Topology.Algebra.Monoid.139_0.3p9EZf9ZWFxWOAq
|
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b)
|
Mathlib_Topology_Algebra_Monoid
|
ฮน : Type u_1
ฮฑ : Type u_2
M : Type u_3
N : Type u_4
X : Type u_5
instโโธ : TopologicalSpace X
instโโท : TopologicalSpace M
instโโถ : Mul M
instโโต : ContinuousMul M
instโโด : TopologicalSpace N
instโยณ : Monoid N
instโยฒ : ContinuousMul N
instโยน : T2Space N
f : ฮน โ Nหฃ
rโ rโ : N
l : Filter ฮน
instโ : NeBot l
hโ : Tendsto (fun x => โ(f x)) l (๐ rโ)
hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)
โข rโ * rโ = 1
|
/-
Copyright (c) 2017 Johannes Hรถlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hรถlzl, Mario Carneiro
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Order.Filter.Pointwise
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Topology.ContinuousFunction.Basic
#align_import topology.algebra.monoid from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353"
/-!
# Theory of topological monoids
In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many
applications the underlying type is a monoid (multiplicative or additive), we do not require this in
the definitions.
-/
universe u v
open Classical Set Filter TopologicalSpace
open Classical Topology BigOperators Pointwise
variable {ฮน ฮฑ M N X : Type*} [TopologicalSpace X]
@[to_additive (attr := continuity)]
theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X โ M) :=
@continuous_const _ _ _ _ 1
#align continuous_one continuous_one
#align continuous_zero continuous_zero
/-- Basic hypothesis to talk about a topological additive monoid or a topological additive
semigroup. A topological additive monoid over `M`, for example, is obtained by requiring both the
instances `AddMonoid M` and `ContinuousAdd M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstVAdd ฮฑ ฮฑ`/`ContinuousConstVAdd ฮฑแตแตแต ฮฑ`. -/
class ContinuousAdd (M : Type u) [TopologicalSpace M] [Add M] : Prop where
continuous_add : Continuous fun p : M ร M => p.1 + p.2
#align has_continuous_add ContinuousAdd
/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.
A topological monoid over `M`, for example, is obtained by requiring both the instances `Monoid M`
and `ContinuousMul M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstSMul ฮฑ ฮฑ`/`ContinuousConstSMul ฮฑแตแตแต ฮฑ`. -/
@[to_additive]
class ContinuousMul (M : Type u) [TopologicalSpace M] [Mul M] : Prop where
continuous_mul : Continuous fun p : M ร M => p.1 * p.2
#align has_continuous_mul ContinuousMul
section ContinuousMul
variable [TopologicalSpace M] [Mul M] [ContinuousMul M]
@[to_additive]
instance : ContinuousMul Mแตแต :=
โนContinuousMul Mโบ
@[to_additive (attr := continuity)]
theorem continuous_mul : Continuous fun p : M ร M => p.1 * p.2 :=
ContinuousMul.continuous_mul
#align continuous_mul continuous_mul
#align continuous_add continuous_add
@[to_additive]
instance ContinuousMul.to_continuousSMul : ContinuousSMul M M :=
โจcontinuous_mulโฉ
#align has_continuous_mul.to_has_continuous_smul ContinuousMul.to_continuousSMul
#align has_continuous_add.to_has_continuous_vadd ContinuousAdd.to_continuousVAdd
@[to_additive]
instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mแตแตแต M :=
โจshow Continuous ((fun p : M ร M => p.1 * p.2) โ Prod.swap โ Prod.map MulOpposite.unop id) from
continuous_mul.comp <|
continuous_swap.comp <| Continuous.prod_map MulOpposite.continuous_unop continuous_idโฉ
#align has_continuous_mul.to_has_continuous_smul_op ContinuousMul.to_continuousSMul_op
#align has_continuous_add.to_has_continuous_vadd_op ContinuousAdd.to_continuousVAdd_op
@[to_additive (attr := continuity)]
theorem Continuous.mul {f g : X โ M} (hf : Continuous f) (hg : Continuous g) :
Continuous fun x => f x * g x :=
continuous_mul.comp (hf.prod_mk hg : _)
#align continuous.mul Continuous.mul
#align continuous.add Continuous.add
@[to_additive (attr := continuity)]
theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b :=
continuous_const.mul continuous_id
#align continuous_mul_left continuous_mul_left
#align continuous_add_left continuous_add_left
@[to_additive (attr := continuity)]
theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a :=
continuous_id.mul continuous_const
#align continuous_mul_right continuous_mul_right
#align continuous_add_right continuous_add_right
@[to_additive]
theorem ContinuousOn.mul {f g : X โ M} {s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x => f x * g x) s :=
(continuous_mul.comp_continuousOn (hf.prod hg) : _)
#align continuous_on.mul ContinuousOn.mul
#align continuous_on.add ContinuousOn.add
@[to_additive]
theorem tendsto_mul {a b : M} : Tendsto (fun p : M ร M => p.fst * p.snd) (๐ (a, b)) (๐ (a * b)) :=
continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b)
#align tendsto_mul tendsto_mul
#align tendsto_add tendsto_add
@[to_additive]
theorem Filter.Tendsto.mul {f g : ฮฑ โ M} {x : Filter ฮฑ} {a b : M} (hf : Tendsto f x (๐ a))
(hg : Tendsto g x (๐ b)) : Tendsto (fun x => f x * g x) x (๐ (a * b)) :=
tendsto_mul.comp (hf.prod_mk_nhds hg)
#align filter.tendsto.mul Filter.Tendsto.mul
#align filter.tendsto.add Filter.Tendsto.add
@[to_additive]
theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => b * f k) l (๐ (b * c)) :=
tendsto_const_nhds.mul h
#align filter.tendsto.const_mul Filter.Tendsto.const_mul
#align filter.tendsto.const_add Filter.Tendsto.const_add
@[to_additive]
theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => f k * b) l (๐ (c * b)) :=
h.mul tendsto_const_nhds
#align filter.tendsto.mul_const Filter.Tendsto.mul_const
#align filter.tendsto.add_const Filter.Tendsto.add_const
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b) := by
rw [โ mapโ_mul, โ map_uncurry_prod, โ nhds_prod_eq]
exact continuous_mul.tendsto _
#align le_nhds_mul le_nhds_mul
#align le_nhds_add le_nhds_add
@[to_additive (attr := simp)]
theorem nhds_one_mul_nhds {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
๐ (1 : M) * ๐ a = ๐ a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (one_mul a)).antisymm <|
le_mul_of_one_le_left' <| pure_le_nhds 1
#align nhds_one_mul_nhds nhds_one_mul_nhds
#align nhds_zero_add_nhds nhds_zero_add_nhds
@[to_additive (attr := simp)]
theorem nhds_mul_nhds_one {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
๐ a * ๐ 1 = ๐ a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (mul_one a)).antisymm <|
le_mul_of_one_le_right' <| pure_le_nhds 1
#align nhds_mul_nhds_one nhds_mul_nhds_one
#align nhds_add_nhds_zero nhds_add_nhds_zero
section tendsto_nhds
variable {๐ : Type*} [Preorder ๐] [Zero ๐] [Mul ๐] [TopologicalSpace ๐] [ContinuousMul ๐]
{l : Filter ฮฑ} {f : ฮฑ โ ๐} {b c : ๐} (hb : 0 < b)
theorem Filter.TendstoNhdsWithinIoi.const_mul [PosMulStrictMono ๐] [PosMulReflectLT ๐]
(h : Tendsto f l (๐[>] c)) : Tendsto (fun a => b * f a) l (๐[>] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Ioi.const_mul Filter.TendstoNhdsWithinIoi.const_mul
theorem Filter.TendstoNhdsWithinIio.const_mul [PosMulStrictMono ๐] [PosMulReflectLT ๐]
(h : Tendsto f l (๐[<] c)) : Tendsto (fun a => b * f a) l (๐[<] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Iio.const_mul Filter.TendstoNhdsWithinIio.const_mul
theorem Filter.TendstoNhdsWithinIoi.mul_const [MulPosStrictMono ๐] [MulPosReflectLT ๐]
(h : Tendsto f l (๐[>] c)) : Tendsto (fun a => f a * b) l (๐[>] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Ioi.mul_const Filter.TendstoNhdsWithinIoi.mul_const
theorem Filter.TendstoNhdsWithinIio.mul_const [MulPosStrictMono ๐] [MulPosReflectLT ๐]
(h : Tendsto f l (๐[<] c)) : Tendsto (fun a => f a * b) l (๐[<] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Iio.mul_const Filter.TendstoNhdsWithinIio.mul_const
end tendsto_nhds
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ฮน โ Nหฃ} {rโ rโ : N} {l : Filter ฮน} [l.NeBot] (hโ : Tendsto (fun x => โ(f x)) l (๐ rโ))
(hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)) : Nหฃ
where
val := rโ
inv := rโ
val_inv := by
|
symm
|
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ฮน โ Nหฃ} {rโ rโ : N} {l : Filter ฮน} [l.NeBot] (hโ : Tendsto (fun x => โ(f x)) l (๐ rโ))
(hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)) : Nหฃ
where
val := rโ
inv := rโ
val_inv := by
|
Mathlib.Topology.Algebra.Monoid.197_0.3p9EZf9ZWFxWOAq
|
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr
|
Mathlib_Topology_Algebra_Monoid
|
ฮน : Type u_1
ฮฑ : Type u_2
M : Type u_3
N : Type u_4
X : Type u_5
instโโธ : TopologicalSpace X
instโโท : TopologicalSpace M
instโโถ : Mul M
instโโต : ContinuousMul M
instโโด : TopologicalSpace N
instโยณ : Monoid N
instโยฒ : ContinuousMul N
instโยน : T2Space N
f : ฮน โ Nหฃ
rโ rโ : N
l : Filter ฮน
instโ : NeBot l
hโ : Tendsto (fun x => โ(f x)) l (๐ rโ)
hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)
โข 1 = rโ * rโ
|
/-
Copyright (c) 2017 Johannes Hรถlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hรถlzl, Mario Carneiro
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Order.Filter.Pointwise
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Topology.ContinuousFunction.Basic
#align_import topology.algebra.monoid from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353"
/-!
# Theory of topological monoids
In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many
applications the underlying type is a monoid (multiplicative or additive), we do not require this in
the definitions.
-/
universe u v
open Classical Set Filter TopologicalSpace
open Classical Topology BigOperators Pointwise
variable {ฮน ฮฑ M N X : Type*} [TopologicalSpace X]
@[to_additive (attr := continuity)]
theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X โ M) :=
@continuous_const _ _ _ _ 1
#align continuous_one continuous_one
#align continuous_zero continuous_zero
/-- Basic hypothesis to talk about a topological additive monoid or a topological additive
semigroup. A topological additive monoid over `M`, for example, is obtained by requiring both the
instances `AddMonoid M` and `ContinuousAdd M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstVAdd ฮฑ ฮฑ`/`ContinuousConstVAdd ฮฑแตแตแต ฮฑ`. -/
class ContinuousAdd (M : Type u) [TopologicalSpace M] [Add M] : Prop where
continuous_add : Continuous fun p : M ร M => p.1 + p.2
#align has_continuous_add ContinuousAdd
/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.
A topological monoid over `M`, for example, is obtained by requiring both the instances `Monoid M`
and `ContinuousMul M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstSMul ฮฑ ฮฑ`/`ContinuousConstSMul ฮฑแตแตแต ฮฑ`. -/
@[to_additive]
class ContinuousMul (M : Type u) [TopologicalSpace M] [Mul M] : Prop where
continuous_mul : Continuous fun p : M ร M => p.1 * p.2
#align has_continuous_mul ContinuousMul
section ContinuousMul
variable [TopologicalSpace M] [Mul M] [ContinuousMul M]
@[to_additive]
instance : ContinuousMul Mแตแต :=
โนContinuousMul Mโบ
@[to_additive (attr := continuity)]
theorem continuous_mul : Continuous fun p : M ร M => p.1 * p.2 :=
ContinuousMul.continuous_mul
#align continuous_mul continuous_mul
#align continuous_add continuous_add
@[to_additive]
instance ContinuousMul.to_continuousSMul : ContinuousSMul M M :=
โจcontinuous_mulโฉ
#align has_continuous_mul.to_has_continuous_smul ContinuousMul.to_continuousSMul
#align has_continuous_add.to_has_continuous_vadd ContinuousAdd.to_continuousVAdd
@[to_additive]
instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mแตแตแต M :=
โจshow Continuous ((fun p : M ร M => p.1 * p.2) โ Prod.swap โ Prod.map MulOpposite.unop id) from
continuous_mul.comp <|
continuous_swap.comp <| Continuous.prod_map MulOpposite.continuous_unop continuous_idโฉ
#align has_continuous_mul.to_has_continuous_smul_op ContinuousMul.to_continuousSMul_op
#align has_continuous_add.to_has_continuous_vadd_op ContinuousAdd.to_continuousVAdd_op
@[to_additive (attr := continuity)]
theorem Continuous.mul {f g : X โ M} (hf : Continuous f) (hg : Continuous g) :
Continuous fun x => f x * g x :=
continuous_mul.comp (hf.prod_mk hg : _)
#align continuous.mul Continuous.mul
#align continuous.add Continuous.add
@[to_additive (attr := continuity)]
theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b :=
continuous_const.mul continuous_id
#align continuous_mul_left continuous_mul_left
#align continuous_add_left continuous_add_left
@[to_additive (attr := continuity)]
theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a :=
continuous_id.mul continuous_const
#align continuous_mul_right continuous_mul_right
#align continuous_add_right continuous_add_right
@[to_additive]
theorem ContinuousOn.mul {f g : X โ M} {s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x => f x * g x) s :=
(continuous_mul.comp_continuousOn (hf.prod hg) : _)
#align continuous_on.mul ContinuousOn.mul
#align continuous_on.add ContinuousOn.add
@[to_additive]
theorem tendsto_mul {a b : M} : Tendsto (fun p : M ร M => p.fst * p.snd) (๐ (a, b)) (๐ (a * b)) :=
continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b)
#align tendsto_mul tendsto_mul
#align tendsto_add tendsto_add
@[to_additive]
theorem Filter.Tendsto.mul {f g : ฮฑ โ M} {x : Filter ฮฑ} {a b : M} (hf : Tendsto f x (๐ a))
(hg : Tendsto g x (๐ b)) : Tendsto (fun x => f x * g x) x (๐ (a * b)) :=
tendsto_mul.comp (hf.prod_mk_nhds hg)
#align filter.tendsto.mul Filter.Tendsto.mul
#align filter.tendsto.add Filter.Tendsto.add
@[to_additive]
theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => b * f k) l (๐ (b * c)) :=
tendsto_const_nhds.mul h
#align filter.tendsto.const_mul Filter.Tendsto.const_mul
#align filter.tendsto.const_add Filter.Tendsto.const_add
@[to_additive]
theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => f k * b) l (๐ (c * b)) :=
h.mul tendsto_const_nhds
#align filter.tendsto.mul_const Filter.Tendsto.mul_const
#align filter.tendsto.add_const Filter.Tendsto.add_const
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b) := by
rw [โ mapโ_mul, โ map_uncurry_prod, โ nhds_prod_eq]
exact continuous_mul.tendsto _
#align le_nhds_mul le_nhds_mul
#align le_nhds_add le_nhds_add
@[to_additive (attr := simp)]
theorem nhds_one_mul_nhds {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
๐ (1 : M) * ๐ a = ๐ a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (one_mul a)).antisymm <|
le_mul_of_one_le_left' <| pure_le_nhds 1
#align nhds_one_mul_nhds nhds_one_mul_nhds
#align nhds_zero_add_nhds nhds_zero_add_nhds
@[to_additive (attr := simp)]
theorem nhds_mul_nhds_one {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
๐ a * ๐ 1 = ๐ a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (mul_one a)).antisymm <|
le_mul_of_one_le_right' <| pure_le_nhds 1
#align nhds_mul_nhds_one nhds_mul_nhds_one
#align nhds_add_nhds_zero nhds_add_nhds_zero
section tendsto_nhds
variable {๐ : Type*} [Preorder ๐] [Zero ๐] [Mul ๐] [TopologicalSpace ๐] [ContinuousMul ๐]
{l : Filter ฮฑ} {f : ฮฑ โ ๐} {b c : ๐} (hb : 0 < b)
theorem Filter.TendstoNhdsWithinIoi.const_mul [PosMulStrictMono ๐] [PosMulReflectLT ๐]
(h : Tendsto f l (๐[>] c)) : Tendsto (fun a => b * f a) l (๐[>] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Ioi.const_mul Filter.TendstoNhdsWithinIoi.const_mul
theorem Filter.TendstoNhdsWithinIio.const_mul [PosMulStrictMono ๐] [PosMulReflectLT ๐]
(h : Tendsto f l (๐[<] c)) : Tendsto (fun a => b * f a) l (๐[<] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Iio.const_mul Filter.TendstoNhdsWithinIio.const_mul
theorem Filter.TendstoNhdsWithinIoi.mul_const [MulPosStrictMono ๐] [MulPosReflectLT ๐]
(h : Tendsto f l (๐[>] c)) : Tendsto (fun a => f a * b) l (๐[>] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Ioi.mul_const Filter.TendstoNhdsWithinIoi.mul_const
theorem Filter.TendstoNhdsWithinIio.mul_const [MulPosStrictMono ๐] [MulPosReflectLT ๐]
(h : Tendsto f l (๐[<] c)) : Tendsto (fun a => f a * b) l (๐[<] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Iio.mul_const Filter.TendstoNhdsWithinIio.mul_const
end tendsto_nhds
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ฮน โ Nหฃ} {rโ rโ : N} {l : Filter ฮน} [l.NeBot] (hโ : Tendsto (fun x => โ(f x)) l (๐ rโ))
(hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)) : Nหฃ
where
val := rโ
inv := rโ
val_inv := by
symm
|
simpa using hโ.mul hโ
|
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ฮน โ Nหฃ} {rโ rโ : N} {l : Filter ฮน} [l.NeBot] (hโ : Tendsto (fun x => โ(f x)) l (๐ rโ))
(hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)) : Nหฃ
where
val := rโ
inv := rโ
val_inv := by
symm
|
Mathlib.Topology.Algebra.Monoid.197_0.3p9EZf9ZWFxWOAq
|
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr
|
Mathlib_Topology_Algebra_Monoid
|
ฮน : Type u_1
ฮฑ : Type u_2
M : Type u_3
N : Type u_4
X : Type u_5
instโโธ : TopologicalSpace X
instโโท : TopologicalSpace M
instโโถ : Mul M
instโโต : ContinuousMul M
instโโด : TopologicalSpace N
instโยณ : Monoid N
instโยฒ : ContinuousMul N
instโยน : T2Space N
f : ฮน โ Nหฃ
rโ rโ : N
l : Filter ฮน
instโ : NeBot l
hโ : Tendsto (fun x => โ(f x)) l (๐ rโ)
hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)
โข rโ * rโ = 1
|
/-
Copyright (c) 2017 Johannes Hรถlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hรถlzl, Mario Carneiro
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Order.Filter.Pointwise
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Topology.ContinuousFunction.Basic
#align_import topology.algebra.monoid from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353"
/-!
# Theory of topological monoids
In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many
applications the underlying type is a monoid (multiplicative or additive), we do not require this in
the definitions.
-/
universe u v
open Classical Set Filter TopologicalSpace
open Classical Topology BigOperators Pointwise
variable {ฮน ฮฑ M N X : Type*} [TopologicalSpace X]
@[to_additive (attr := continuity)]
theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X โ M) :=
@continuous_const _ _ _ _ 1
#align continuous_one continuous_one
#align continuous_zero continuous_zero
/-- Basic hypothesis to talk about a topological additive monoid or a topological additive
semigroup. A topological additive monoid over `M`, for example, is obtained by requiring both the
instances `AddMonoid M` and `ContinuousAdd M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstVAdd ฮฑ ฮฑ`/`ContinuousConstVAdd ฮฑแตแตแต ฮฑ`. -/
class ContinuousAdd (M : Type u) [TopologicalSpace M] [Add M] : Prop where
continuous_add : Continuous fun p : M ร M => p.1 + p.2
#align has_continuous_add ContinuousAdd
/-- Basic hypothesis to talk about a topological monoid or a topological semigroup.
A topological monoid over `M`, for example, is obtained by requiring both the instances `Monoid M`
and `ContinuousMul M`.
Continuity in only the left/right argument can be stated using
`ContinuousConstSMul ฮฑ ฮฑ`/`ContinuousConstSMul ฮฑแตแตแต ฮฑ`. -/
@[to_additive]
class ContinuousMul (M : Type u) [TopologicalSpace M] [Mul M] : Prop where
continuous_mul : Continuous fun p : M ร M => p.1 * p.2
#align has_continuous_mul ContinuousMul
section ContinuousMul
variable [TopologicalSpace M] [Mul M] [ContinuousMul M]
@[to_additive]
instance : ContinuousMul Mแตแต :=
โนContinuousMul Mโบ
@[to_additive (attr := continuity)]
theorem continuous_mul : Continuous fun p : M ร M => p.1 * p.2 :=
ContinuousMul.continuous_mul
#align continuous_mul continuous_mul
#align continuous_add continuous_add
@[to_additive]
instance ContinuousMul.to_continuousSMul : ContinuousSMul M M :=
โจcontinuous_mulโฉ
#align has_continuous_mul.to_has_continuous_smul ContinuousMul.to_continuousSMul
#align has_continuous_add.to_has_continuous_vadd ContinuousAdd.to_continuousVAdd
@[to_additive]
instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mแตแตแต M :=
โจshow Continuous ((fun p : M ร M => p.1 * p.2) โ Prod.swap โ Prod.map MulOpposite.unop id) from
continuous_mul.comp <|
continuous_swap.comp <| Continuous.prod_map MulOpposite.continuous_unop continuous_idโฉ
#align has_continuous_mul.to_has_continuous_smul_op ContinuousMul.to_continuousSMul_op
#align has_continuous_add.to_has_continuous_vadd_op ContinuousAdd.to_continuousVAdd_op
@[to_additive (attr := continuity)]
theorem Continuous.mul {f g : X โ M} (hf : Continuous f) (hg : Continuous g) :
Continuous fun x => f x * g x :=
continuous_mul.comp (hf.prod_mk hg : _)
#align continuous.mul Continuous.mul
#align continuous.add Continuous.add
@[to_additive (attr := continuity)]
theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b :=
continuous_const.mul continuous_id
#align continuous_mul_left continuous_mul_left
#align continuous_add_left continuous_add_left
@[to_additive (attr := continuity)]
theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a :=
continuous_id.mul continuous_const
#align continuous_mul_right continuous_mul_right
#align continuous_add_right continuous_add_right
@[to_additive]
theorem ContinuousOn.mul {f g : X โ M} {s : Set X} (hf : ContinuousOn f s) (hg : ContinuousOn g s) :
ContinuousOn (fun x => f x * g x) s :=
(continuous_mul.comp_continuousOn (hf.prod hg) : _)
#align continuous_on.mul ContinuousOn.mul
#align continuous_on.add ContinuousOn.add
@[to_additive]
theorem tendsto_mul {a b : M} : Tendsto (fun p : M ร M => p.fst * p.snd) (๐ (a, b)) (๐ (a * b)) :=
continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b)
#align tendsto_mul tendsto_mul
#align tendsto_add tendsto_add
@[to_additive]
theorem Filter.Tendsto.mul {f g : ฮฑ โ M} {x : Filter ฮฑ} {a b : M} (hf : Tendsto f x (๐ a))
(hg : Tendsto g x (๐ b)) : Tendsto (fun x => f x * g x) x (๐ (a * b)) :=
tendsto_mul.comp (hf.prod_mk_nhds hg)
#align filter.tendsto.mul Filter.Tendsto.mul
#align filter.tendsto.add Filter.Tendsto.add
@[to_additive]
theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => b * f k) l (๐ (b * c)) :=
tendsto_const_nhds.mul h
#align filter.tendsto.const_mul Filter.Tendsto.const_mul
#align filter.tendsto.const_add Filter.Tendsto.const_add
@[to_additive]
theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : ฮฑ โ M} {l : Filter ฮฑ}
(h : Tendsto (fun k : ฮฑ => f k) l (๐ c)) : Tendsto (fun k : ฮฑ => f k * b) l (๐ (c * b)) :=
h.mul tendsto_const_nhds
#align filter.tendsto.mul_const Filter.Tendsto.mul_const
#align filter.tendsto.add_const Filter.Tendsto.add_const
@[to_additive]
theorem le_nhds_mul (a b : M) : ๐ a * ๐ b โค ๐ (a * b) := by
rw [โ mapโ_mul, โ map_uncurry_prod, โ nhds_prod_eq]
exact continuous_mul.tendsto _
#align le_nhds_mul le_nhds_mul
#align le_nhds_add le_nhds_add
@[to_additive (attr := simp)]
theorem nhds_one_mul_nhds {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
๐ (1 : M) * ๐ a = ๐ a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (one_mul a)).antisymm <|
le_mul_of_one_le_left' <| pure_le_nhds 1
#align nhds_one_mul_nhds nhds_one_mul_nhds
#align nhds_zero_add_nhds nhds_zero_add_nhds
@[to_additive (attr := simp)]
theorem nhds_mul_nhds_one {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
๐ a * ๐ 1 = ๐ a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (mul_one a)).antisymm <|
le_mul_of_one_le_right' <| pure_le_nhds 1
#align nhds_mul_nhds_one nhds_mul_nhds_one
#align nhds_add_nhds_zero nhds_add_nhds_zero
section tendsto_nhds
variable {๐ : Type*} [Preorder ๐] [Zero ๐] [Mul ๐] [TopologicalSpace ๐] [ContinuousMul ๐]
{l : Filter ฮฑ} {f : ฮฑ โ ๐} {b c : ๐} (hb : 0 < b)
theorem Filter.TendstoNhdsWithinIoi.const_mul [PosMulStrictMono ๐] [PosMulReflectLT ๐]
(h : Tendsto f l (๐[>] c)) : Tendsto (fun a => b * f a) l (๐[>] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Ioi.const_mul Filter.TendstoNhdsWithinIoi.const_mul
theorem Filter.TendstoNhdsWithinIio.const_mul [PosMulStrictMono ๐] [PosMulReflectLT ๐]
(h : Tendsto f l (๐[<] c)) : Tendsto (fun a => b * f a) l (๐[<] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
#align filter.tendsto_nhds_within_Iio.const_mul Filter.TendstoNhdsWithinIio.const_mul
theorem Filter.TendstoNhdsWithinIoi.mul_const [MulPosStrictMono ๐] [MulPosReflectLT ๐]
(h : Tendsto f l (๐[>] c)) : Tendsto (fun a => f a * b) l (๐[>] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Ioi.mul_const Filter.TendstoNhdsWithinIoi.mul_const
theorem Filter.TendstoNhdsWithinIio.mul_const [MulPosStrictMono ๐] [MulPosReflectLT ๐]
(h : Tendsto f l (๐[<] c)) : Tendsto (fun a => f a * b) l (๐[<] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
#align filter.tendsto_nhds_within_Iio.mul_const Filter.TendstoNhdsWithinIio.mul_const
end tendsto_nhds
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ฮน โ Nหฃ} {rโ rโ : N} {l : Filter ฮน} [l.NeBot] (hโ : Tendsto (fun x => โ(f x)) l (๐ rโ))
(hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)) : Nหฃ
where
val := rโ
inv := rโ
val_inv := by
symm
simpa using hโ.mul hโ
inv_val := by
|
symm
|
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ฮน โ Nหฃ} {rโ rโ : N} {l : Filter ฮน} [l.NeBot] (hโ : Tendsto (fun x => โ(f x)) l (๐ rโ))
(hโ : Tendsto (fun x => โ(f x)โปยน) l (๐ rโ)) : Nหฃ
where
val := rโ
inv := rโ
val_inv := by
symm
simpa using hโ.mul hโ
inv_val := by
|
Mathlib.Topology.Algebra.Monoid.197_0.3p9EZf9ZWFxWOAq
|
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr
|
Mathlib_Topology_Algebra_Monoid
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.