Theorem: Nat.isPowerOfTwo_nextPowerOfTwo
File: src/lean/Init/Data/Nat/Power2.lean

tactic: apply isPowerOfTwo_go
state_before: n : Nat
⊢ isPowerOfTwo (nextPowerOfTwo n)

tactic: apply one_isPowerOfTwo
state_before: case h₂
n : Nat
⊢ isPowerOfTwo 1

tactic: unfold nextPowerOfTwo.go
state_before: n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
⊢ isPowerOfTwo (nextPowerOfTwo.go n power h₁)

tactic: split
state_before: n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
⊢ isPowerOfTwo (if power < n then nextPowerOfTwo.go n (power * 2) (_ : power * 2 > 0) else power)

tactic: . exact isPowerOfTwo_go (power*2) (Nat.mul_pos h₁ (by decide)) (Nat.mul2_isPowerOfTwo_of_isPowerOfTwo h₂)
state_before: case inl
n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
h✝ : power < n
⊢ isPowerOfTwo (nextPowerOfTwo.go n (power * 2) (_ : power * 2 > 0))

case inr
n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
h✝ : ¬power < n
⊢ isPowerOfTwo power

tactic: . assumption
state_before: case inr
n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
h✝ : ¬power < n
⊢ isPowerOfTwo power

tactic: exact isPowerOfTwo_go (power*2) (Nat.mul_pos h₁ (by decide)) (Nat.mul2_isPowerOfTwo_of_isPowerOfTwo h₂)
state_before: case inl
n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
h✝ : power < n
⊢ isPowerOfTwo (nextPowerOfTwo.go n (power * 2) (_ : power * 2 > 0))

tactic: decide
state_before: n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
h✝ : power < n
⊢ 2 > 0

tactic: assumption
state_before: case inr
n power : Nat
h₁ : power > 0
h₂ : isPowerOfTwo power
h✝ : ¬power < n
⊢ isPowerOfTwo power

tactic: simp_wf
state_before: n : Nat
_x✝ : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power
a✝² :
  ∀ (y : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power),
    (invImage (fun a => PSigma.casesOn a fun p snd => PSigma.casesOn snd fun h₁ snd => n - p) instWellFoundedRelation).1
        y _x✝ →
      isPowerOfTwo (nextPowerOfTwo.go n y.1 (_ : y.1 > 0))
power : Nat
h₁✝ : (_ : power > 0) ×' isPowerOfTwo power
a✝¹ :
  ∀ (y : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power),
    (invImage (fun a => PSigma.casesOn a fun p snd => PSigma.casesOn snd fun h₁ snd => n - p) instWellFoundedRelation).1
        y { fst := power, snd := h₁✝ } →
      isPowerOfTwo (nextPowerOfTwo.go n y.1 (_ : y.1 > 0))
h₁ : power > 0
h₂ : isPowerOfTwo power
a✝ :
  ∀ (y : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power),
    (invImage (fun a => PSigma.casesOn a fun p snd => PSigma.casesOn snd fun h₁ snd => n - p) instWellFoundedRelation).1
        y { fst := power, snd := { fst := h₁, snd := h₂ } } →
      isPowerOfTwo (nextPowerOfTwo.go n y.1 (_ : y.1 > 0))
h✝ : power < n
⊢ (invImage (fun a => PSigma.casesOn a fun p snd => PSigma.casesOn snd fun h₁ snd => n - p) instWellFoundedRelation).1
    { fst := power * 2, snd := { fst := (_ : power * 2 > 0), snd := (_ : isPowerOfTwo (power * 2)) } }
    { fst := power, snd := { fst := h₁, snd := h₂ } }

tactic: apply nextPowerOfTwo_dec <;> assumption
state_before: n : Nat
_x✝ : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power
a✝² :
  ∀ (y : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power),
    (invImage (fun a => PSigma.casesOn a fun p snd => PSigma.casesOn snd fun h₁ snd => n - p) instWellFoundedRelation).1
        y _x✝ →
      isPowerOfTwo (nextPowerOfTwo.go n y.1 (_ : y.1 > 0))
power : Nat
h₁✝ : (_ : power > 0) ×' isPowerOfTwo power
a✝¹ :
  ∀ (y : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power),
    (invImage (fun a => PSigma.casesOn a fun p snd => PSigma.casesOn snd fun h₁ snd => n - p) instWellFoundedRelation).1
        y { fst := power, snd := h₁✝ } →
      isPowerOfTwo (nextPowerOfTwo.go n y.1 (_ : y.1 > 0))
h₁ : power > 0
h₂ : isPowerOfTwo power
a✝ :
  ∀ (y : (power : Nat) ×' (_ : power > 0) ×' isPowerOfTwo power),
    (invImage (fun a => PSigma.casesOn a fun p snd => PSigma.casesOn snd fun h₁ snd => n - p) instWellFoundedRelation).1
        y { fst := power, snd := { fst := h₁, snd := h₂ } } →
      isPowerOfTwo (nextPowerOfTwo.go n y.1 (_ : y.1 > 0))
h✝ : power < n
⊢ n - power * 2 < n - power