Lean library · module TopologyByExample.Slices.Basic

Slices of properties of topological spaces: rows, realisation and witness expressions

Source file

A slice is a finite, ordered family of properties of topological spaces P : Fin n → _. A row is a true/false assignment to the slice's properties, and a space realises a row when each property holds of it exactly when the row says so.

This file sets up the parts of the theory that do not depend on any particular set of implications between the properties:

  • TopologyByExample.Slices.SpaceProperty: a property of topological spaces in a fixed universe;
  • TopologyByExample.Slices.SpaceProperty.SumConjunctive: the property holds of a disjoint sum X ⊕ Y exactly when it holds of both X and Y;
  • TopologyByExample.Slices.SpaceProperty.ProdConjunctive: the property holds of a product X × Y of nonempty spaces exactly when it holds of both X and Y;
  • TopologyByExample.Slices.Row n: the rows Fin n → Bool, ordered and met pointwise;
  • TopologyByExample.Slices.Realises P X r: the space X realises the row r;
  • TopologyByExample.Slices.Expr ι: binary trees over base spaces (indexed by ι), their interpretation Expr.eval as a bundled topological space (TopCat) with each node read as the disjoint sum, and their combinatorial row Expr.row, the meet of the rows of the leaves;
  • TopologyByExample.Slices.Expr.realises_eval: if every base space realises its row and every property is sum-conjunctive, then an expression realises its combinatorial row;
  • TopologyByExample.Slices.Combinator: the operations that may interpret the node of an expression, the disjoint sum and the binary product, with Expr.evalBy (the space an expression denotes with its nodes read as a given combinator) and Expr.realises_evalBy (its correctness, for properties conjunctive for the combinator and admissible base spaces).

Combinators

The node of Expr (Expr.node) carries no operation: the tree, its row and everything built on them (the decision algorithm and its finite side condition in TopologyByExample.Slices.Horn) are shared by every slice whose realised rows are closed under meets. Only the evaluation of a tree depends on the operation, which is chosen when the tree is evaluated (Expr.evalBy c). A slice of sum-conjunctive properties reads the node as the disjoint sum (Expr.eval, equal to Expr.evalBy .sum); a slice of product-conjunctive properties, such as connectedness, which no disjoint sum of two nonempty spaces has, reads it as the binary product of nonempty spaces. A further operation is a further Combinator, with its admissible arguments and its notion of conjunctive property.

The Horn theory of a slice and the decision algorithm are in TopologyByExample.Slices.Horn.

Universes

A SpaceProperty.{u} speaks about spaces in Type u. A concrete slice is defined universe polymorphically, so its refutations hold for spaces in every universe; its witnesses are built in whichever universe the base spaces live in (usually Type).

