Skip to main content

Crate pertaro

Crate pertaro 

Source
Expand description

§PERTARO

Pruned Expert Regrounding Trie via Answer-set Reduct Optimization.

A #![no_std], zero-heap neuro-symbolic micro-expert primitive that packs a 5-tier ternary decision trie (3^5 = 243 leaves) plus a 13-state in-band control envelope (243..=255) into one exact 256-byte cache-aligned word.

§Byte contract

One byte has 256 states: 0..243 are 5-trit coordinates, 243..=255 are the 13 Sentinel control states. A Word256 is header-first:

offsetfieldmeaning
0..8hash: u64xorshift64 seed of the default leaf field
8..12parent: u32lineage link to the parent horizon word
12..255trits[0..243]243 leaf deltas or in-band sentinels
255trits[243]root sentinel: the active horizon phase

§Default field

The seed’s xorshift64 stream is turned into 243 uniform Z_243 digits by radix-243 extraction: 243^8 < 2^64, so every state below 243^8 holds eight exact, independent digits; states at or above it are rejected, not reduced. No % 243 bias anywhere.

Structs§

PertaroExpert243
Zero-cost view over Word256: the payload as a 5-tier micro-expert.
Word256
Sealed 256-byte header-first word, aligned to 256 bytes (four cache lines).

Enums§

Sentinel
The 13 in-band control states, bytes 243..=255.

Constants§

DIGITS_PER_WORD
Digits one accepted xorshift64 state yields.
FNV1A64_BASIS
Canonical FNV-1a 64-bit offset basis.
FNV1A64_PRIME
Canonical FNV-1a 64-bit prime.
LEAVES
Trie leaves: 3^5 = 243, one byte each.
MAX_PACKED
Count of 5-trit coordinate values in one byte: 3^5 = 243.
PAYLOAD_BYTES
Payload width: 243 leaves + 1 root sentinel.
RADIX_243_POW_8
243^8: the rejection threshold for unbiased radix-243 extraction.
ROOT_SENTINEL
Payload index of the root sentinel byte, the one byte past the leaves.
SENTINEL_COUNT
Count of in-band control states: 256 - 243 = 13.
TIERS
Trie depth: five ternary tiers address one leaf.

Functions§

fnv1a64_fold
FNV-1a 64-bit fold of bytes onto a running hash. Start from FNV1A64_BASIS. The single FNV home in this crate.
xorshift64
One xorshift64 step (13, 7, 17). 0 is a fixed point.