Elamur Groupants⌕
☰

algorithm-subset-mobius

The groupant beside algorithms/src/subset_mobius/mod.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
approximantpartialForward
astpartialsyntax.json
costconditionalCost
descriptantpresentdescriptant
invariantpartialInvariant
testsbounded executedevidence

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.

idtypelabelwhere
behavior_complementbehavior_complementpartial relational specificationbehavior_complement
reverse_reconstructionreverse_reconstructionpartial relational specificationreverse_reconstruction
inclusion_exclusioninclusion_exclusionpartial relational specificationinclusion_exclusion
subtraction_boundarysubtraction_boundarypartial relational specificationsubtraction_boundary
validation_partitionvalidation_partitionpartial relational specificationvalidation_partition

Model text

descriptant

subset_mobius mod.rs

Epoch 2026-10-30: prospective model selected bounded exact computation before implementation. kn mask visits, kn/2 modular subtractions, n normalizations; O(n log n) time and O(1) extra space, n<=2^20. No primality test, inversions, allocation or speed claim.

Retained observation: Tie orientation, residue normalization and first-error order are part of the public behavior, not incidental implementation choices.

The reference attribution is in production module documentation. No copied solution text or implementation is used. No approximate surrogate is useful for the exact API here, and no performance gain is claimed. Partial syntax is generated twice identically; macro bodies remain opaque and semantic AST/proofs are absent. These small files have no nested fragments.

model

subset_mobius mod.rs model

Forward

For n=2^k nonempty,m>0, y[S]=sum_{T subset S} (-1)^(popcount(S xor T)) x[T] mod m. Normalize then subtract each bit-cleared coefficient from bit-set coefficients, once per coordinate. This is subset-lattice Mobius inversion, inverse to subset zeta over every Z/mZ.

Invariant

Length unchanged, residues in [0,m). If a>=b use a-b, else m-(b-a), with normalized operands; neither branch overflows or returns m. Bit-cleared source remains fixed within a stage. Invalid calls preserve raw vector bytes.

Cost

kn mask visits, kn/2 modular subtractions, n normalizations; O(n log n) time and O(1) extra space, n<=2^20. No primality test, inversions, allocation or speed claim.

behavior_complement

Universe: (raw vector,modulus,result,final vector). Admitted outputs differing from the signed literal submask sum modulo m are absent, as are residues >=m and changed lengths. Invalid input with Ok or changed raw values is absent. ZeroModulus precedes Empty, NotPowerOfTwo, TooLong.

reverse_reconstruction

For fixed valid n,m normalized outputs have unique normalized antecedents given by zeta sums. Raw u64 inputs remain ambiguous by adding multiples of m where representable. For m=1 every raw input of fixed shape yields all zeros. Error observations do not recover original entries.

inclusion_exclusion

Each removed coordinate contributes one negative sign, yielding (-1)^popcount(S xor T). The oracle sums signed i128 raw coefficients directly, independently of stage logic; its n<=8 domain fits i128 easily.

subtraction_boundary

For a<b the distance b-a is in 1..m, so m-(b-a) is in 1..m. For a>=b the difference is <m. This supports composite moduli and u64::MAX without signed conversion in production.

validation_partition

Check m=0, empty, non-power-of-two, cap in this exact order before any normalization. Full-cap constant raw input becomes one normalized coefficient at index0 and zeros elsewhere; errors preserve nonnormalized values.

evidence

Evidence, 2026-10-30

Source SHA-256: d63acc0b6b3a974ba487084fafa0311f413941810f56c6d261cb9e2bb5b2d642. Twelve focused named tests (three per module) pass twice in debug and twice in release with identical normalized outcomes. Strict all-target Clippy and narrow rustfmt pass. Each production module has a compiled negative control rejected by its exhaustive assertion; test false-oracle controls are separately rejected. Exact source bytes are restored and positives rerun.

Cartesian and inversion enumerate sum(3^n,n=0..8)=9841 vectors each; subset files enumerate 3+9+81+6561=6654 vectors at five moduli, 33270 comparisons each. Cap fixtures dominate memory/time; no benchmark claim.

Raw logs are external. Bound evidence hashes:

No whole-repository test, allocator injection, general proof, live parser/teacher/GPU, approximation-error or runtime improvement claim.

This page in Markdown → https://md.groupants.elamur.ai/free/en/mova/algorithms/src/subset_mobius/mod.rs.groupant/