/-- Equivalence between `∀ i : Fin m, Fin (n i)` and `Fin (∏ i : Fin m, n i)`. -/
def finPiFinEquiv {m : ℕ} {n : Fin m → ℕ} : (∀ i : Fin m, Fin (n i)) ≃ Fin (∏ i : Fin m, n i) :=
  Equiv.ofRightInverseOfCardLE (le_of_eq <| by simp_rw [Fintype.card_pi, Fintype.card_fin])
    (fun f => ⟨∑ i, f i * ∏ j, n (Fin.castLE i.is_lt.le j), by
      induction' m with m ih
      · simp
      rw [Fin.prod_univ_castSucc, Fin.sum_univ_castSucc]
      suffices
        ∀ (n : Fin m → ℕ) (nn : ℕ) (f : ∀ i : Fin m, Fin (n i)) (fn : Fin nn),
          ((∑ i : Fin m, ↑(f i) * ∏ j : Fin i, n (Fin.castLE i.prop.le j)) + ↑fn * ∏ j, n j) <
            (∏ i : Fin m, n i) * nn by
        replace := this (Fin.init n) (n (Fin.last _)) (Fin.init f) (f (Fin.last _))
        rw [← Fin.snoc_init_self f]
        simp (config := { singlePass := true }) only [← Fin.snoc_init_self n]
        simp_rw [Fin.snoc_castSucc, Fin.snoc_last, Fin.snoc_init_self n]
        exact this
      intro n nn f fn
      cases nn
      · dsimp only [Nat.zero_eq] at fn -- porting note: added, wrong zero
        exact isEmptyElim fn
      refine' (add_lt_add_of_lt_of_le (ih _) <| mul_le_mul_right' (Fin.is_le _) _).trans_eq _
      rw [← one_add_mul (_ : ℕ), mul_comm, add_comm]
      -- porting note: added, wrong `succ`
      rfl⟩)
    (fun a b => ⟨(a / ∏ j : Fin b, n (Fin.castLE b.is_lt.le j)) % n b, by
      cases m
      · exact b.elim0
      cases' h : n b with nb
      · rw [prod_eq_zero (Finset.mem_univ _) h] at a
        exact isEmptyElim a
      exact Nat.mod_lt _ nb.succ_pos⟩)
    (by
      intro a; revert a; dsimp only [Fin.val_mk]
      refine' Fin.consInduction _ _ n
      · intro a
        haveI : Subsingleton (Fin (∏ i : Fin 0, i.elim0)) :=
          (Fin.castIso <| prod_empty).toEquiv.subsingleton
        exact Subsingleton.elim _ _
      · intro n x xs ih a
        simp_rw [Fin.forall_iff, Fin.ext_iff] at ih
        ext
        simp_rw [Fin.sum_univ_succ, Fin.cons_succ]
        have := fun i : Fin n =>
          Fintype.prod_equiv (Fin.castIso <| Fin.val_succ i).toEquiv
            (fun j => (Fin.cons x xs : _ → ℕ) (Fin.castLE (Fin.is_lt _).le j))
            (fun j => (Fin.cons x xs : _ → ℕ) (Fin.castLE (Nat.succ_le_succ (Fin.is_lt _).le) j))
            fun j => rfl
        

Proof state:
case refine'_2.h
α : Type u_1
β : Type u_2
m : ℕ
n✝ : Fin m → ℕ
n x : ℕ
xs : Fin n → ℕ
a : Fin (∏ i : Fin (n + 1), Fin.cons x xs i)
ih :
  ∀ i < ∏ i : Fin n, xs i,
    ∑ x : Fin n,
        (i / ∏ j : Fin ↑x, xs (Fin.castLE (_ : ↑x ≤ n) j)) % xs x * ∏ j : Fin ↑x, xs (Fin.castLE (_ : ↑x ≤ n) j) =
      i
this :
  ∀ (i : Fin n),
    ∏ x_1 : Fin ↑(Fin.succ i), Fin.cons x xs (Fin.castLE (_ : ↑(Fin.succ i) ≤ n + 1) x_1) =
      ∏ x_1 : Fin (↑i + 1), Fin.cons x xs (Fin.castLE (_ : Nat.succ ↑i ≤ Nat.succ n) x_1)
⊢ (↑a / ∏ j : Fin ↑0, Fin.cons x xs (Fin.castLE (_ : ↑0 ≤ n + 1) j)) % Fin.cons x xs 0 *
        ∏ j : Fin ↑0, Fin.cons x xs (Fin.castLE (_ : ↑0 ≤ n + 1) j) +
      ∑ x_1 : Fin n,
        (↑a / ∏ j : Fin ↑(Fin.succ x_1), Fin.cons x xs (Fin.castLE (_ : ↑(Fin.succ x_1) ≤ n + 1) j)) % xs x_1 *
          ∏ j : Fin ↑(Fin.succ x_1), Fin.cons x xs (Fin.castLE (_ : ↑(Fin.succ x_1) ≤ n + 1) j) =
    ↑a

Next tactic:
simp_rw [this]