Skip to content

fix: circuit simplify and extens must not prove false judgements - #1203

Merged
strub merged 1 commit into
mainfrom
fix/circuit-simplify-extens
Oct 9, 2026
Merged

strub merged 1 commit into
mainfrom
fix/circuit-simplify-extens

Conversation

@strub

@strub strub commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Two circuit tactics proved false hoare judgements.

circuit simplify replaced each bitstring / array equality of the
postcondition by true when the circuits prove it valid, and by
false otherwise. An equality that is not valid may still hold in
some states, so this is unsound under a negation. With

proc f(x : W8) = { return x; }

it proved

hoare[M.f : true ==> !(res = of_int 0)]

An equality that the circuits do not prove valid is now kept as is.

extens [x] replaces x by each of its values in the program, the
precondition and the postcondition, but the postcondition reads x in
the final memory. With

proc f(x : W8) = { x <- of_int 0; return x; }

it proved

hoare[M.f : x = of_int 1 ==> res = of_int 1]

It now fails when the program writes x.

Fixes #1201.
Fixes #1202.

Origin: e07ffa0 (2026-06-24), first released in r2026.07.

Test: tests/circuits/circuit_soundness.ec (the previous build accepts
the two fail lines). tests/circuits, unit (125 files) and stdlib
(128) pass.

Two circuit tactics proved false hoare judgements.

`circuit simplify` replaced each bitstring / array equality of the
postcondition by `true` when the circuits prove it valid, and by
`false` otherwise. An equality that is not valid may still hold in
some states, so this is unsound under a negation. With

    proc f(x : W8) = { return x; }

it proved

    hoare[M.f : true ==> !(res = of_int 0)]

An equality that the circuits do not prove valid is now kept as is.

`extens [x]` replaces `x` by each of its values in the program, the
precondition and the postcondition, but the postcondition reads `x` in
the final memory. With

    proc f(x : W8) = { x <- of_int 0; return x; }

it proved

    hoare[M.f : x = of_int 1 ==> res = of_int 1]

It now fails when the program writes `x`.

Fixes #1201.
Fixes #1202.

Origin: e07ffa0 (2026-06-24), first released in r2026.07.

Test: tests/circuits/circuit_soundness.ec (the previous build accepts
the two `fail` lines). tests/circuits, unit (125 files) and stdlib
(128) pass.
@strub
strub force-pushed the fix/circuit-simplify-extens branch from 7016531 to ae557db Compare October 9, 2026 15:26
@strub strub self-assigned this Oct 9, 2026
@strub strub added the yolo-pr Don't bother reviewing, I will merge label Oct 9, 2026
@strub
strub merged commit e7eff05 into main Oct 9, 2026
17 checks passed
@strub
strub deleted the fix/circuit-simplify-extens branch October 9, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

yolo-pr Don't bother reviewing, I will merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extens [x] does not check that the program leaves x unwritten circuit simplify replaces an unproved equality by false

1 participant