The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V04. Order and lattices

Mathlib.Order.Circular

84 declarations. Mathlib docs · Source

Circular order hierarchy

This file defines circular preorders, circular partial orders and circular orders.

Hierarchy

  • A ternary "betweenness" relation btw : α → α → α → Prop forms a CircularOrder if it is

    • reflexive: btw a a a
    • cyclic: btw a b c → btw b c a
    • antisymmetric: btw a b c → btw c b a → a = b ∨ b = c ∨ c = a
    • total: btw a b c ∨ btw c b a

    along with a strict betweenness relation sbtw : α → α → α → Prop which respects sbtw a b c ↔ btw a b c ∧ ¬ btw c b a, analogously to how < and ≤ are related, and is

    • transitive: sbtw a b c → sbtw b d c → sbtw a d c.
  • A CircularPartialOrder drops totality.

  • A CircularPreorder further drops antisymmetry.

The intuition is that a circular order is a circle and btw a b c means that going around clockwise from a you reach b before c (b is between a and c is meaningless on an unoriented circle). A circular partial order is several, potentially intersecting, circles. A circular preorder is like a circular partial order, but several points can coexist.

Note that the relations between CircularPreorder, CircularPartialOrder and CircularOrder are subtler than between Preorder, PartialOrder, LinearOrder. In particular, one cannot simply extend the Btw of a CircularPartialOrder to make it a CircularOrder.

One can translate from usual orders to circular ones by "closing the necklace at infinity". See LE.toBtw and LT.toSBtw. Going the other way involves "cutting the necklace" or "rolling the necklace open".

Examples

Some concrete circular orders one encounters in the wild are ZMod n for 0 < n, Circle, Real.Angle...

Main definitions

  • Set.cIcc: Closed-closed circular interval.
  • Set.cIoo: Open-open circular interval.

Implementation notes

There's an unsolved diamond on OrderDual α here. The instances LE α → Btw αᵒᵈ and LT α → SBtw αᵒᵈ can each be inferred in two ways:

  • LE α → Btw α → Btw αᵒᵈ vs LE α → LE αᵒᵈ → Btw αᵒᵈ
  • LT α → SBtw α → SBtw αᵒᵈ vs LT α → LT αᵒᵈ → SBtw αᵒᵈ

The fields are propeq, but not defeq. It is temporarily fixed by turning the circularizing instances into definitions.

TODO

Antisymmetry is quite weak in the sense that there's no way to discriminate which two points are equal. This prevents defining closed-open intervals cIco and cIoc in the neat =-less way. We currently haven't defined them at all.

What is the correct generality of "rolling the necklace" open? At least, this works for α × β and β × α where α is a circular order and β is a linear order.

What's next is to define circular groups and provide instances for ZMod n, the usual circle group Circle, and RootsOfUnity M. What conditions do we need on M for this last one to work?

We should have circular order homomorphisms. The typical example is daysToMonth : DaysOfTheYear →c MonthsOfTheYear which relates the circular order of days and the circular order of months. Is α →c β a good notation?

References

  • https://en.wikipedia.org/wiki/Cyclic_order
  • https://en.wikipedia.org/wiki/Partial_cyclic_order

Tags

circular order, cyclic order, circularly ordered set, cyclically ordered set

Circular preorders

Circular partial orders

Circular orders

Circular intervals

Circularizing instances

Dual constructions

def Btw.ctorIdx E1 #

{α : Type u_1} → Btw α → ℕ

def CircularOrder.ctorIdx E1 #

{α : Type u_1} → CircularOrder α → ℕ

def CircularPartialOrder.ctorIdx E1 #

{α : Type u_1} → CircularPartialOrder α → ℕ

def CircularPreorder.ctorIdx E1 #

{α : Type u_1} → CircularPreorder α → ℕ

def SBtw.ctorIdx E1 #

{α : Type u_1} → SBtw α → ℕ

class Btw E1 #

Type u_1 → Type u_1

Syntax typeclass for a betweenness relation.

ctor Btw.mk E0 #

{α : Type u_1} → (α → α → α → Prop) → Btw α

abbrev Btw.btw E1 #

{α : Type u_1} → [self : Btw α] → α → α → α → Prop

