case refl =>
  rw [foldf_high n n .refl, Bool.or_false]
  have : ∀ b, UInt.getBit (UInt.when b ((1 : α) <<< OfNat.ofNat n)) n = b := by
    intro b; cases b
    case true =>
      simp only [
        UInt.when_true_eq, UInt.getBit_shiftLeft,
        UInt.toNat_ofNat,
        Nat.mod_eq_of_lt ‹n < 2^length α›,
        Nat.mod_eq_of_lt ‹n < length α›
      ]
      rw [decide_eq_true ‹n < length α›, decide_eq_true (p:=n≥n) .refl]
      rw [Nat.sub_self, UInt.getBit_one, decide_eq_true ‹0 < length α›, decide_eq_true rfl]
      simp only [Bool.true_and]
    case false => rw [UInt.when_false_eq, UInt.getBit_zero]
  rw [this]; clear this
  suffices ∀ y, decide ((x &&& y) ≠ 0) = UInt.getBit y i by
    rw [this]
    have hgetbit := UInt.getBit_bitmask (OfNat.ofNat (α:=α) n) i
    simp only [UInt.toNat_ofNat, Nat.mod_eq_of_lt ‹n < 2^length α›] at hgetbit
    rw [decide_eq_true ‹i < length α›, Bool.true_and] at hgetbit
    exact hgetbit ‹n < length α›
  intro y
  cases hyi : UInt.getBit y i
  case true =>
    apply decide_eq_true; intro hcontra
    have := calc
      true = (true && true) := rfl
      _    = (UInt.getBit x i && UInt.getBit y i) := by rw [hi i, decide_eq_true rfl, hyi]
      _    = UInt.getBit (x &&& y) i := by rw [UInt.getBit_land]
      _    = UInt.getBit (α:=α) 0 i := by rw [hcontra]
      _    = false := UInt.getBit_zero i
    cases this
  case false =>
    apply decide_eq_false; apply not_not_intro
    apply UInt.bitext; intro j hj
    rw [UInt.getBit_zero, UInt.getBit_land, hi j]
    if hij : i = j
    then cases hij; rw [hyi, Bool.and_false]
    else rw [decide_eq_false hij, Bool.false_and]
α : Type
inst✝² : (n : Nat) → OfNat α n
inst✝¹ : UInt α
inst✝ : DecidableEq α
i : Nat
x : α
hi : ∀ (j : Nat), UInt.getBit x j = decide (i = j)
f : Nat → α → α := fun i y => UInt.when (decide (x &&& bitmask (OfNat.ofNat i) ≠ 0)) (1 <<< OfNat.ofNat i) ||| y
this✝³ : UInt.getBit x i = true
this✝² : i < length α
this✝¹ : 0 < length α
foldf_high : ∀ (n k : Nat), k ≥ n → UInt.getBit (Nat.fold f n 0) k = false
n : Nat
h_ind : n < length α → ∀ (k : Nat), k < n → UInt.getBit (Nat.fold f n 0) k = Nat.getBit i k
hn : Nat.succ n < length α
this✝ : n < length α
this : n < 2 ^ length α
⊢ (UInt.getBit (UInt.when (decide (x &&& bitmask (OfNat.ofNat n) ≠ 0)) (1 <<< OfNat.ofNat n)) n ||
      UInt.getBit (Nat.fold f n 0) n) =
    Nat.getBit i n
no goals