---
title: "algorithm-totient-sieve-tests — Mova code model"
description: "Mova code model of algorithms/src/totient_sieve/tests.rs: components with their labels, obernants and the model text."
url: "https://groupants.elamur.ai/free/en/mova/algorithms/src/totient_sieve/tests.rs.groupant/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Research](https://md.research.elamur.ai/free/en/) · **Groupants**

This page as HTML: <https://groupants.elamur.ai/free/en/mova/algorithms/src/totient_sieve/tests.rs.groupant/>

# algorithm-totient-sieve-tests

The groupant beside algorithms/src/totient_sieve/tests.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

- **kind:** groupant
- **status:** partial source derived instance
- **source:** [`algorithms/src/totient_sieve/tests.rs`](https://github.com/ElamurAI/mova-free/blob/main/algorithms/src/totient_sieve/tests.rs)
- **source SHA-256:** `2b39f420ef0c2c90…`
- **repository folder:** [`algorithms/src/totient_sieve/tests.rs.groupant`](https://github.com/ElamurAI/mova-free/tree/main/algorithms/src/totient_sieve/tests.rs.groupant)
- **repository commit:** `48f2e6f74146`

> **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

| component | label | where |
|---|---|---|
| **approximant** | partial | [Forward](#forward) |
| **ast** | partial | `syntax.json` |
| **cost** | conditional | [Cost](#cost) |
| **descriptant** | present | [descriptant](#descriptant) |
| **invariant** | partial | [Invariant](#invariant) |
| **tests** | bounded executed | [evidence](#evidence) |

## 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.

| id | type | label | where |
|---|---|---|---|
| `behavior_complement` | behavior_complement | partial relational specification | [behavior_complement](#behavior-complement) |
| `reverse_reconstruction` | reverse_reconstruction | partial relational specification | [reverse_reconstruction](#reverse-reconstruction) |
| `coprime_oracle` | coprime_oracle | partial relational specification | [coprime_oracle](#coprime-oracle) |
| `divisor_identity` | divisor_identity | partial relational specification | [divisor_identity](#divisor-identity) |
| `resource_partition` | resource_partition | partial relational specification | [resource_partition](#resource-partition) |
| `prime_update` | prime_update | partial relational specification | [prime_update](#prime-update) |

## Model text


### descriptant

#### algorithm-totient-sieve-tests

Epoch2026-10-30: original implementation and independent fixtures. Prospective relation: Finite executable observation: Return inclusive phi table, phi(0)=0, phi(1)=1; phi(k) counts integers1..k coprime to k. Initialize phi(k)=k, then for each prime p eliminate its factor by phi(multiple)-=phi(multiple)/p. Reject n>1000000 before allocation. Reference: Hardy and Wright, An Introduction to the Theory of Numbers, chapter V, Euler's function and its product formula. Assertions check independent arithmetic oracles, boundaries and identities; passing fixtures do not establish untested behavior.

Predicted cost: O(n log log n) arithmetic and O(n) storage. GCD oracle through2048 has O(N^2 log N) upper bound. Allocation failure follows Vec policy.

Compiled controls are rejected and exact bytes restored. Six file roots contain36 typed views, no fragments. Twice-identical partial syntax binds source; macros remain opaque. No semantic AST, formal proof, approximate surrogate or speed claim.

### model

## algorithm-totient-sieve-tests

### Forward

Finite executable observation: Return inclusive phi table, phi(0)=0, phi(1)=1; phi(k) counts integers1..k coprime to k. Initialize phi(k)=k, then for each prime p eliminate its factor by phi(multiple)-=phi(multiple)/p. Reject n>1000000 before allocation. Reference: Hardy and Wright, An Introduction to the Theory of Numbers, chapter V, Euler's function and its product formula. Assertions check independent arithmetic oracles, boundaries and identities; passing fixtures do not establish untested behavior.

### Invariant

Entries equal k times product(1-1/p) over processed prime divisors; updates divide exactly. 0<=phi(k)<=k; cap bounds indices.

### Cost

O(n log log n) arithmetic and O(n) storage. GCD oracle through2048 has O(N^2 log N) upper bound. Allocation failure follows Vec policy.

### behavior_complement

Universe is fixture executions and assertion outcomes. A passing actual/expected mismatch is excluded; failure cannot count as success. This finite complement does not cover all API calls.

### reverse_reconstruction

Passing summary retains every implementation agreeing on exercised fixtures, including implementations wrong elsewhere. Failure locates an observed disagreement but cannot alone distinguish oracle and implementation defects.

### coprime_oracle

GCD counting independently checks each n=1..2048 without prime-factor elimination.

### divisor_identity

For n>=1, sum_{d|n} phi(d)=n; tests check n<=512, partitioning integers by gcd.

### resource_partition

n=0,1 and MAX_N accepted; phi(MAX_N)=400000. MAX_N+1 and usize::MAX rejected before allocation.

### prime_update

phi(p)=p identifies prime p>=2. Omitting subtraction compiles and fails exhaustive_gcd_oracle.

### evidence

#### Evidence

Source SHA-256: 2b39f420ef0c2c90a5baa6b74dc4a74e68f4a3103eb751be2a43eaad341e32ba.

Nine tests total, three per algorithm, pass twice debug and twice release with identical normalized outcomes. Three compiled production controls fail exhaustive_gcd_oracle, exhaustive_factor_oracle and exhaustive_iterative_oracle; exact bytes restored before positives. Strict all-target Clippy and narrow formatting pass. External wave16 numeric bundle retains logs. Finite checks do not establish universal correctness or allocator success.

- debug-1-totient_sieve.log: e061a404779be971019b2d63adca6e2c027ce73d7e8d21793469286d388f5417
- debug-2-totient_sieve.log: a5e3a4fd4e68a9214222cc13e5c745d044da9db6de2b55a4571b0bf1c9d2fe1e
- release-1-totient_sieve.log: 5ec9a2f63ebd17b9db456d372c83fb6b552acb2c28cb3c6c476f528f0d2f6316
- release-2-totient_sieve.log: d71671b64a4564f68bf9688908592de260750274d4ba15bd5fbc3037c4fd176e
- mutant-totient_sieve.log: 8ac9bdc98245338db9d3d3ad551316f75d88b078eb8b49948ea1057b63e7f9a5
