Theorem: Affine.Simplex.centroid_eq_iff
File: Mathlib/LinearAlgebra/AffineSpace/Independent.lean

tactic: refine' ⟨fun h => _, @congrArg _ _ fs₁ fs₂ (fun z => Finset.centroid k z s.points)⟩
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
⊢ Finset.centroid k fs₁ s.points = Finset.centroid k fs₂ s.points ↔ fs₁ = fs₂

tactic: rw [Finset.centroid_eq_affineCombination_fintype,
  Finset.centroid_eq_affineCombination_fintype] at h
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h : Finset.centroid k fs₁ s.points = Finset.centroid k fs₂ s.points
⊢ fs₁ = fs₂

tactic: have ha :=
  (affineIndependent_iff_indicator_eq_of_affineCombination_eq k s.points).1 s.Independent _ _ _ _
    (fs₁.sum_centroidWeightsIndicator_eq_one_of_card_eq_add_one k h₁)
    (fs₂.sum_centroidWeightsIndicator_eq_one_of_card_eq_add_one k h₂) h
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
⊢ fs₁ = fs₂

tactic: simp_rw [Finset.coe_univ, Set.indicator_univ, Function.funext_iff,
  Finset.centroidWeightsIndicator_def, Finset.centroidWeights, h₁, h₂] at ha
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
ha :
  (Set.indicator ↑Finset.univ fun i => Finset.centroidWeightsIndicator k fs₁ i) =
    Set.indicator ↑Finset.univ fun i => Finset.centroidWeightsIndicator k fs₂ i
⊢ fs₁ = fs₂

tactic: ext i
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
ha :
  ∀ (a : Fin (n + 1)),
    Set.indicator (↑fs₁) (const (Fin (n + 1)) (↑(m₁ + 1))⁻¹) a =
      Set.indicator (↑fs₂) (const (Fin (n + 1)) (↑(m₂ + 1))⁻¹) a
⊢ fs₁ = fs₂

tactic: specialize ha i
state_before: case a
k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
ha :
  ∀ (a : Fin (n + 1)),
    Set.indicator (↑fs₁) (const (Fin (n + 1)) (↑(m₁ + 1))⁻¹) a =
      Set.indicator (↑fs₂) (const (Fin (n + 1)) (↑(m₂ + 1))⁻¹) a
i : Fin (n + 1)
⊢ i ∈ fs₁ ↔ i ∈ fs₂

tactic: have key : ∀ n : ℕ, (n : k) + 1 ≠ 0 := fun n h => by norm_cast at h
state_before: case a
k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
i : Fin (n + 1)
ha :
  Set.indicator (↑fs₁) (const (Fin (n + 1)) (↑(m₁ + 1))⁻¹) i =
    Set.indicator (↑fs₂) (const (Fin (n + 1)) (↑(m₂ + 1))⁻¹) i
⊢ i ∈ fs₁ ↔ i ∈ fs₂

tactic: constructor <;> intro hi <;> by_contra hni
state_before: case a
k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
i : Fin (n + 1)
ha :
  Set.indicator (↑fs₁) (const (Fin (n + 1)) (↑(m₁ + 1))⁻¹) i =
    Set.indicator (↑fs₂) (const (Fin (n + 1)) (↑(m₂ + 1))⁻¹) i
key : ∀ (n : ℕ), ↑n + 1 ≠ 0
⊢ i ∈ fs₁ ↔ i ∈ fs₂

tactic: norm_cast at h
state_before: k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n✝ : ℕ
s : Simplex k P n✝
fs₁ fs₂ : Finset (Fin (n✝ + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h✝ :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
i : Fin (n✝ + 1)
ha :
  Set.indicator (↑fs₁) (const (Fin (n✝ + 1)) (↑(m₁ + 1))⁻¹) i =
    Set.indicator (↑fs₂) (const (Fin (n✝ + 1)) (↑(m₂ + 1))⁻¹) i
n : ℕ
h : ↑n + 1 = 0
⊢ False

tactic: simp [hni, hi, key] at ha
state_before: case a.mp
k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
i : Fin (n + 1)
ha :
  Set.indicator (↑fs₁) (const (Fin (n + 1)) (↑(m₁ + 1))⁻¹) i =
    Set.indicator (↑fs₂) (const (Fin (n + 1)) (↑(m₂ + 1))⁻¹) i
key : ∀ (n : ℕ), ↑n + 1 ≠ 0
hi : i ∈ fs₁
hni : ¬i ∈ fs₂
⊢ False

tactic: simpa [hni, hi, key] using ha.symm
state_before: case a.mpr
k : Type u_1
V : Type u_2
P : Type u_3
inst✝⁴ : DivisionRing k
inst✝³ : AddCommGroup V
inst✝² : Module k V
inst✝¹ : AffineSpace V P
inst✝ : CharZero k
n : ℕ
s : Simplex k P n
fs₁ fs₂ : Finset (Fin (n + 1))
m₁ m₂ : ℕ
h₁ : Finset.card fs₁ = m₁ + 1
h₂ : Finset.card fs₂ = m₂ + 1
h :
  ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₁) =
    ↑(Finset.affineCombination k Finset.univ s.points) (Finset.centroidWeightsIndicator k fs₂)
i : Fin (n + 1)
ha :
  Set.indicator (↑fs₁) (const (Fin (n + 1)) (↑(m₁ + 1))⁻¹) i =
    Set.indicator (↑fs₂) (const (Fin (n + 1)) (↑(m₂ + 1))⁻¹) i
key : ∀ (n : ℕ), ↑n + 1 ≠ 0
hi : i ∈ fs₂
hni : ¬i ∈ fs₁
⊢ False