Betweenness for circular orders. btw a b c states that b is between a and c (in that order).

class SBtw E1 #

Type u_1 → Type u_1

Syntax typeclass for a strict betweenness relation.

ctor SBtw.mk E0 #

{α : Type u_1} → (α → α → α → Prop) → SBtw α

abbrev SBtw.sbtw E1 #

{α : Type u_1} → [self : SBtw α] → α → α → α → Prop

Strict betweenness for circular orders. sbtw a b c states that b is strictly between a and c (in that order).

class CircularPreorder E1 #

Type u_1 → Type u_1

A circular preorder is the analogue of a preorder where you can loop around. ≤ and < are replaced by ternary relations btw and sbtw. btw is reflexive and cyclic. sbtw is transitive.

instance CircularPreorder.toBtw E0 #

{α : Type u_1} → [self : CircularPreorder α] → Btw α

instance CircularPreorder.toSBtw E0 #

{α : Type u_1} → [self : CircularPreorder α] → SBtw α

ctor CircularPreorder.mk E0 #

{α : Type u_1} →
  [toBtw : Btw α] →
    [toSBtw : SBtw α] →
      (∀ (a : α), btw a a a) →
        (∀ {a b c : α}, btw a b c → btw b c a) →
          autoParam (∀ {a b c : α}, sbtw a b c ↔ btw a b c ∧ ¬btw c b a)
              CircularPreorder.sbtw_iff_btw_not_btw._autoParam →
            (∀ {a b c d : α}, sbtw a b c → sbtw b d c → sbtw a d c) → CircularPreorder α

theorem CircularPreorder.btw_refl E1 #

∀ {α : Type u_1} [self : CircularPreorder α] (a : α), btw a a a

a is between a and a.

theorem CircularPreorder.btw_cyclic_left E1 #

∀ {α : Type u_1} [self : CircularPreorder α] {a b c : α}, btw a b c → btw b c a

If b is between a and c, then c is between b and a. This is motivated by imagining three points on a circle.

theorem CircularPreorder.sbtw_iff_btw_not_btw E1 #

∀ {α : Type u_1} [self : CircularPreorder α] {a b c : α}, sbtw a b c ↔ btw a b c ∧ ¬btw c b a

Strict betweenness is given by betweenness in one direction and non-betweenness in the other.

I.e., if b is between a and c but not between c and a, then we say b is strictly between a and c.

theorem CircularPreorder.sbtw_trans_left E1 #

∀ {α : Type u_1} [self : CircularPreorder α] {a b c d : α}, sbtw a b c → sbtw b d c → sbtw a d c

For any fixed c, fun a b ↦ sbtw a b c is a transitive relation.

I.e., given a b d c in that "order", if we have b strictly between a and c, and d strictly between b and c, then d is strictly between a and c.

class CircularPartialOrder E1 #

Type u_1 → Type u_1

A circular partial order is the analogue of a partial order where you can loop around. ≤ and < are replaced by ternary relations btw and sbtw. btw is reflexive, cyclic and antisymmetric. sbtw is transitive.

instance CircularPartialOrder.toCircularPreorder E0 #

{α : Type u_1} → [self : CircularPartialOrder α] → CircularPreorder α

ctor CircularPartialOrder.mk E0 #

{α : Type u_1} →
  [toCircularPreorder : CircularPreorder α] →
    (∀ {a b c : α}, btw a b c → btw c b a → a = b ∨ b = c ∨ c = a) → CircularPartialOrder α

theorem CircularPartialOrder.btw_antisymm E1 #

∀ {α : Type u_1} [self : CircularPartialOrder α] {a b c : α}, btw a b c → btw c b a → a = b ∨ b = c ∨ c = a

If b is between a and c and also between c and a, then at least one pair of points among a, b, c are identical.

class CircularOrder E1 #

Type u_1 → Type u_1

A circular order is the analogue of a linear order where you can loop around. ≤ and < are replaced by ternary relations btw and sbtw. btw is reflexive, cyclic, antisymmetric and total. sbtw is transitive.

ctor CircularOrder.mk E0 #

{α : Type u_1} →
  [toCircularPartialOrder : CircularPartialOrder α] → (∀ (a b c : α), btw a b c ∨ btw c b a) → CircularOrder α

