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]
  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]
      rfl
    ) h fun j hj => by
      -- Porting note: this was originally `simp [hi' _ hj]`
      

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
j : ℕ
hj : i < j
⊢ testBit (a ^^^ v) j = testBit a j

Next tactic:
rw [Nat.testBit_xor, hi' _ hj, Bool.xor, Bool.xor_false, eq_self_iff_true]
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]
      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]
      

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
j : ℕ
hj : i < j
⊢ True

Next tactic:
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.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

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 b i = true
⊢ testBit (b ^^^ 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 b i = true
⊢ (!true) = false

Next tactic:
rfl
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]
      rfl
    ) h fun j hj => by
      -- Porting note: this was originally `simp [hi' _ hj]`
      

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 b i = true
j : ℕ
hj : i < j
⊢ testBit (b ^^^ v) j = testBit b j

Next tactic:
rw [Nat.testBit_xor, hi' _ hj, Bool.xor, Bool.xor_false, eq_self_iff_true]
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]
      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]
      

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 b i = true
j : ℕ
hj : i < j
⊢ True

Next tactic:
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.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:
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 c i = true
⊢ testBit (c ^^^ 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 c i = true
⊢ (!true) = false

Next tactic:
rfl
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]
      rfl
    ) h fun j hj => by
      -- Porting note: this was originally `simp [hi' _ hj]`
      

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 c i = true
j : ℕ
hj : i < j
⊢ testBit (c ^^^ v) j = testBit c j

Next tactic:
rw [Nat.testBit_xor, hi' _ hj, Bool.xor, Bool.xor_false, eq_self_iff_true]
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]
      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]
      

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 c i = true
j : ℕ
hj : i < j
⊢ True

Next tactic:
trivial
@[simp] theorem bit_lt_two_pow_succ_iff {b x n} : bit b x < 2 ^ (n + 1) ↔ x < 2 ^ n := by
  

Proof state:
b : Bool
x n : ℕ
⊢ bit b x < 2 ^ (n + 1) ↔ x < 2 ^ n

Next tactic:
rw [pow_succ', ← bit0_eq_two_mul]
@[simp] theorem bit_lt_two_pow_succ_iff {b x n} : bit b x < 2 ^ (n + 1) ↔ x < 2 ^ n := by
  rw [pow_succ', ← bit0_eq_two_mul]
  

Proof state:
b : Bool
x n : ℕ
⊢ bit b x < bit0 (2 ^ n) ↔ x < 2 ^ n

Next tactic:
cases b
@[simp] theorem bit_lt_two_pow_succ_iff {b x n} : bit b x < 2 ^ (n + 1) ↔ x < 2 ^ n := by
  rw [pow_succ', ← bit0_eq_two_mul]
  cases b <;> 

Proof state:
case false
x n : ℕ
⊢ bit false x < bit0 (2 ^ n) ↔ x < 2 ^ n

Next tactic:
simp
@[simp] theorem bit_lt_two_pow_succ_iff {b x n} : bit b x < 2 ^ (n + 1) ↔ x < 2 ^ n := by
  rw [pow_succ', ← bit0_eq_two_mul]
  cases b <;> 

Proof state:
case true
x n : ℕ
⊢ bit true x < bit0 (2 ^ n) ↔ x < 2 ^ n

Next tactic:
simp