l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem zero_xor (n : ℕ) : 0 ^^^ n = n := by 

Proof state:
n : ℕ
⊢ 0 ^^^ n = n

Next tactic:
simp [HXor.hXor, Xor.xor, xor]
@[simp]
theorem xor_zero (n : ℕ) : n ^^^ 0 = n := by 

Proof state:
n : ℕ
⊢ n ^^^ 0 = n

Next tactic:
simp [HXor.hXor, Xor.xor, xor]
theorem xor_assoc (n m k : ℕ) : (n ^^^ m) ^^^ k = n ^^^ (m ^^^ k) := by 

Proof state:
n m k : ℕ
⊢ n ^^^ m ^^^ k = n ^^^ (m ^^^ k)

Next tactic:
bitwise_assoc_tac
theorem land_assoc (n m k : ℕ) : (n &&& m) &&& k = n &&& (m &&& k) := by 

Proof state:
n m k : ℕ
⊢ n &&& m &&& k = n &&& (m &&& k)

Next tactic:
bitwise_assoc_tac
theorem lor_assoc (n m k : ℕ) : (n ||| m) ||| k = n ||| (m ||| k) := by 

Proof state:
n m k : ℕ
⊢ n ||| m ||| k = n ||| (m ||| k)

Next tactic:
bitwise_assoc_tac
@[simp]
theorem xor_self (n : ℕ) : n ^^^ n = 0 :=
  zero_of_testBit_eq_false fun i => by 

Proof state:
n i : ℕ
⊢ testBit (n ^^^ n) i = false

Next tactic:
simp
theorem lxor_cancel_right (n m : ℕ) : (m ^^^ n) ^^^ n = m := by
  

Proof state:
n m : ℕ
⊢ m ^^^ n ^^^ n = m

Next tactic:
rw [xor_assoc, xor_self, xor_zero]
theorem xor_cancel_left (n m : ℕ) : n ^^^ (n ^^^ m) = m := by
  

Proof state:
n m : ℕ
⊢ n ^^^ (n ^^^ m) = m

Next tactic:
rw [← xor_assoc, xor_self, zero_xor]
theorem xor_right_injective {n : ℕ} : Function.Injective (HXor.hXor n : ℕ → ℕ) := fun m m' h => by
  

Proof state:
n m m' : ℕ
h : n ^^^ m = n ^^^ m'
⊢ m = m'

Next tactic:
rw [← xor_cancel_left n m, ← xor_cancel_left n m', h]
theorem xor_left_injective {n : ℕ} : Function.Injective fun m => m ^^^ n :=
  fun m m' (h : m ^^^ n = m' ^^^ n) => by
  

Proof state:
n m m' : ℕ
h : m ^^^ n = m' ^^^ n
⊢ m = m'

Next tactic:
rw [← lxor_cancel_right n m, ← lxor_cancel_right n m', h]
@[simp]
theorem xor_eq_zero {n m : ℕ} : n ^^^ m = 0 ↔ n = m := by
  

Proof state:
n m : ℕ
⊢ n ^^^ m = 0 ↔ n = m

Next tactic:
rw [← xor_self n, xor_right_inj, eq_comm]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

Next tactic:
set v := a ^^^ (b ^^^ c) with hv
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  

Proof state:
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

Next tactic:
have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
⊢ a ^^^ b = c ^^^ v

Next tactic:
rw [hv]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
⊢ a ^^^ b = c ^^^ (a ^^^ (b ^^^ c))

Next tactic:
conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
| c ^^^ (a ^^^ (b ^^^ c))

Next tactic:
rw [xor_comm]
      simp [xor_assoc]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
| c ^^^ (a ^^^ (b ^^^ c))

Next tactic:
rw [xor_comm]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
| a ^^^ (b ^^^ c) ^^^ c

Next tactic:
simp [xor_assoc]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  

Proof state:
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

Next tactic:
have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    

Proof state:
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

Next tactic:
rw [hv]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    

Proof state:
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))

Next tactic:
conv_rhs =>
      right
      rw [← xor_comm]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
| b ^^^ (a ^^^ (b ^^^ c))

Next tactic:
right
      rw [← xor_comm]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
| b ^^^ (a ^^^ (b ^^^ c))

