topos.core.category

Category Module

Defines the categorical universe E = Set^(C × H^op) of the program topos. The base index category C lives in topos.graphs.base (the directed-graph index category); the value Heyting algebra H = Ω lives in topos.core.omega; this module ties them together.

ProgramCategory enforces composition axioms, maintains identity mappings, and provides convenience access to:

  • the subobject classifier Ω (Omega)

  • the characteristic morphism χ_S (CharacteristicMorphism)

so callers never need to reach into the logic subpackage just to classify or compose programs.

exception topos.core.category.CategoryError[source]

Bases: Exception

Raised when category axioms (like composition domain mismatches) are broken.

class topos.core.category.ProgramCategory(name='ToposOfPrograms')[source]

Bases: object

Encapsulates the categorical universe of our program topos.

Provides utility methods for constructing identity maps, verifying composition legality, and reaching the topos’s internal logic — the subobject classifier Ω and the characteristic morphism χ_S.

static identity(obj)[source]

Constructs the Identity Morphism id_A : A A for a given state.

Mathematically, this is the trivial NOOP transformation that leaves the object’s structural state completely invariant.

classmethod compose(g, f)[source]

Composes two program transformations to form a new Morphism (g ∘ f).

Requires that the codomain of f matches the domain of g. In software, this pipes the output structural block of f directly into the input of g.

verify_commutativity(f, g, h)[source]

Verify whether a triangular diagram commutes: h == g f.

In the context of program transformations, decides if a direct refactoring/shortcut (h) is structurally identical to a multi-step pipeline (g ∘ f).

static omega()[source]

Return a fresh instance of the subobject classifier Ω.

Ω carries both roles: the truth-value object of the topos and the value Heyting algebra of the internal logic. See topos.core.omega for the algebra; see classify() below for the characteristic morphism that maps programs into it.

static characteristic_morphism()[source]

Return a fresh CharacteristicMorphism (χ_S : P → Ω).

The returned object can be applied to any ProgramMorphism to produce a ClassificationResult.

classmethod classify(program)[source]

Apply χ_S : P → Ω to program and return the resulting Ω element.

Convenience wrapper around CharacteristicMorphism.classify().

classmethod classify_detailed(program)[source]

Apply χ_S : P → Ω with full per-generator detail.

Convenience wrapper around CharacteristicMorphism.classify_detailed().