Elamur Groupants⌕
☰

treestore-frag

The groupant beside tools/treestore/src/frag.rs in the Mova repository: what the code computes, what it never does, how to go back from its outputs, its invariants, cost and checks.

Facts

Implementation material. A Mova code model describes this code at one source revision: partial models, finite checks and their stated scope. It is not a reviewed general exposition, and its labels are shown as written, never raised.

Components

componentlabelwhere
ApproximantpartialApproximant
Astpartialsyntax.json
CompositionpartialComposition
Costsymbolic source derivedInvariant
DescriptantpresentDescriptant
InvariantpartialInvariant
Testsexecuted bounded checksTests

Obernants

The typed relations around the forward model: the behaviour complement (what the code never does), the reverse reconstruction (every input compatible with an output) and specialised views.

relationtypelabelwhere
Behavior complementbehavior complementpartial source derived modelBehavior complement
Reverse reconstructionreverse reconstructionpartial source derived modelReverse reconstruction

Model text

Descriptant

The meta-dictionary of typical structures: frequent runs of token shapes (tag tuple, relation, relative head) learned by pair merging (Gage 1994; Re-Pair, Larsson & Moffat 2000). With relative heads, a run whose heads point inside it is a tree fragment. Epoch 2026-11-06: measured gain over single shapes is small (see approximant).

Approximant

learn: repeat n times: take the most frequent adjacent pair (ties: smallest pair) with count ≥ min, give it a new symbol, replace its occurrences left to right; counts are updated incrementally (a lazy max-heap). encode: merge the lowest-rank pair present until none. expand: symbol → shapes. Measured on shard 00050 (structure stream + escapes): shape ids alone 2.04 MB (context coder), 1024 fragments 2.01 MB (−1.5 %), 4096 fragments 2.12 MB, 16384 fragments 2.30 MB; under zstd only: shapes 2.49 MB, 4096 fragments 2.44 MB. The gain of the structure coding comes from the joint shape symbol (split columns 3.23–3.50 MB → shapes 2.04 MB).

Invariant

expand ∘ encode = id on every shape sequence (also unseen ones; symbols below base expand to themselves). learn is deterministic. Cost: learn O(merges · affected sentences · length); encode O(len · merges applied).

Composition

model::train learns it from the sample; codec writes encode(shapes) to the shape stream and expands while decoding until the sentence's token count is reached.

Behavior complement

Does not learn non-contiguous subtrees (only runs in word order), does not use the context coder's statistics, and does not prune fragments that do not pay off.

Reverse reconstruction

Exact: a fragment sequence has one expansion; a shape sequence has one encoding for fixed merges.

Tests

frag::tests::learn_encode_expand (first merge = most frequent pair, round trip, unseen sequence, determinism, the negative control that an unknown symbol does not expand).

Provenance

This page in Markdown → https://md.groupants.elamur.ai/free/en/mova/tools/treestore/src/frag.rs.groupant/