l3lab/ntp-mathlib huggingface dataset:
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case pos
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : p1
h✝¹ : p2
h✝ : p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case neg
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : p1
h✝¹ : p2
h✝ : ¬p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case pos
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : p1
h✝¹ : ¬p2
h✝ : p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case neg
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : p1
h✝¹ : ¬p2
h✝ : ¬p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case pos
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : ¬p1
h✝¹ : p2
h✝ : p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case neg
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : ¬p1
h✝¹ : p2
h✝ : ¬p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case pos
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : ¬p1
h✝¹ : ¬p2
h✝ : p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> 

Proof state:
case neg
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝² : ¬p1
h✝¹ : ¬p2
h✝ : ¬p3
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p4
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> by_cases p4 <;> 

Proof state:
case pos
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝³ : p1
h✝² : p2
h✝¹ : p3
h✝ : p4
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p5
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> by_cases p4 <;> 

Proof state:
case neg
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝³ : p1
h✝² : p2
h✝¹ : p3
h✝ : ¬p4
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p5
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> by_cases p4 <;> 

Proof state:
case pos
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝³ : p1
h✝² : p2
h✝¹ : ¬p3
h✝ : p4
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p5
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> by_cases p4 <;> 

Proof state:
case neg
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝³ : p1
h✝² : p2
h✝¹ : ¬p3
h✝ : ¬p4
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p5
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> by_cases p4 <;> 

Proof state:
case pos
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝³ : p1
h✝² : ¬p2
h✝¹ : p3
h✝ : p4
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p5
/-- The circular preorder obtained from "looping around" a preorder.
See note [reducible non-instances]. -/
@[reducible]
def Preorder.toCircularPreorder (α : Type*) [Preorder α] : CircularPreorder α where
  btw a b c := a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b
  sbtw a b c := a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b
  btw_refl a := Or.inl ⟨le_rfl, le_rfl⟩
  btw_cyclic_left {a b c} h := by
    dsimp
    rwa [← or_assoc, or_comm]
  sbtw_trans_left {a b c d} := by
    rintro (⟨hab, hbc⟩ | ⟨hbc, hca⟩ | ⟨hca, hab⟩) (⟨hbd, hdc⟩ | ⟨hdc, hcb⟩ | ⟨hcb, hbd⟩)
    · exact Or.inl ⟨hab.trans hbd, hdc⟩
    · exact (hbc.not_lt hcb).elim
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact (hbc.not_lt hcb).elim
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inl ⟨hdc, hca⟩)
    · exact Or.inr (Or.inr ⟨hca, hab.trans hbd⟩)
  sbtw_iff_btw_not_btw {a b c} := by
    simp_rw [lt_iff_le_not_le]
    have h1 := le_trans a b c
    have h2 := le_trans b c a
    have h3 := le_trans c a b
    -- Porting note: was `tauto`, but this is a much faster tactic proof
    revert h1 h2 h3
    generalize (a ≤ b) = p1
    generalize (b ≤ a) = p2
    generalize (a ≤ c) = p3
    generalize (c ≤ a) = p4
    generalize (b ≤ c) = p5
    by_cases p1 <;> by_cases p2 <;> by_cases p3 <;> by_cases p4 <;> 

Proof state:
case neg
α : Type u_1
inst✝ : Preorder α
a b c : α
p1 p2 p3 p4 p5 : Prop
h✝³ : p1
h✝² : ¬p2
h✝¹ : p3
h✝ : ¬p4
⊢ (p1 → p5 → p3) →
    (p5 → p4 → p2) →
      (p4 → p1 → c ≤ b) →
        ((p1 ∧ ¬p2) ∧ p5 ∧ ¬c ≤ b ∨ (p5 ∧ ¬c ≤ b) ∧ p4 ∧ ¬p3 ∨ (p4 ∧ ¬p3) ∧ p1 ∧ ¬p2 ↔
          (p1 ∧ p5 ∨ p5 ∧ p4 ∨ p4 ∧ p1) ∧ ¬(c ≤ b ∧ p2 ∨ p2 ∧ p3 ∨ p3 ∧ c ≤ b))

Next tactic:
by_cases p5