Skip to main content

Term

Enum Term 

Source
pub enum Term<'a, const INLINE_BYTES: usize> {
Show 21 variants Literal { value: TermValue<'a, INLINE_BYTES>, level: WittLevel, }, Variable { name_index: u32, }, Application { operator: PrimitiveOp, args: TermList, }, Lift { operand_index: u32, target: WittLevel, }, Project { operand_index: u32, target: WittLevel, }, Match { scrutinee_index: u32, arms: TermList, }, Recurse { measure_index: u32, base_index: u32, step_index: u32, }, Unfold { seed_index: u32, step_index: u32, }, Try { body_index: u32, handler_index: u32, }, AxisInvocation { axis_index: u32, kernel_id: u32, input_index: u32, }, ProjectField { source_index: u32, byte_offset: u32, byte_length: u32, }, FirstAdmit { domain_size_index: u32, predicate_index: u32, }, Nerve { value_index: u32, }, ChainComplex { simplicial_index: u32, }, HomologyGroups { chain_index: u32, }, Betti { homology_index: u32, }, CochainComplex { chain_index: u32, }, CohomologyGroups { cochain_index: u32, }, PostnikovTower { simplicial_index: u32, }, HomotopyGroups { postnikov_index: u32, }, KInvariants { homotopy_index: u32, },
}
Expand description

Concrete AST node for the UOR term language. Mirrors the EBNF grammar productions. All child references are indices into a TermArena, keeping the AST stack-resident and #![no_std]-safe.

§Examples

use uor_foundation::enforcement::{Term, TermList};
use uor_foundation::{WittLevel, PrimitiveOp};

// ADR-060: `Term` carries `<'a, const INLINE_BYTES: usize>`. The
// application instantiates `INLINE_BYTES` from its selected
// `HostBounds` via `pipeline::carrier_inline_bytes::<B>()`; this
// example fixes a concrete width.
const N: usize = 32;

// Literal: an integer value tagged with a Witt level.
let lit: Term<'static, N> =
    uor_foundation::pipeline::literal_u64(42, WittLevel::W8);

// Application: an operation applied to arguments.
// `args` is a TermList { start, len } pointing into a TermArena.
let app: Term<'static, N> = Term::Application {
    operator: PrimitiveOp::Mul,
    args: TermList { start: 0, len: 2 },
};

// Lift: canonical injection from a lower to a higher Witt level.
let lift: Term<'static, N> =
    Term::Lift { operand_index: 0, target: WittLevel::new(32) };

// Project: canonical surjection from a higher to a lower level.
let proj: Term<'static, N> =
    Term::Project { operand_index: 0, target: WittLevel::W8 };
let _ = (lit, app, lift, proj);

Variants§

§

Literal

Integer literal with Witt level annotation. Per ADR-051 the value carrier is a TermValue byte sequence whose length matches the declared level’s byte width. Use uor_foundation::pipeline::literal_u64(value, level) to construct a literal from a u64 value (the narrow form).

Fields

§value: TermValue<'a, INLINE_BYTES>

The literal value as a source-polymorphic carrier (ADR-051 + ADR-060). Inline length equals level.witt_length() / 8. Wider widths (W128, W256, …) are natively representable without Concat composition.

§level: WittLevel

The Witt level of this literal.

§

Variable

Variable reference by name index.

Fields

§name_index: u32

Index into the name table.

§

Application

Operation application: operator applied to arguments.

Fields

§operator: PrimitiveOp

The primitive operation to apply.

§args: TermList

Argument list (indices into arena).

§

Lift

Lift: canonical injection W_n to W_m (n < m, lossless).

Fields

§operand_index: u32

Index of the operand term in the arena.

§target: WittLevel

Target Witt level.

§

Project

Project: canonical surjection W_m to W_n (m > n, lossy).

Fields

§operand_index: u32

Index of the operand term in the arena.

§target: WittLevel

Target Witt level.