instance CircularOrder.toCircularPartialOrder E0 #

{α : Type u_1} → [self : CircularOrder α] → CircularPartialOrder α

theorem CircularOrder.btw_total E1 #

∀ {α : Type u_1} [self : CircularOrder α] (a b c : α), btw a b c ∨ btw c b a

For any triple of points, the second is between the other two one way or another.

theorem btw_rfl E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a : α}, btw a a a

theorem Btw.btw.cyclic_left E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c → btw b c a

theorem btw_cyclic_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c → btw c a b

theorem Btw.btw.cyclic_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c → btw c a b

Alias of btw_cyclic_right.

theorem btw_cyclic E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c ↔ btw c a b

The order of the ↔ has been chosen so that rw [btw_cyclic] cycles to the right while rw [← btw_cyclic] cycles to the left (thus following the prepended arrow).

theorem sbtw_iff_btw_not_btw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c ↔ btw a b c ∧ ¬btw c b a

theorem btw_of_sbtw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → btw a b c

theorem SBtw.sbtw.btw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → btw a b c

Alias of btw_of_sbtw.

theorem not_btw_of_sbtw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → ¬btw c b a

theorem SBtw.sbtw.not_btw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → ¬btw c b a

Alias of not_btw_of_sbtw.

theorem not_sbtw_of_btw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c → ¬sbtw c b a

theorem Btw.btw.not_sbtw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c → ¬sbtw c b a

Alias of not_sbtw_of_btw.

theorem sbtw_of_btw_not_btw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c → ¬btw c b a → sbtw a b c

theorem Btw.btw.sbtw_of_not_btw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, btw a b c → ¬btw c b a → sbtw a b c

Alias of sbtw_of_btw_not_btw.

theorem sbtw_cyclic_left E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → sbtw b c a

theorem SBtw.sbtw.cyclic_left E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → sbtw b c a

Alias of sbtw_cyclic_left.

theorem sbtw_cyclic_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → sbtw c a b

theorem SBtw.sbtw.cyclic_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → sbtw c a b

Alias of sbtw_cyclic_right.

theorem sbtw_cyclic E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c ↔ sbtw c a b

The order of the ↔ has been chosen so that rw [sbtw_cyclic] cycles to the right while rw [← sbtw_cyclic] cycles to the left (thus following the prepended arrow).

theorem SBtw.sbtw.trans_left E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c d : α}, sbtw a b c → sbtw b d c → sbtw a d c

theorem sbtw_trans_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c d : α}, sbtw a b c → sbtw a c d → sbtw a b d

theorem SBtw.sbtw.trans_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c d : α}, sbtw a b c → sbtw a c d → sbtw a b d

Alias of sbtw_trans_right.

theorem sbtw_asymm E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → ¬sbtw c b a

theorem SBtw.sbtw.not_sbtw E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b c : α}, sbtw a b c → ¬sbtw c b a

Alias of sbtw_asymm.

theorem sbtw_irrefl_left_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b : α}, ¬sbtw a b a

theorem sbtw_irrefl_left E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b : α}, ¬sbtw a a b

theorem sbtw_irrefl_right E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b : α}, ¬sbtw a b b

theorem sbtw_irrefl E1 #

∀ {α : Type u_1} [inst : CircularPreorder α] (a : α), ¬sbtw a a a

theorem Btw.btw.antisymm E1 #

∀ {α : Type u_1} [inst : CircularPartialOrder α] {a b c : α}, btw a b c → btw c b a → a = b ∨ b = c ∨ c = a

theorem btw_refl_left_right E1 #

∀ {α : Type u_1} [inst : CircularOrder α] (a b : α), btw a b a

theorem btw_rfl_left_right E1 #

∀ {α : Type u_1} [inst : CircularOrder α] {a b : α}, btw a b a

theorem btw_refl_left E1 #

∀ {α : Type u_1} [inst : CircularOrder α] (a b : α), btw a a b

theorem btw_rfl_left E1 #

∀ {α : Type u_1} [inst : CircularOrder α] {a b : α}, btw a a b

theorem btw_refl_right E1 #

∀ {α : Type u_1} [inst : CircularOrder α] (a b : α), btw a b b