This file was written by Claude (Anthropic's AI model) working under the direction of David R. MacIver, who reviews it and is responsible for it.

Imports

structure SpaceProperty

TopologyByExample.Slices.SpaceProperty

A property of topological spaces whose carrier lives in Type u.

structure SpaceProperty : Type (u + 1) where
  /-- The property holds of the space `X`. -/
  Holds : (X : Type u) → [TopologicalSpace X] → Prop

definition SumConjunctive

TopologyByExample.Slices.SpaceProperty.SumConjunctive

A property is sum-conjunctive if it holds of a binary disjoint sum exactly when it holds of both summands.

def SumConjunctive (P : SpaceProperty.{u}) : Prop
:=
  ∀ (X Y : Type u) [TopologicalSpace X] [TopologicalSpace Y],
    P.Holds (X ⊕ Y) ↔ P.Holds X ∧ P.Holds Y

definition ProdConjunctive

TopologyByExample.Slices.SpaceProperty.ProdConjunctive

A property is product-conjunctive if it holds of a product of two nonempty spaces exactly when it holds of both factors.

def ProdConjunctive (P : SpaceProperty.{u}) : Prop
:=
  ∀ (X Y : Type u) [TopologicalSpace X] [TopologicalSpace Y] [Nonempty X] [Nonempty Y],
    P.Holds (X × Y) ↔ P.Holds X ∧ P.Holds Y

definition Row

TopologyByExample.Slices.Row

A row over n properties: a true/false value for each. Rows are ordered and met pointwise (Bool is ordered by false < true, and ⊓ is &&).

abbrev Row (n : ℕ) : Type
:= Fin n → Bool
variable {n : ℕ}

definition toList

TopologyByExample.Slices.Row.toList

The values of a row, as a list in property order.

def toList (r : Row n) : List Bool
:= List.ofFn r

theorem toList_injective

TopologyByExample.Slices.Row.toList_injective

theorem toList_injective : Function.Injective (toList (n := n))
Proof
:= List.ofFn_injective

theorem toList_inj

TopologyByExample.Slices.Row.toList_inj

@[simp]
theorem toList_inj {r s : Row n} : r.toList = s.toList ↔ r = s
Proof
:= toList_injective.eq_iff

theorem inf_apply_eq_true

TopologyByExample.Slices.Row.inf_apply_eq_true

theorem inf_apply_eq_true {r s : Row n} {i : Fin n} :
    (r ⊓ s) i = true ↔ r i = true ∧ s i = true
Proof
:= by
  rw [Pi.inf_apply]
  cases r i <;> cases s i <;> decide

definition leB

TopologyByExample.Slices.Row.leB

r ≤ s as a boolean, by checking every property; used by the decision algorithm.

def leB (r s : Row n) : Bool
:= (List.finRange n).all fun i ↦ !r i || s i

theorem leB_eq_true

TopologyByExample.Slices.Row.leB_eq_true

@[simp]
theorem leB_eq_true {r s : Row n} : r.leB s = true ↔ ∀ i, r i = true → s i = true
Proof
:= by
  simp only [leB, List.all_eq_true, List.mem_finRange, Bool.or_eq_true, Bool.not_eq_eq_eq_not,
    Bool.not_true, true_imp_iff]
  exact forall_congr' fun i ↦ by cases r i <;> simp

definition all

TopologyByExample.Slices.Row.all

Every row over n properties, as an explicit list (of length 2 ^ n). Used to decide statements about all rows by kernel evaluation.

def all : (n : ℕ) → List (Row n)
  | 0 => [Fin.elim0]
  | n + 1 => (all n).flatMap fun r ↦ [Fin.cons false r, Fin.cons true r]

theorem mem_all

TopologyByExample.Slices.Row.mem_all

theorem mem_all : ∀ {n : ℕ} (r : Row n), r ∈ all n
Proof
  | 0, r => by simp only [all, List.mem_singleton]; exact funext fun i ↦ i.elim0
  | n + 1, r => by
    simp only [all, List.mem_flatMap, List.mem_cons, List.not_mem_nil, or_false]
    refine ⟨Fin.tail r, mem_all _, ?_⟩
    rcases h : r 0 with _ | _
    · exact .inl (by rw [← h, Fin.cons_self_tail])
    · exact .inr (by rw [← h, Fin.cons_self_tail])
variable {n : ℕ}

definition Realises

TopologyByExample.Slices.Realises

The space X realises the row r for the properties P: each property holds of X exactly when r says it does.

def Realises (P : Fin n → SpaceProperty.{u}) (X : Type u) [TopologicalSpace X] (r : Row n) :
    Prop
:=
  ∀ i, (P i).Holds X ↔ r i = true

theorem unique

TopologyByExample.Slices.Realises.unique

A space realises at most one row.

theorem Realises.unique {P : Fin n → SpaceProperty.{u}} {X : Type u} [TopologicalSpace X]
    {r s : Row n} (hr : Realises P X r) (hs : Realises P X s) : r = s
Proof
:=
  funext fun i ↦ Bool.eq_iff_iff.2 ((hr i).symm.trans (hs i))

theorem realises_rowOf

TopologyByExample.Slices.realises_rowOf

Every space realises the row of the properties it has.

theorem realises_rowOf (P : Fin n → SpaceProperty.{u}) (X : Type u) [TopologicalSpace X] :
    Realises P X (fun i ↦ open Classical in decide ((P i).Holds X))
Proof
:= fun i ↦ by simp

theorem sum

TopologyByExample.Slices.Realises.sum

If every property is sum-conjunctive, a disjoint sum realises the meet of the rows of the summands.

theorem Realises.sum {P : Fin n → SpaceProperty.{u}} (hP : ∀ i, (P i).SumConjunctive)
    {X Y : Type u} [TopologicalSpace X] [TopologicalSpace Y] {r s : Row n}
    (hX : Realises P X r) (hY : Realises P Y s) : Realises P (X ⊕ Y) (r ⊓ s)
Proof
:= fun i ↦ by
  rw [hP i, hX i, hY i, Row.inf_apply_eq_true]

theorem prod

TopologyByExample.Slices.Realises.prod

If every property is product-conjunctive, a product of two nonempty spaces realises the meet of the rows of its factors.

theorem Realises.prod {P : Fin n → SpaceProperty.{u}} (hP : ∀ i, (P i).ProdConjunctive)
    {X Y : Type u} [TopologicalSpace X] [TopologicalSpace Y] [Nonempty X] [Nonempty Y]
    {r s : Row n} (hX : Realises P X r) (hY : Realises P Y s) : Realises P (X × Y) (r ⊓ s)
Proof
:=
  fun i ↦ by rw [hP i, hX i, hY i, Row.inf_apply_eq_true]

inductive type Expr

TopologyByExample.Slices.Expr

Expressions for spaces built from a library of base spaces, indexed by ι: binary trees whose leaves are base spaces. A node combines two spaces by an operation chosen when the tree is evaluated: the disjoint sum for Expr.eval, any Combinator for Expr.evalBy.

inductive Expr (ι : Type) : Type where
  /-- The base space with index `i`. -/
  | base (i : ι) : Expr ι
  /-- The combination of two spaces (their disjoint sum, or their product, according to the
  evaluation). -/
  | node (e f : Expr ι) : Expr ι
  deriving DecidableEq, Repr
variable {ι : Type}

definition eval

TopologyByExample.Slices.Expr.eval

The space an expression denotes, given the base spaces.

def eval (B : ι → TopCat.{u}) : Expr ι → TopCat.{u}
  | base i => B i
  | node e f => TopCat.of (eval B e ⊕ eval B f)

definition row

TopologyByExample.Slices.Expr.row

The row an expression has according to the transfer theorems, given the base rows: a base space has its base row and a node (a disjoint sum, or a product of nonempty spaces) has the meet of the rows of its two arguments.

def row (R : ι → Row n) : Expr ι → Row n
  | base i => R i
  | node e f => row R e ⊓ row R f

definition nodeList

TopologyByExample.Slices.Expr.nodeList

The left-nested tree ((i₀ ∗ i₁) ∗ i₂) ∗ ⋯ of a non-empty list of base spaces i₀ :: is (a disjoint sum, or a product, according to the evaluation).

def nodeList (i₀ : ι) (is : List ι) : Expr ι
:=
  is.foldl (fun e i ↦ node e (base i)) (base i₀)

theorem realises_eval

TopologyByExample.Slices.Expr.realises_eval

Correctness of evaluation. If every property is sum-conjunctive and every base space realises its base row, then the space an expression denotes realises the row the transfer theorems give it.

theorem realises_eval {P : Fin n → SpaceProperty.{u}} (hP : ∀ i, (P i).SumConjunctive)
    {B : ι → TopCat.{u}} {R : ι → Row n} (hB : ∀ i, Realises P (B i) (R i)) :
    ∀ e : Expr ι, Realises P (e.eval B) (e.row R)
Proof
  | base i => hB i
  | node e f => (realises_eval hP hB e).sum hP (realises_eval hP hB f)

Combinators

inductive type Combinator

TopologyByExample.Slices.Combinator

The binary operations by which a slice's witness expressions combine base spaces.

inductive Combinator : Type where
  /-- The disjoint sum `X ⊕ Y`. -/
  | sum : Combinator
  /-- The binary product `X × Y`. -/
  | prod : Combinator
  deriving DecidableEq, Repr

definition apply

TopologyByExample.Slices.Combinator.apply

The space obtained by combining two spaces.

def apply : Combinator → TopCat.{u} → TopCat.{u} → TopCat.{u}
  | sum, X, Y => TopCat.of (X ⊕ Y)
  | prod, X, Y => TopCat.of (X × Y)

definition Admissible

TopologyByExample.Slices.Combinator.Admissible

The spaces a combinator may take as arguments: every space for the disjoint sum, nonempty spaces for the product.

def Admissible : Combinator → Type u → Prop
  | sum, _ => True
  | prod, X => Nonempty X

theorem admissible_apply

TopologyByExample.Slices.Combinator.admissible_apply

Combining admissible spaces gives an admissible space.

theorem admissible_apply (c : Combinator) {X Y : TopCat.{u}} (hX : c.Admissible X)
    (hY : c.Admissible Y) : c.Admissible (c.apply X Y)
Proof
:= by
  cases c
  · trivial
  · exact ⟨(hX.some, hY.some)⟩

definition Conjunctive

TopologyByExample.Slices.SpaceProperty.Conjunctive

A property is conjunctive for a combinator if it holds of the combination of two admissible spaces exactly when it holds of both: sum-conjunctive for the disjoint sum, product-conjunctive for the product.

def SpaceProperty.Conjunctive (P : SpaceProperty.{u}) : Combinator → Prop
  | .sum => P.SumConjunctive
  | .prod => P.ProdConjunctive

theorem apply

TopologyByExample.Slices.Realises.apply

If every property is conjunctive for a combinator, combining two admissible spaces realises the meet of their rows.

theorem Realises.apply {P : Fin n → SpaceProperty.{u}} {c : Combinator}
    (hP : ∀ i, (P i).Conjunctive c) {X Y : TopCat.{u}} (hXa : c.Admissible X)
    (hYa : c.Admissible Y) {r s : Row n} (hX : Realises P X r) (hY : Realises P Y s) :
    Realises P (c.apply X Y) (r ⊓ s)
Proof
:= by
  cases c
  · exact hX.sum hP hY
  · have : Nonempty X := hXa
    have : Nonempty Y := hYa
    exact hX.prod hP hY

Evaluating expressions through a combinator

variable {ι : Type}

definition evalBy

TopologyByExample.Slices.Expr.evalBy

The space an expression denotes, given the base spaces, when its binary node is read as the combinator c.

def evalBy (c : Combinator) (B : ι → TopCat.{u}) : Expr ι → TopCat.{u}
  | base i => B i
  | node e f => c.apply (evalBy c B e) (evalBy c B f)

theorem evalBy_sum

TopologyByExample.Slices.Expr.evalBy_sum

Read as the disjoint sum, an expression denotes the space Expr.eval gives.

@[simp]
theorem evalBy_sum (B : ι → TopCat.{u}) : ∀ e : Expr ι, e.evalBy .sum B = e.eval B
Proof
  | base _ => rfl
  | node e f => by rw [evalBy, evalBy_sum B e, evalBy_sum B f]; rfl

theorem admissible_evalBy

TopologyByExample.Slices.Expr.admissible_evalBy

An expression over admissible base spaces denotes an admissible space.

theorem admissible_evalBy {c : Combinator} {B : ι → TopCat.{u}} (hB : ∀ i, c.Admissible (B i)) :
    ∀ e : Expr ι, c.Admissible (e.evalBy c B)
Proof
  | base i => hB i
  | node e f => c.admissible_apply (admissible_evalBy hB e) (admissible_evalBy hB f)

theorem nonempty_evalBy_prod

TopologyByExample.Slices.Expr.nonempty_evalBy_prod

A product of nonempty base spaces is nonempty.

theorem nonempty_evalBy_prod {B : ι → TopCat.{u}} (hB : ∀ i, Nonempty (B i)) (e : Expr ι) :
    Nonempty (e.evalBy .prod B)
Proof
:=
  admissible_evalBy (c := .prod) hB e

theorem realises_evalBy

TopologyByExample.Slices.Expr.realises_evalBy

Correctness of evaluation through a combinator. If every property is conjunctive for the combinator and every base space is admissible and realises its base row, then the space an expression denotes realises the row the transfer theorems give it.

theorem realises_evalBy {P : Fin n → SpaceProperty.{u}} {c : Combinator}
    (hP : ∀ i, (P i).Conjunctive c) {B : ι → TopCat.{u}} {R : ι → Row n}
    (hA : ∀ i, c.Admissible (B i)) (hB : ∀ i, Realises P (B i) (R i)) :
    ∀ e : Expr ι, Realises P (e.evalBy c B) (e.row R)
Proof
  | base i => hB i
  | node e f => (realises_evalBy hP hA hB e).apply hP (admissible_evalBy hA e)
      (admissible_evalBy hA f) (realises_evalBy hP hA hB f)

theorem realises_evalBy_prod

TopologyByExample.Slices.Expr.realises_evalBy_prod

Correctness of evaluation as a product. If every property is product-conjunctive and every base space is nonempty and realises its base row, then the product an expression denotes realises the row the transfer theorems give it.

theorem realises_evalBy_prod {P : Fin n → SpaceProperty.{u}} (hP : ∀ i, (P i).ProdConjunctive)
    {B : ι → TopCat.{u}} {R : ι → Row n} (hne : ∀ i, Nonempty (B i))
    (hB : ∀ i, Realises P (B i) (R i)) (e : Expr ι) : Realises P (e.evalBy .prod B) (e.row R)
Proof
:=
  realises_evalBy (c := .prod) hP hne hB e