§

Match

Match expression with pattern-result pairs.

Fields

§scrutinee_index: u32

Index of the scrutinee term in the arena.

§arms: TermList

Match arms (indices into arena).

§

Recurse

Bounded recursion with descent measure.

Fields

§measure_index: u32

Index of the descent measure term.

§base_index: u32

Index of the base case term.

§step_index: u32

Index of the recursive step term.

§

Unfold

Stream construction via unfold.

Fields

§seed_index: u32

Index of the seed term.

§step_index: u32

Index of the step function term.

§

Try

Try expression with failure recovery.

Fields

§body_index: u32

Index of the body term.

§handler_index: u32

Index of the handler term.

§

AxisInvocation

Substitution-axis-realized verb projection (wiki ADR-029 + ADR-030). Delegates evaluation to the application’s AxisTuple substitution-axis impl: the catamorphism evaluates the input subtree, dispatches the axis at axis_index to the kernel identified by kernel_id, and emits the kernel’s output as the result. Emitted by prism_model! from the closure-body form hash(input) (ADR-026 G19, which lowers to AxisInvocation against the application’s HashAxis).

Fields

§axis_index: u32

Position of the axis in the application’s AxisTuple.

§kernel_id: u32

Per-axis kernel id (the SDK macro emits per-method KERNEL_* consts).

§input_index: u32

Input subtree’s arena index (single input — current axes are 1-arg).

§

ProjectField

Field-access projection over a partition_product input (wiki ADR-033 G20). The catamorphism’s fold-rule evaluates source and slices [byte_offset .. byte_offset + byte_length] from the resulting bytes. Emitted by prism_model! and verb! from the closure-body forms <expr>.<index> and <expr>.<field_name> (named-field access requires the partition_product! declaration to use the named-field form). Coproduct field-access is rejected at macro-expansion time.

Fields

§source_index: u32

Arena index of the source expression’s term tree.

§byte_offset: u32

Byte offset into the source’s evaluated bytes (proc- macro-computed from the partition-product factor widths).

§byte_length: u32

Length of the projected slice in bytes.

§

FirstAdmit

Bounded search with structural early termination (wiki ADR-034). The catamorphism iterates idx from 0 up to (but excluding) the evaluated domain_size; for each iteration it evaluates predicate with FIRST_ADMIT_IDX_NAME_INDEX bound to idx. On the first non-zero predicate result the fold emits the coproduct value (0x01, idx_bytes) and terminates iteration; if no idx admits, the fold emits (0x00, idx-width zero bytes). Emitted by prism_model! and verb! from the closure-body form first_admit(<DomainTy>, |idx| <pred>) (ADR-026 G16; the lowering target shifted from Term::Recurse to Term::FirstAdmit per ADR-034’s structural-search commitment).

Fields

§domain_size_index: u32

Arena index of the domain-cardinality term (typically a Term::Literal carrying <DomainTy as ConstrainedTypeShape>::CYCLE_SIZE).

§predicate_index: u32

Arena index of the predicate body. Evaluation visits predicate with FIRST_ADMIT_IDX_NAME_INDEX bound to the current candidate idx.

§

Nerve

ψ_1 (wiki ADR-035): nerve construction — Constraints → SimplicialComplex. Lowered from the closure-body form nerve(<value_expr>) (G21). Resolver-bound: consults the ResolverTuple’s NerveResolver per ADR-036.

Fields

§value_index: u32

Arena index of the value-bytes operand (typically a Term::Variable for the route input or a Term::ProjectField).

§

ChainComplex

ψ_2 (wiki ADR-035): chain functor — SimplicialComplex → ChainComplex. Lowered from chain_complex(<simplicial_expr>) (G22). Resolver-bound: ChainComplexResolver per ADR-036.

Fields

§simplicial_index: u32
§

HomologyGroups