theorem btw_rfl_right E1 #

∀ {α : Type u_1} [inst : CircularOrder α] {a b : α}, btw a b b

theorem sbtw_iff_not_btw E1 #

∀ {α : Type u_1} [inst : CircularOrder α] {a b c : α}, sbtw a b c ↔ ¬btw c b a

theorem btw_iff_not_sbtw E1 #

∀ {α : Type u_1} [inst : CircularOrder α] {a b c : α}, btw a b c ↔ ¬sbtw c b a

def Set.cIcc E3 #

{α : Type u_1} → [CircularPreorder α] → α → α → Set α

Closed-closed circular interval

def Set.cIoo E3 #

{α : Type u_1} → [CircularPreorder α] → α → α → Set α

Open-open circular interval

theorem Set.mem_cIcc E0 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b x : α}, x ∈ Set.cIcc a b ↔ btw a x b

theorem Set.mem_cIoo E0 #

∀ {α : Type u_1} [inst : CircularPreorder α] {a b x : α}, x ∈ Set.cIoo a b ↔ sbtw a x b

theorem Set.left_mem_cIcc E1 #

∀ {α : Type u_1} [inst : CircularOrder α] (a b : α), a ∈ Set.cIcc a b

theorem Set.right_mem_cIcc E1 #

∀ {α : Type u_1} [inst : CircularOrder α] (a b : α), b ∈ Set.cIcc a b

theorem Set.compl_cIcc E1 #

∀ {α : Type u_1} [inst : CircularOrder α] {a b : α}, (Set.cIcc a b)ᶜ = Set.cIoo b a

theorem Set.compl_cIoo E1 #

∀ {α : Type u_1} [inst : CircularOrder α] {a b : α}, (Set.cIoo a b)ᶜ = Set.cIcc b a

abbrev LE.toBtw E1 #

(α : Type u_1) → [LE α] → Btw α

The betweenness relation obtained from "looping around" ≤. See note [reducible non-instances].

abbrev LT.toSBtw E1 #

(α : Type u_1) → [LT α] → SBtw α

The strict betweenness relation obtained from "looping around" <. See note [reducible non-instances].

theorem btw_iff E0 #

∀ {α : Type u_1} {a b c : α} [inst : LE α], btw a b c ↔ a ≤ b ∧ b ≤ c ∨ b ≤ c ∧ c ≤ a ∨ c ≤ a ∧ a ≤ b

The following lemmas are about the non-instances LE.toBtw, LT.toSBtw and LinearOrder.toCircularOrder.

theorem sbtw_iff E0 #

∀ {α : Type u_1} {a b c : α} [inst : LT α], sbtw a b c ↔ a < b ∧ b < c ∨ b < c ∧ c < a ∨ c < a ∧ a < b

The following lemmas are about the non-instances LE.toBtw, LT.toSBtw and LinearOrder.toCircularOrder.

abbrev Preorder.toCircularPreorder E1 #

(α : Type u_1) → [Preorder α] → CircularPreorder α

The circular preorder obtained from "looping around" a preorder. See note [reducible non-instances].

abbrev PartialOrder.toCircularPartialOrder E1 #

(α : Type u_1) → [PartialOrder α] → CircularPartialOrder α

The circular partial order obtained from "looping around" a partial order. See note [reducible non-instances].

abbrev LinearOrder.toCircularOrder E1 #

(α : Type u_1) → [LinearOrder α] → CircularOrder α

The circular order obtained from "looping around" a linear order. See note [reducible non-instances].

instance OrderDual.btw E0 #

(α : Type u_1) → [h : Btw α] → Btw αᵒᵈ

instance OrderDual.sbtw E0 #

(α : Type u_1) → [h : SBtw α] → SBtw αᵒᵈ

instance OrderDual.circularPreorder E0 #

(α : Type u_1) → [CircularPreorder α] → CircularPreorder αᵒᵈ

instance OrderDual.circularPartialOrder E0 #

(α : Type u_1) → [CircularPartialOrder α] → CircularPartialOrder αᵒᵈ

instance OrderDual.instCircularOrder E0 #

(α : Type u_1) → [CircularOrder α] → CircularOrder αᵒᵈ