Next tactic:
right
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      

Proof state:
a b c : ℕ
h : a ≠ b ^^^ c
v : ℕ := a ^^^ (b ^^^ c)
hv : v = a ^^^ (b ^^^ c)
hab : a ^^^ b = c ^^^ v
| a ^^^ (b ^^^ c)

Next tactic:
rw [← xor_comm]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    

Proof state:
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)

Next tactic:
rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  

Proof state:
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

Next tactic:
have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by 

Proof state:
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

Next tactic:
simp [hv, ← xor_assoc]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  

Proof state:
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

Next tactic:
obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

Next 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]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  have : testBit a i = true ∨ testBit b i = true ∨ testBit c i = true := by
    

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
⊢ testBit a i = true ∨ testBit b i = true ∨ testBit c i = true

Next tactic:
contrapose! hi
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  have : testBit a i = true ∨ testBit b i = true ∨ testBit c i = true := by
    contrapose! hi
    

Proof state:
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 → testBit (a ^^^ (b ^^^ c)) j = false
hi : testBit a i ≠ true ∧ testBit b i ≠ true ∧ testBit c i ≠ true
⊢ testBit (a ^^^ (b ^^^ c)) i ≠ true

Next tactic:
simp only [Bool.eq_false_eq_not_eq_true, Ne, testBit_xor, Bool.bne_eq_xor] at hi ⊢
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  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 ⊢
    

Proof state:
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 → testBit (a ^^^ (b ^^^ c)) j = false
hi : testBit a i = false ∧ testBit b i = false ∧ testBit c i = false
⊢ _root_.xor (testBit a i) (_root_.xor (testBit b i) (testBit c i)) = false

Next tactic:
rw [hi.1, hi.2.1, hi.2.2, Bool.xor_false, Bool.xor_false]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  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]
  -- If, say, `a` has a one bit at position `i`, then `a xor v` has a zero bit at position `i`, but
  -- the same bits as `a` in positions greater than `j`, so `a xor v < a`.
  

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
this : testBit a i = true ∨ testBit b i = true ∨ testBit c i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

Next tactic:
rcases this with (h | h | h)
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  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]
  -- If, say, `a` has a one bit at position `i`, then `a xor v` has a zero bit at position `i`, but
  -- the same bits as `a` in positions greater than `j`, so `a xor v < a`.
  rcases this with (h | h | h)
  

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit a 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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit b 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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit c i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

Next tactic:
on_goal 1 => left; rw [hbc]
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  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]
  -- If, say, `a` has a one bit at position `i`, then `a xor v` has a zero bit at position `i`, but
  -- the same bits as `a` in positions greater than `j`, so `a xor v < a`.
  rcases this with (h | h | h)
  on_goal 1 => 

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit a i = true
⊢ b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c

Next tactic:
left
theorem xor_trichotomy {a b c : ℕ} (h : a ≠ b ^^^ c) :
    b ^^^ c < a ∨ a ^^^ c < b ∨ a ^^^ b < c := by
  set v := a ^^^ (b ^^^ c) with hv
  -- The xor of any two of `a`, `b`, `c` is the xor of `v` and the third.
  have hab : a ^^^ b = c ^^^ v := by
    rw [hv]
    conv_rhs =>
      rw [xor_comm]
      simp [xor_assoc]
  have hac : a ^^^ c = b ^^^ v := by
    rw [hv]
    conv_rhs =>
      right
      rw [← xor_comm]
    rw [← xor_assoc, ← xor_assoc, xor_self, zero_xor, xor_comm]
  have hbc : b ^^^ c = a ^^^ v := by simp [hv, ← xor_assoc]
  -- If `i` is the position of the most significant bit of `v`, then at least one of `a`, `b`, `c`
  -- has a one bit at position `i`.
  obtain ⟨i, ⟨hi, hi'⟩⟩ := exists_most_significant_bit (xor_ne_zero.2 h)
  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]
  -- If, say, `a` has a one bit at position `i`, then `a xor v` has a zero bit at position `i`, but
  -- the same bits as `a` in positions greater than `j`, so `a xor v < a`.
  rcases this with (h | h | h)
  on_goal 1 => left; 

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit a i = true
⊢ b ^^^ c < a

Next tactic:
rw [hbc]