Expand description
§panproto-gat
The GAT (Generalized Algebraic Theory) engine for panproto.
This is Level 0 of the panproto architecture, the only component implemented directly in Rust rather than as data. It provides:
- Sorts: Types that may depend on terms of other sorts
- Operations: Term constructors with typed inputs and outputs
- Equations: Judgemental equalities between terms
- Theories: Named collections of sorts, operations, and equations
- Theory morphisms: Structure-preserving maps between theories
- Colimits: Pushouts of theories for composing schema languages
- Pullbacks: Intersections of theories for overlap discovery
- Models: Interpretations of theories in Set
- Type-checking: Verification that terms and equations are well-typed
- Natural transformations: Morphisms between theory morphisms
- Free models: Initial model construction from theories
- Quotient theories: Theory simplification by merging identified elements
The mathematical foundations are based on Cartmell (1986) and
the GATlab architecture (Lynch et al., 2024).
Re-exports§
pub use composition::CompositionSpec;pub use composition::CompositionStep;pub use composition::recompose;pub use alg_struct::AlgStruct;pub use alg_struct::StructField;pub use alg_struct::StructParam;pub use refinement::RefinedSort;pub use refinement::RefinementConstraint;pub use refinement::RefinementError;pub use rewriting::ConfluenceReport;pub use rewriting::CriticalPair;pub use rewriting::OpPrecedence;pub use rewriting::RuleViolation;pub use rewriting::TerminationReport;pub use rewriting::check_local_confluence;pub use rewriting::check_termination_via_lpo;pub use rewriting::lpo_greater;pub use witness::EqWitness;pub use witness::WitnessJustification;
Modules§
- alg_
struct - Algebraic struct types for theories.
- composition
- Declarative composition specs for theory colimit recipes.
- refinement
- Refinement types: sorts constrained by predicates.
- rewriting
- Rewrite-system properties: confluence and termination.
- witness
- Equality witnesses: propositional equality proofs.
Structs§
- Case
Branch - One branch of a
Term::Caseexpression. - Check
Model Options - Options for model checking.
- Colimit
Result - Result of a categorical pushout (colimit) computation.
- Conflict
Policy - A conflict resolution policy for merge operations.
- Directed
Equation - A directed equation (rewrite rule) with a computation term.
- Equation
- An equation (axiom) in a GAT.
- Equation
Violation - A single violation of an equation in a model.
- Factorization
- The result of factorizing a theory morphism.
- Free
Model Config - Configuration for free model construction.
- Free
Model Result - Result of free model construction, including completeness status.
- Hole
Report - A report generated for each typed hole encountered by
typecheck_term_with_holes. - Ident
- A first-class identifier separating stable identity from display name.
- Model
- A model (interpretation) of a theory in Set.
- Name
- An interned name handle with a pointer-equality fast path.
- Natural
Transformation - A natural transformation between two theory morphisms F, G: T1 -> T2.
- Operation
- An operation (term constructor) in a GAT.
- Pullback
Result - Result of a pullback computation.
- Scope
Tag - An opaque scope tag distinguishing different naming contexts.
- Site
Rename - A site-qualified rename operation.
- Sort
- A sort declaration in a GAT.
- Sort
Param - A parameter of a dependent sort.
- Sort
Scheme - A sort scheme: a sort expression universally quantified over a list of metavariable names.
- Theory
- A generalized algebraic theory (GAT).
- Theory
Endofunctor - A theory endofunctor: maps theories to theories.
- Theory
Morphism - A structure-preserving map between two theories.
Enums§
- Coercion
Class - Classification of a coercion’s round-trip properties.
- Conflict
Strategy - A conflict resolution strategy for merge operations.
- GatError
- Errors that can occur in GAT operations.
- Implicit
- Implicit/explicit tag on an
Operationinput parameter. - Model
Value - A value in a model interpretation.
- Name
Site - Enumerates the 9 naming sites in the panproto system.
- Sort
Closure - Closure attribute on a
Sort. - Sort
Expr - A sort expression: a plain sort name or a dependent sort applied to argument terms.
- Sort
Kind - The kind of a sort, distinguishing structural sorts from value/coercion sorts.
- Term
- A term in a GAT expression.
- Theory
Constraint - A predicate on theories: the precondition for applying a transform.
- Theory
Transform - How a theory endofunctor transforms a theory.
- Value
Kind - The primitive value kind that a value sort ranges over.
Functions§
- alpha_
equivalent - Check if two terms are α-equivalent (equal up to consistent variable renaming).
- alpha_
equivalent_ equation - Check if two equations are α-equivalent.
- check_
interchange - Check the interchange law for 2-categorical structure.
- check_
model - Check whether a model satisfies all equations of its theory.
- check_
model_ with_ options - Check with configurable options.
- check_
morphism - Soundness note on equation preservation
- check_
natural_ transformation - Check that a natural transformation is valid.
- classify_
builtin_ coercion - Classify a builtin coercion operation by its source/target value kinds and round-trip class.
- colimit
- Compute the pushout (colimit) of two theories over explicit morphisms.
- colimit_
by_ name - Compute the pushout (colimit) of two theories over a shared base theory.
- compose_
subst - Compose two term substitutions.
- factorize
- Factorize a theory morphism into elementary endofunctors.
- free_
model - Construct a bounded approximation of the free (initial) model.
- horizontal_
compose - Horizontal composition: given alpha: F => G and beta: H => K where G’s codomain is H’s domain, produce (beta * alpha): H.F => K.G.
- infer_
var_ sorts - Infer variable sorts from an equation’s term structure.
- match_
pattern - Try to match a pattern term against a concrete term, returning a substitution if successful. Pattern variables can match any subterm; operation names must match exactly.
- migrate_
model - Migrate a model along a theory morphism.
- normalize
- Normalize a term by repeatedly applying directed equations as rewrite rules.
- positional_
param_ rename - Build a variable-rename substitution that sends each domain parameter name to the codomain parameter name at the same position.
- pullback
- Compute the pullback of two theories over a common codomain.
- quotient
- Quotient a theory by identifying sorts and/or operations.
- resolve_
theory - Resolve a theory by computing the transitive closure of its
extendschain. - signatures_
equivalent_ modulo_ param_ rename - Compare two operation or sort signatures modulo positional alpha-rename of the declared parameter names.
- sort_
params_ equivalent_ modulo_ rename - Compare two sort declarations’ parameter blocks modulo positional alpha-rename of the declared parameter names.
- th_
editable_ structure - The abstract theory of editable structures (Hofmann, Pierce, Wagner 2012).
- typecheck_
equation - Typecheck an equation: infer variable sorts, typecheck both sides, verify they produce the same output sort.
- typecheck_
equation_ modulo_ rewrites - Typecheck an equation with sort equality relaxed modulo a set of directed rewrite rules.
- typecheck_
term - Infer the output sort expression of a term given a variable context and theory.
- typecheck_
term_ with_ holes - Typecheck a term, collecting a
HoleReportat everyTerm::Holesite. - typecheck_
theory - Typecheck all equations in a theory.
- validate_
factorization - Validate that applying a factorization to the domain yields a theory compatible with the codomain.
- vertical_
compose - Vertical composition: given alpha: F => G and beta: G => H, produce beta . alpha: F => H.
Type Aliases§
- VarContext
- A variable typing context.