l3lab/ntp-mathlib huggingface dataset:
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; rw [hbc]
  

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
⊢ 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 : 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 2 => right; left; rw [hac]
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; rw [hbc]
  on_goal 2 => 

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

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
      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; rw [hbc]
  on_goal 2 => right; 

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit b i = true
⊢ 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; rw [hbc]
  on_goal 2 => right; left; 

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

Next tactic:
rw [hac]
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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  

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
⊢ 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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit b 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 : 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 3 => right; right; rw [hab]
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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  on_goal 3 => 

Proof state:
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:
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
      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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  on_goal 3 => right; 

Proof state:
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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit c i = true
⊢ a ^^^ c < 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
      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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  on_goal 3 => right; right; 

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

Next tactic:
rw [hab]
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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  on_goal 3 => right; right; rw [hab]
  

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

Next tactic:
all_goals
    exact lt_of_testBit i (by
      -- Porting note: this was originally `simp [h, hi]`
      rw [Nat.testBit_xor, h, Bool.xor, Bool.true_xor, hi]
      rfl
    ) h fun j hj => by
      -- Porting note: this was originally `simp [hi' _ hj]`
      rw [Nat.testBit_xor, hi' _ hj, Bool.xor, Bool.xor_false, eq_self_iff_true]
      trivial
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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  on_goal 3 => right; right; rw [hab]
  all_goals
    

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
⊢ a ^^^ v < a

Next tactic:
exact lt_of_testBit i (by
      -- Porting note: this was originally `simp [h, hi]`
      rw [Nat.testBit_xor, h, Bool.xor, Bool.true_xor, hi]
      rfl
    ) h fun j hj => by
      -- Porting note: this was originally `simp [hi' _ hj]`
      rw [Nat.testBit_xor, hi' _ hj, Bool.xor, Bool.xor_false, eq_self_iff_true]
      trivial
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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  on_goal 3 => right; right; rw [hab]
  all_goals
    exact lt_of_testBit i (by
      -- Porting note: this was originally `simp [h, 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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit a i = true
⊢ testBit (a ^^^ v) i = false

Next tactic:
rw [Nat.testBit_xor, h, Bool.xor, Bool.true_xor, 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 ⊢
    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; rw [hbc]
  on_goal 2 => right; left; rw [hac]
  on_goal 3 => right; right; rw [hab]
  all_goals
    exact lt_of_testBit i (by
      -- Porting note: this was originally `simp [h, hi]`
      rw [Nat.testBit_xor, h, Bool.xor, Bool.true_xor, 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 : testBit (a ^^^ (b ^^^ c)) i = true
hi' : ∀ (j : ℕ), i < j → testBit (a ^^^ (b ^^^ c)) j = false
h : testBit a i = true
⊢ (!true) = false

Next tactic:
rfl