# mathlibdocumentation

combinatorics.colex

# Colex

We define the colex ordering for finite sets, and give a couple of important lemmas and properties relating to it.

The colex ordering likes to avoid large values - it can be thought of on finset ℕ as the "binary" ordering. That is, order A based on ∑_{i ∈ A} 2^i. It's defined here in a slightly more general way, requiring only has_lt α in the definition of colex on finset α. In the context of the Kruskal-Katona theorem, we are interested in particular on how colex behaves for sets of a fixed size. If the size is 3, colex on ℕ starts 123, 124, 134, 234, 125, 135, 235, 145, 245, 345, ...

## Main statements

• colex_hom: strictly monotone functions preserve colex
• Colex order properties - linearity, decidability and so on.
• forall_lt_of_colex_lt_of_forall_lt: if A < B in colex, and everything in B is < t, then everything in A is < t. This confirms the idea that an enumeration under colex will exhaust all sets using elements < t before allowing t to be included.
• binary_iff: colex for α = ℕ is the same as binary (this also proves binary expansions are unique)

## Notation

We define < and ≤ to denote colex ordering, useful in particular when multiple orderings are available in context.

## Tags

colex, colexicographic, binary

## References

• https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf

## Todo

Show the subset ordering is a sub-relation of the colex ordering.

@[instance]
def finset.colex.inhabited (α : Type u_1) :

def finset.colex (α : Type u_1) :
Type u_1

We define this type synonym to refer to the colexicographic ordering on finsets rather than the natural subset ordering.

Equations
def finset.to_colex {α : Type u_1} (s : finset α) :

A convenience constructor to turn a finset α into a finset.colex α, useful in order to use the colex ordering rather than the subset ordering.

Equations
@[simp]
theorem colex.eq_iff {α : Type u_1} (A B : finset α) :
A = B

@[instance]
def finset.colex.has_lt {α : Type u_1} [has_lt α] :

A is less than B in the colex ordering if the largest thing that's not in both sets is in B. In other words, max (A ▵ B) ∈ B (if the maximum exists).

Equations
@[instance]
def finset.colex.has_le {α : Type u_1} [has_lt α] :

We can define (≤) in the obvious way.

Equations
theorem colex.lt_def {α : Type u_1} [has_lt α] (A B : finset α) :
∃ (k : α), (∀ {x : α}, k < x(x A x B)) k A k B

theorem colex.le_def {α : Type u_1} [has_lt α] (A B : finset α) :
A = B

theorem nat.sum_pow_two_lt {k : } {A : finset } (h₁ : ∀ {x : }, x Ax < k) :
A.sum (pow 2) < 2 ^ k

If everything in A is less than k, we can bound the sum of powers.

theorem colex.hom {α : Type u_1} {β : Type u_2} [linear_order α] [decidable_eq β] [preorder β] {f : α → β} (h₁ : strict_mono f) (A B : finset α) :

Strictly monotone functions preserve the colex ordering.

@[simp]
theorem colex.hom_fin {n : } (A B : finset (fin n)) :
(finset.image (λ (n_1 : fin n), n_1) A).to_colex < (finset.image (λ (n_1 : fin n), n_1) B).to_colex

A special case of colex_hom which is sometimes useful.

@[instance]
def colex.has_lt.lt.is_irrefl {α : Type u_1} [has_lt α] :

theorem colex.lt_trans {α : Type u_1} [linear_order α] {a b c : finset.colex α} :
a < bb < ca < c

theorem colex.le_trans {α : Type u_1} [linear_order α] (a b c : finset.colex α) :
a bb ca c

@[instance]
def colex.has_lt.lt.is_trans {α : Type u_1} [linear_order α] :

@[instance]
def colex.has_lt.lt.is_asymm {α : Type u_1} [linear_order α] :

@[instance]
def colex.has_lt.lt.is_strict_order {α : Type u_1} [linear_order α] :

theorem colex.lt_trichotomy {α : Type u_1} [linear_order α] (A B : finset.colex α) :
A < B A = B B < A

@[instance]
def colex.has_lt.lt.is_trichotomous {α : Type u_1} [linear_order α] :

@[instance]
def colex.finset.colex.linear_order {α : Type u_1} [linear_order α] :

Equations
@[instance]
def colex.has_lt.lt.is_incomp_trans {α : Type u_1} [linear_order α] :

@[instance]

@[instance]

theorem colex.mem_le_of_singleton_le {α : Type u_1} [linear_order α] {r : α} {s : finset α} :
{r}.to_colex s.to_colex(∃ (x : α) (H : x s), r x)

If {r} is less than or equal to s in the colexicographical sense, then s contains an element greater than or equal to r.

theorem colex.lt_singleton_iff_mem_lt {α : Type u_1} [linear_order α] {r : α} {s : finset α} :
s.to_colex < {r}.to_colex ∀ (x : α), x sx < r

s.to_colex < finset.to_colex {r} iff all elements of s are less than r.

theorem colex.singleton_lt_iff_lt {α : Type u_1} [linear_order α] {r s : α} :
{r}.to_colex < {s}.to_colex r < s

Colex is an extension of the base ordering on α.

theorem colex.forall_lt_of_colex_lt_of_forall_lt {α : Type u_1} [linear_order α] {A B : finset α} (t : α) (h₁ : A.to_colex < B.to_colex) (h₂ : ∀ (x : α), x Bx < t) (x : α) (H : x A) :
x < t

If A is before B in colex, and everything in B is small, then everything in A is small.

@[simp]
theorem colex.sdiff_lt_sdiff_iff_lt {α : Type u_1} [has_lt α] [decidable_eq α] (A B : finset α) :
(A \ B).to_colex < (B \ A).to_colex

Colex doesn't care if you remove the other set

theorem colex.sum_pow_two_lt_iff_lt (A B : finset ) :
A.sum (pow 2) < B.sum (pow 2)

For subsets of ℕ, we can show that colex is equivalent to binary.