Theorem: Nat.xor_trichotomy
File: Mathlib/Data/Nat/Bitwise.lean

tactic: set v := a ^^^ (b ^^^ c) with hv
state_before: a b c : ℕ
h : a ≠ b ^^^ c
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: have hab : a ^^^ b = c ^^^ v := by
  rw [hv]
  conv_rhs =>
    rw [Nat.xor_comm]
    simp [Nat.xor_assoc]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: have hac : a ^^^ c = b ^^^ v := by
  rw [hv]
  conv_rhs =>
    right
    rw [← Nat.xor_comm]
  rw [← Nat.xor_assoc, ← Nat.xor_assoc, xor_self, zero_xor, Nat.xor_comm]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← Nat.xor_assoc]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: have : testBit a i = true ∨ testBit b i = true ∨ testBit c i = true := by
  contrapose! hi
  simp only [Bool.eq_false_eq_not_eq_true, Ne, testBit_xor, Bool.bne_eq_xor] at hi ⊢
  rw [hi.1, hi.2.1, hi.2.2, Bool.xor_false, Bool.xor_false]
state_before: case intro.intro
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
this : a.testBit i = true ∨ b.testBit i = true ∨ c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: rcases this with (h | h | h)
state_before: case intro.intro
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
this : a.testBit i = true ∨ b.testBit i = true ∨ c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

case intro.intro.inr.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

case intro.intro.inr.inr
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: on_goal 1 => left; rw [hbc]
state_before: case intro.intro.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

case intro.intro.inr.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

case intro.intro.inr.inr
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ a ^^^ v < a

case intro.intro.inr.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

case intro.intro.inr.inr
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: on_goal 2 => right; left; rw [hac]
state_before: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ a ^^^ v < a

case intro.intro.inr.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

case intro.intro.inr.inr
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ a ^^^ v < a

case intro.intro.inr.inl.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ v < b

case intro.intro.inr.inr
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

tactic: on_goal 3 => right; right; rw [hab]
state_before: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ a ^^^ v < a

case intro.intro.inr.inl.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ v < b

case intro.intro.inr.inr
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ a ^^^ v < a

case intro.intro.inr.inl.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ v < b

case intro.intro.inr.inr.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ c ^^^ v < c

tactic: all_goals
  exact lt_of_testBit i (by simp [h, hi]) h fun j hj => by simp [hi' _ hj]
state_before: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ a ^^^ v < a

case intro.intro.inr.inl.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ v < b

case intro.intro.inr.inr.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ c ^^^ v < c
state_after: no goals

tactic: rw [hv]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
⊢ a ^^^ b = c ^^^ v
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
⊢ a ^^^ b = c ^^^ (a ^^^ (b ^^^ c))

tactic: conv_rhs =>
  rw [Nat.xor_comm]
  simp [Nat.xor_assoc]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
⊢ a ^^^ b = c ^^^ (a ^^^ (b ^^^ c))
state_after: no goals

tactic: rw [hv]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
⊢ a ^^^ c = b ^^^ v
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
⊢ a ^^^ c = b ^^^ (a ^^^ (b ^^^ c))

tactic: conv_rhs =>
  right
  rw [← Nat.xor_comm]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
⊢ a ^^^ c = b ^^^ (a ^^^ (b ^^^ c))
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
⊢ a ^^^ c = b ^^^ (b ^^^ c ^^^ a)

tactic: rw [← Nat.xor_assoc, ← Nat.xor_assoc, xor_self, zero_xor, Nat.xor_comm]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
⊢ a ^^^ c = b ^^^ (b ^^^ c ^^^ a)
state_after: no goals

tactic: simp [hv, ← Nat.xor_assoc]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
⊢ b ^^^ c = a ^^^ v
state_after: no goals

tactic: contrapose! hi
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
⊢ a.testBit i = true ∨ b.testBit i = true ∨ c.testBit i = true
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
hi : a.testBit i ≠ true ∧ b.testBit i ≠ true ∧ c.testBit i ≠ true
⊢ (a ^^^ (b ^^^ c)).testBit i ≠ true

tactic: simp only [Bool.eq_false_eq_not_eq_true, Ne, testBit_xor, Bool.bne_eq_xor] at hi ⊢
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
hi : a.testBit i ≠ true ∧ b.testBit i ≠ true ∧ c.testBit i ≠ true
⊢ (a ^^^ (b ^^^ c)).testBit i ≠ true
state_after: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
hi : a.testBit i = false ∧ b.testBit i = false ∧ c.testBit i = false
⊢ _root_.xor (a.testBit i) (_root_.xor (b.testBit i) (c.testBit i)) = false

tactic: rw [hi.1, hi.2.1, hi.2.2, Bool.xor_false, Bool.xor_false]
state_before: a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
hi : a.testBit i = false ∧ b.testBit i = false ∧ c.testBit i = false
⊢ _root_.xor (a.testBit i) (_root_.xor (b.testBit i) (c.testBit i)) = false
state_after: no goals

tactic: left
state_before: case intro.intro.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ b ^^^ c < a

tactic: rw [hbc]
state_before: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ b ^^^ c < a
state_after: case intro.intro.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : a.testBit i = true
⊢ a ^^^ v < a

tactic: right
state_before: case intro.intro.inr.inl
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inr.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ a ^^^ c < b ∨ a ^^^ b < c

tactic: left
state_before: case intro.intro.inr.inl.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inr.inl.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ a ^^^ c < b

tactic: rw [hac]
state_before: case intro.intro.inr.inl.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ a ^^^ c < b
state_after: case intro.intro.inr.inl.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : b.testBit i = true
⊢ b ^^^ v < b

tactic: right
state_before: case intro.intro.inr.inr
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inr.inr.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ a ^^^ c < b ∨ a ^^^ b < c

tactic: right
state_before: case intro.intro.inr.inr.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ a ^^^ c < b ∨ a ^^^ b < c
state_after: case intro.intro.inr.inr.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ a ^^^ b < c

tactic: rw [hab]
state_before: case intro.intro.inr.inr.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ a ^^^ b < c
state_after: case intro.intro.inr.inr.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ c ^^^ v < c

tactic: exact lt_of_testBit i (by simp [h, hi]) h fun j hj => by simp [hi' _ hj]
state_before: case intro.intro.inr.inr.h.h
a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ c ^^^ v < c
state_after: no goals

tactic: simp [h, hi]
state_before: a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
⊢ (c ^^^ v).testBit i = false
state_after: no goals

tactic: simp [hi' _ hj]
state_before: a b c : ℕ
h✝ : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
hac : a ^^^ c = b ^^^ v
hbc : b ^^^ c = a ^^^ v
i : ℕ
hi : (a ^^^ (b ^^^ c)).testBit i = true
hi' : ∀ (j : ℕ), i < j → (a ^^^ (b ^^^ c)).testBit j = false
h : c.testBit i = true
j : ℕ
hj : i < j
⊢ (c ^^^ v).testBit j = c.testBit j
state_after: no goals