-- Mathlib/Dynamics/TopologicalEntropy/CoverEntropy.lean
/-- From a dynamical cover `s` with entourage `U` and time `m`, we construct covers with entourage
`U ○ U` and any multiple `m * n` of `m` with controlled cardinality. This lemma is the first step
in a submultiplicative-like property of `coverMincard`, with consequences such as explicit bounds
for the topological entropy (`coverEntropyInfEntourage_le_card_div`) and an equality between
two notions of topological entropy (`coverEntropyInf_eq_coverEntropySup_of_inv`). -/
lemma IsDynCoverOf.iterate_le_pow {T : X → X} {F : Set X} (F_inv : MapsTo T F F) {U : Set (X × X)}
    (U_symm : SymmetricRel U) {m : ℕ} (n : ℕ) {s : Finset X} (h : IsDynCoverOf T F U m s) :
    ∃ t : Finset X, IsDynCoverOf T F (U ○ U) (m * n) t ∧ t.card ≤ s.card ^ n

Proof state:
case inr.intro.inr.refine_2
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
this : Fintype ↑(range dyncover)
⊢ Fintype.card ↑sn ≤ s.card ^ n

Tactic:
apply (Fintype.card_range_le dyncover).trans

Result:
case inr.intro.inr.refine_2
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
this : Fintype ↑(range dyncover)
⊢ Fintype.card (Fin n → { x // x ∈ s }) ≤ s.card ^ n

Proof state:
case inr.intro.inr.refine_2
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
this : Fintype ↑(range dyncover)
⊢ Fintype.card (Fin n → { x // x ∈ s }) ≤ s.card ^ n

Tactic:
simp only [Fintype.card_fun, Fintype.card_coe, Fintype.card_fin, le_refl]

Result:
no goals

Proof state:
case inr
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
F_nemp : F.Nonempty
x✝ : Nonempty X
⊢ ∃ t, IsDynCoverOf T F (U ○ U) (m * n) ↑t ∧ t.card ≤ s.card ^ n

Tactic:
have s_nemp := h.nonempty F_nemp

Result:
case inr
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
F_nemp : F.Nonempty
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
⊢ ∃ t, IsDynCoverOf T F (U ○ U) (m * n) ↑t ∧ t.card ≤ s.card ^ n

Proof state:
case inr.intro.inr.refine_1
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝¹ : Nonempty X
s_nemp : s.Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
this : Fintype ↑(range dyncover)
x✝ : Nonempty { x // x ∈ s }
y : X
y_F : y ∈ F
⊢ y ∈ ⋃ x ∈ ↑sn.toFinset, ball x (dynEntourage T (U ○ U) (m * n))

Tactic:
have key : ∀ k : Fin n, ∃ z : s, y ∈ T^[m * k] ⁻¹' ball z (dynEntourage T U m) := by
  intro k
  have := h (MapsTo.iterate F_inv (m * k) y_F)
  simp only [Finset.coe_sort_coe, mem_iUnion, Subtype.exists, exists_prop] at this
  rcases this with ⟨z, z_s, hz⟩
  exact ⟨⟨z, z_s⟩, hz⟩

Result:
case inr.intro.inr.refine_1
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝¹ : Nonempty X
s_nemp : s.Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
this : Fintype ↑(range dyncover)
x✝ : Nonempty { x // x ∈ s }
y : X
y_F : y ∈ F
key : ∀ (k : Fin n), ∃ z, y ∈ T^[m * ↑k] ⁻¹' ball (↑z) (dynEntourage T U m)
⊢ y ∈ ⋃ x ∈ ↑sn.toFinset, ball x (dynEntourage T (U ○ U) (m * n))

Proof state:
case inr.intro.inr
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
⊢ ∃ t, IsDynCoverOf T F (U ○ U) (m * n) ↑t ∧ t.card ≤ s.card ^ n

Tactic:
let sn := range dyncover

Result:
case inr.intro.inr
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
⊢ ∃ t, IsDynCoverOf T F (U ○ U) (m * n) ↑t ∧ t.card ≤ s.card ^ n

Proof state:
case inr.intro.inr
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
⊢ ∃ t, IsDynCoverOf T F (U ○ U) (m * n) ↑t ∧ t.card ≤ s.card ^ n

Tactic:
have := fintypeRange dyncover

Result:
case inr.intro.inr
X : Type u_1
T : X → X
F : Set X
F_inv : MapsTo T F F
U : Set (X × X)
U_symm : SymmetricRel U
m n : ℕ
s : Finset X
h : IsDynCoverOf T F U m ↑s
x✝ : Nonempty X
s_nemp : (↑s).Nonempty
x : X
x_F : x ∈ F
m_pos : m > 0
dyncover : (Fin n → { x // x ∈ s }) → X
h_dyncover :
  ∀ (t : Fin n → { x // x ∈ s }),
    ⋂ k, T^[m * ↑k] ⁻¹' ball (↑(t k)) (dynEntourage T U m) ⊆ ball (dyncover t) (dynEntourage T (U ○ U) (m * n))
sn : Set X := range dyncover
this : Fintype ↑(range dyncover)
⊢ ∃ t, IsDynCoverOf T F (U ○ U) (m * n) ↑t ∧ t.card ≤ s.card ^ n