Elamur GroupantsโŒ•
โ˜ฐ

algorithm-dag-path-count

The groupant beside algorithms/src/dag_path_count/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
compositionpartialComposition
descriptantpresentEpoch memory
invariantpartialInvariant
testsexecuted bounded checksevidence

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 source derived modelbehavior-complement
reverse-reconstructionreverse_reconstructionpartial source derived modelreverse-reconstruction
parallelarc_multiplicitypartial source derived modelparallel
unreachablezero_extensionpartial source derived modelunreachable
overflowchecked_arithmetic_boundarypartial source derived modeloverflow
renamingvertex_transportpartial source derived modelrenaming
validationerror_precedencepartial source derived modelvalidation

Parts

Model text

model

algorithm-dag-path-count

Domain

Finite materialized ordered graphs and machine-sized indices, fixed input, successful allocation. Observations are returned Result values; allocator failure and wall-clock timing are outside the relation.

Source: algorithms/src/dag_path_count/mod.rs; SHA-256: b373088f752be5d16a5de4fc5189b923fe7c65f240ac462598221fd38919856e. Observation is one completed invocation. Models are exact specifications with partial source correspondence, not semantic AST proofs.

Forward

Reject an invalid source before inspecting edges. Run topological_sort on the entire graph: first invalid adjacency target precedes any cycle error. In a globally valid DAG set c[source]=1, then add c[u] once along each arc u->v with checked u128 addition. Count includes the empty path; unreachable vertices get zero. Overflow is the first failing (from,to) in smallest-available topological order and input adjacency order.

Cost

O(E+V log(V+1)) time and O(V) auxiliary space from the reused heap-based topological_sort, plus O(V+E) checked DP. Output has V u128 values. Counts cannot wrap: checked_add returns an error at the first overflow. Unreachable components can have exponentially many internal paths without overflow because all propagated source counts there are zero.

Invariant

After processing a topological prefix, each count equals the sum of contributions from already processed incoming arc identities plus the source empty-path indicator. Before processing a vertex all its predecessors have contributed. Global acyclicity is already established before any count or overflow result is emitted.

behavior-complement

Type: behavior_complement. For domain D and Result space Y let R be the stated exact forward relation. The behavior complement is (D x Y) minus R, including wrong memberships/counts, malformed canonical outputs, wrong errors and wrong precedence. This is a specification complement; correspondence to source is partial and is not a proof. Domain and observation scope are those above; assumptions are fixed inputs, successful allocation and trusted compiler/library. Evidence: evidence.md. Status: partial_source_derived_model.

reverse-reconstruction

Type: reverse_reconstruction. For successful c and source s retain every DAG whose arc multiplicities satisfy c[v]=[v=s]+sum incoming c[u], within u128. Counts do not reconstruct edges; zero-count components are especially ambiguous. Error fibers retain inputs with the stated validation failure or first ordered overflowing addition. Domain and observation scope are those above; assumptions are fixed inputs, successful allocation and trusted compiler/library. Evidence: evidence.md. Status: partial_source_derived_model.

parallel

Type: arc_multiplicity. Duplicating an arc duplicates its predecessor contribution, not merely reachability; downstream increments equal the number of continuations. Domain and observation scope are those above; assumptions are fixed inputs, successful allocation and trusted compiler/library. Evidence: evidence.md. Status: partial_source_derived_model.

unreachable

Type: zero_extension. A disconnected acyclic component has zero source counts even when its own path count exceeds u128; a cycle there still rejects the whole input. Domain and observation scope are those above; assumptions are fixed inputs, successful allocation and trusted compiler/library. Evidence: evidence.md. Status: partial_source_derived_model.

overflow

Type: checked_arithmetic_boundary. A reachable exact count of u128::MAX is accepted; the next positive contribution fails. Error endpoint is determined by traversal order, not a shortest witness. Domain and observation scope are those above; assumptions are fixed inputs, successful allocation and trusted compiler/library. Evidence: evidence.md. Status: partial_source_derived_model.

renaming

Type: vertex_transport. A vertex bijection permutes successful counts and source. Overflow witnesses can change because numeric tie ordering changes. Domain and observation scope are those above; assumptions are fixed inputs, successful allocation and trusted compiler/library. Evidence: evidence.md. Status: partial_source_derived_model.

validation

Type: error_precedence. Invalid source precedes invalid edge, which precedes global cycle, which precedes count overflow. A disconnected cycle is never hidden by reachability. Domain and observation scope are those above; assumptions are fixed inputs, successful allocation and trusted compiler/library. Evidence: evidence.md. Status: partial_source_derived_model.

Composition

Intersect the source projection, forward relation, ordered typed obernants, invariants and finite evidence. Tests constrain observations but do not prove all wiring. Parent library exports and registry integration are checked separately.

Epoch memory

Prospective predictions were saved before implementation in ../prospective.md. Original code and fixtures; conceptual origin: Tarjan (1972) lowlink blocks and Kahn (1962) topological ordering with standard DAG recurrence. Existing bridges adjacency and topological_sort were inspected and reused. Production checks matched the first implementation; no semantic repair was needed.

Limits

Allocation failure is excluded. Syntax projection has no macro expansion or semantic resolution. Finite oracles are not unrestricted proofs. An executable approximate surrogate is an explicit gap: no useful certified relaxed metric was established for edge partitions or exact checked counts; the exact oracle is not a speed surrogate.

evidence

Evidence, 2026-10-30

All 456 algorithm library tests passed twice in debug and twice in release; normalized sorted test records were identical. Each new module contributes four tests. Production mutations: replace the lowlink block boundary with true, rejected by articulation_parallel_loops; replace source count one with zero, rejected by exhaustive_path_enumeration. Both compiled and failed named equality assertions; original source bytes were restored and all four tests per module passed again. Strict production Clippy passed. These are finite observations, not speed or unrestricted correctness claims.

External evidence under $MOVA_DATA/runs/octopus-wave18-graphs-2026-10-30:

Source SHA-256: b373088f752be5d16a5de4fc5189b923fe7c65f240ac462598221fd38919856e. Prospective record: ../prospective.md. Syntax projection generated independently twice and compared byte-for-byte.

prospective

Prospective model, 2026-10-30

Validate source, then global graph via topological_sort, then checked u128 DAG recurrence. Count empty path once; parallel arcs distinct. O(E+V log(V+1)) time, O(V) auxiliary storage. Overflow at first deterministic failed addition. Complement includes wrapping, remote-cycle acceptance and incorrect validation precedence. Reverse fiber retains every DAG satisfying the count recurrence, not unique adjacency. Allocation failure excluded; no useful certified approximation metric established.

This page in Markdown โ†’ https://md.groupants.elamur.ai/free/en/mova/algorithms/src/dag_path_count/mod.rs.groupant/