ψ_3 (wiki ADR-035): homology functor — ChainComplex → HomologyGroups. H_k(C) = ker(∂_k) / im(∂_{k+1}). Lowered from homology_groups(<chain_expr>) (G23). Resolver-bound: HomologyGroupResolver per ADR-036.

Fields

§chain_index: u32
§

Betti

ψ_4 (wiki ADR-035): Betti-number extraction — HomologyGroups → BettiNumbers. Pure computation on resolved homology groups; no resolver consultation. Lowered from betti(<homology_expr>) (G24).

Fields

§homology_index: u32
§

CochainComplex

ψ_5 (wiki ADR-035): dualization functor — ChainComplex → CochainComplex. C^k = Hom(C_k, R). Lowered from cochain_complex(<chain_expr>) (G25). Resolver-bound: CochainComplexResolver per ADR-036.

Fields

§chain_index: u32
§

CohomologyGroups

ψ_6 (wiki ADR-035): cohomology functor — CochainComplex → CohomologyGroups. H^k(C) = ker(δ^k) / im(δ^{k-1}). Lowered from cohomology_groups(<cochain_expr>) (G26). Resolver-bound: CohomologyGroupResolver per ADR-036.

Fields

§cochain_index: u32
§

PostnikovTower

ψ_7 (wiki ADR-035): Kan-completion + Postnikov truncation — SimplicialComplex → PostnikovTower. The PostnikovResolver performs the Kan-completion internally; verb authors do not need to construct KanComplex values explicitly. Lowered from postnikov_tower(<simplicial_expr>) (G27). Resolver-bound: PostnikovResolver per ADR-036.

Fields

§simplicial_index: u32
§

HomotopyGroups

ψ_8 (wiki ADR-035): homotopy extraction — PostnikovTower → HomotopyGroups. π_k from each truncation stage. Lowered from homotopy_groups(<postnikov_expr>) (G28). Resolver-bound: HomotopyGroupResolver per ADR-036.

Fields

§postnikov_index: u32
§

KInvariants

ψ_9 (wiki ADR-035): k-invariant computation — HomotopyGroups → KInvariants. κ_k classifying the Postnikov tower. Lowered from k_invariants(<homotopy_expr>) (G29). Resolver-bound: KInvariantResolver per ADR-036.

Fields

§homotopy_index: u32

Trait Implementations§

Source§

impl<'a, const INLINE_BYTES: usize> Clone for Term<'a, INLINE_BYTES>

Source§

fn clone(&self) -> Term<'a, INLINE_BYTES>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, const INLINE_BYTES: usize> Debug for Term<'a, INLINE_BYTES>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, const INLINE_BYTES: usize> PartialEq for Term<'a, INLINE_BYTES>

Source§

fn eq(&self, other: &Term<'a, INLINE_BYTES>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, const INLINE_BYTES: usize> Copy for Term<'a, INLINE_BYTES>

Source§

impl<'a, const INLINE_BYTES: usize> Eq for Term<'a, INLINE_BYTES>

Source§

impl<'a, const INLINE_BYTES: usize> StructuralPartialEq for Term<'a, INLINE_BYTES>

Auto Trait Implementations§

§

impl<'a, const INLINE_BYTES: usize> Freeze for Term<'a, INLINE_BYTES>

§

impl<'a, const INLINE_BYTES: usize> !RefUnwindSafe for Term<'a, INLINE_BYTES>

§

impl<'a, const INLINE_BYTES: usize> !Send for Term<'a, INLINE_BYTES>

§

impl<'a, const INLINE_BYTES: usize> !Sync for Term<'a, INLINE_BYTES>

§

impl<'a, const INLINE_BYTES: usize> Unpin for Term<'a, INLINE_BYTES>

§

impl<'a, const INLINE_BYTES: usize> UnsafeUnpin for Term<'a, INLINE_BYTES>

§

impl<'a, const INLINE_BYTES: usize> !UnwindSafe for Term<'a, INLINE_BYTES>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.