Overview
AXON’s type system is epistemic—it tracks the nature and reliability of information, not memory layout. The type system has four layers, from simple nominal types to dependent types, all designed to remain decidable at compile-time.Key Principle
Type Layers
AXON has four type system layers:- Nominal — Name-based identity
- Structural Epistemic — Cognitive compatibility
- Refinement — Predicate-constrained types
- Dependent (Light) — Statically parameterized types
Layer 1: Nominal Types
Nominal types are identified by name. Two types are equal only if they have the same name.Syntax
Examples
Party ≠ Witness even though they have identical structure. Nominal typing uses name identity.
When to Use
- Domain-specific entities
- Business concepts
- When structural similarity doesn’t imply semantic equivalence
Layer 2: Structural Epistemic Types
Structural compatibility based on cognitive status, not field matching.Built-in Epistemic Types
Compatibility Rules
Example
Uncertainty Propagation
Uncertainty is infectious—once data becomes uncertain, everything computed from it is also uncertain:Layer 3: Refinement Types
Refine base types with decidable predicates.Range Constraints
Where Clauses
Allowed Predicates
Refinement predicates must be decidable:| ✅ Allowed | Example | Why |
|---|---|---|
| Numeric comparison | value >= 0.95 | Computable |
| Emptiness check | name ≠ ∅ | Computable |
| Length check | length > 0 | Computable |
| Set membership | role ∈ ValidRoles | Finite set |
| Conjunction | P ∧ Q | Both decidable |
| ❌ Prohibited | Example | Why |
|---|---|---|
| LLM judgment | is_factual(text) | Non-deterministic |
| Inference | sentiment(x) > 0 | Requires LLM |
| Unbounded quantification | ∀ field: P(field) | Undecidable |
Example
Layer 4: Dependent Types (Light)
Status: Planned for v1.5+ Dependent types parameterized by static constants (not runtime values).Planned Syntax
What’s Allowed
| ✅ Allowed | Example |
|---|---|
| Integer constants | BoundedList<Party, 100> |
| Enum values | Memory<scope: persistent> |
| Arithmetic on constants | Window<n * 2> where n is const |
| Static bounds | where n ≤ 50 |
| ❌ Prohibited | Example | Why |
|---|---|---|
| LLM outputs | Result<confidence: llm.score> | Non-deterministic |
| Runtime variables | List<T, len: user_input> | Unknown at compile-time |
| Unbounded recursion | Tree<depth: depth(x)> | Undecidable |
Type Definition Syntax
Simple Type
Structured Type
Range-Constrained Type
Refined Type
Type with Where Clause
Combining Features
Type Expressions
Basic Type Reference
Generic Types
Optional Types
Nested Types
Generic Type Parameters
Current support:Optional Fields
Mark fields as optional with?:
Built-in Types
Primitive Types
Epistemic Types
Content Types
Analysis Types
Collection Types
Type Compatibility Matrix
Can Substitute
Cannot Substitute
Uncertainty Taints
Complete Examples
Domain Model
Epistemic Constraints
Range and Refinement
Best Practices
1. Use Nominal Types for Domain Concepts
2. Use Epistemic Types for Information Quality
3. Use Refinement for Constraints
4. Mark Optional Fields Explicitly
5. Prevent Opinion/Fact Confusion
Type Checking
The AXON type checker validates: ✅ Name resolution: All referenced types exist✅ Epistemic compatibility:
Opinion cannot substitute for FactualClaim✅ Range validity:
min < max in range constraints✅ Field types: All field types are valid
✅ Generic parameters: Generic type arguments are valid
Types vs. Contracts
| Aspect | Types | Contracts |
|---|---|---|
| When | Compile-time | Runtime |
| Purpose | Define validity | Enforce validity |
| Decidability | Always decidable | Empirically verified |
| Dependencies | No LLM dependency | May depend on LLM |
Example
Related
- Anchor — Runtime constraints
- Flow — Typed cognitive pipelines
- Persona — Agent identities
- Syntax Overview — Language syntax
