The randomness paradox.

This note runs one 33-line Aver program through declared verification, hostile effect profiles and both proof exporters. The results include the proof-gate fields. Those fields say whether a successful backend run actually proved a universal law.

The program

twoFloatsDistinct reads Random.float twice and compares the two results. Its law supplies distinctStub, a deterministic oracle. The value it returns depends on the call index of Random.float.

fn distinctStub(path: BranchPath, n: Int) -> Float
    ? "Stub returning n+1 as a Float — different value per call counter."
    Float.fromInt(n) + 1.0

fn twoFloatsDistinct() -> Bool
    ? "Sample two random floats; return whether they were different."
    ! [Random.float]
    a = Random.float()
    b = Random.float()
    a != b

verify twoFloatsDistinct law alwaysDistinct
    given rnd: Random.float = [distinctStub]
    twoFloatsDistinct() holds

The final holds says the Boolean result must be true. The given line supplies the declared world that ordinary verification uses. It does not restrict the universal oracle type.

Recorded results

Current outcomes for examples/formal/randomness_paradox.av. Backend success and proof-gate status are reported separately.

Declared verification

PASS

aver verify examples/formal/randomness_paradox.av

verify distinctStub         2/2
verify twoFloatsDistinct  1/1

Summary: 3/3 cases passed

Hostile verification

FAIL

aver verify --hostile examples/formal/randomness_paradox.av

verify distinctStub         2/2
verify twoFloatsDistinct  1/4
  1/1 declared, 0/3 hostile

Summary: 3/6 passed | 3 failed

Lean export

BUILD PASS

aver proof examples/formal/randomness_paradox.av --verify-mode auto --check

build:      passed
sorries:    0
universal:  no

Declared verification

Plain aver verify runs the law with the stub named in given. The first call gets counter 0 and returns 1.0. The second gets counter 1 and returns 2.0. The two differ, so the law adds one passing case. With the two checks for distinctStub, the file reports 3/3.

Hostile profiles

aver verify --hostile keeps the declared case and also runs the law with the three registered Random.float profiles: midrange, always_zero and always_one. Each profile returns the same value on both calls, so all three hostile cases fail and the whole file reports 3/6.

If distinct oracle results are meant as a precondition, the law can say so with when. Hostile mode then skips profiles that fall outside that assumption. If you only want to record behavior under one concrete stub, keep the check sample-shaped and do not claim it holds universally.

Proof export

Oracle lifting turns the effect into an explicit proof parameter, addressed by BranchPath and that operation's own call index. A universal version of this law would have to show that twoFloatsDistinct returns true for every admissible Random.float oracle. Any constant oracle is a counterexample.

Lean

The generated Lean project builds with zero sorries. The exporter keeps the checked-domain evidence it has but does not count this law as universal, so the gate reports universal: no. A clean build confirms the emitted declarations. The universal field says whether every law in the export got a universal theorem checked by the kernel.

Run the checks

git clone https://github.com/jasisz/aver
cd aver
cargo install --path .

aver verify examples/formal/randomness_paradox.av
aver verify --hostile examples/formal/randomness_paradox.av

aver proof examples/formal/randomness_paradox.av \
    --verify-mode auto --check -o out/randomness-lean

Lean checking requires Elan and the pinned Lean toolchain. The Oracle guide covers classified effects, hostile profiles, trace laws and proof lifting.