Repository navigation
Conversation
strub
added this pull request to stack #1156
October 6, 2026 22:10
PR of the program-logic reorganization stack (see
src/phl/REFACTORING.md). It migrates the `rnd` / `rndsem` tactic
class; the trusted rnd rules no longer seq implicitly where `seq` can
do it:
- rules/{hoare,ehoare}/ec<Logic>Rnd.ml: an axiom on the single sampling
`x <$ d`, whose precondition is its weakest precondition (checked up
to alpha-conversion by the rule and its checker). The surface `rnd`
is derived: the migrated `seq` rule before the sampling, with that
weakest precondition as intermediate assertion, then the axiom.
- rules/equiv/ecEquivRnd.ml: the same for equiv, with two axioms: the
two-sided one, recording the bijection instantiated at the sampled
types (well-typedness re-checked), and the one-sided one, on
`x <$ d ~ skip`. The surface forms (seq + axiom, then the existing
simplification of the remaining relation via conseq, and `rnd : k k'`
through rndsem) are derived.
- rules/bdhoare/ecBdHoareRnd.ml: kept over `c; x <$ d`, documented as
such: its premises are judgements on `c` (a hoare one for `<=`)
that the bdhoare seq rule cannot reproduce, and it relies on `c` not
writing the bound when it does not generalize it. The node records
the event and bounds instantiated at the sampled type; the derived
t_bdhoare_rnd_full tries to close the non-negativity premise.
- rules/{hoare,bdhoare,equiv}/ec<Logic>RndSem.ml, with the shared
semantic sampling in rules/ecPlRndSem.ml: rndsem is a trusted
program transformation rewriting the suffix `c[k..]` in place; it
keeps the prefix, which seq cannot express without an intermediate
assertion.
- EcPhlRnd is reduced to the logic-agnostic dispatchers and the legacy
adapters (interface unchanged); the no-op FApi.t_low* wrappers are
dropped.
Behaviour is preserved: on the new test, the transcripts of the
reference and new builds (all goals printed after each command,
including every error message) are identical.
A new test, tests/rnd.ec, exercises every logic and form, including
the bdhoare non-negativity premise and the error paths. The stdlib and
the unit tests, and the 24 examples using rnd / rndsem, pass under
EC_RECHECK=1 with no RecheckFailure; each of
the eight checkers, when deliberately broken, is caught only under
EC_RECHECK, on the new test and, where the rule is used there, on the
stdlib (files: hoare-rnd 15, bdhoare-rnd 21, equiv-rnd 25,
equiv-rnd-onesided 13, equiv-rndsem 4; ehoare-rnd, hoare-rndsem and
bdhoare-rndsem are not used by the stdlib).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR of the program-logic reorganization stack (see
src/phl/REFACTORING.md). It migrates the
rnd/rndsemtacticclass; the trusted rnd rules no longer seq implicitly where
seqcando it:
x <$ d, whose precondition is its weakest precondition (checked upto alpha-conversion by the rule and its checker). The surface
rndis derived: the migrated
seqrule before the sampling, with thatweakest precondition as intermediate assertion, then the axiom.
two-sided one, recording the bijection instantiated at the sampled
types (well-typedness re-checked), and the one-sided one, on
x <$ d ~ skip. The surface forms (seq + axiom, then the existingsimplification of the remaining relation via conseq, and
rnd : k k'through rndsem) are derived.
c; x <$ d, documented assuch: its premises are judgements on
c(a hoare one for<=)that the bdhoare seq rule cannot reproduce, and it relies on
cnotwriting the bound when it does not generalize it. The node records
the event and bounds instantiated at the sampled type; the derived
t_bdhoare_rnd_full tries to close the non-negativity premise.
semantic sampling in rules/ecPlRndSem.ml: rndsem is a trusted
program transformation rewriting the suffix
c[k..]in place; itkeeps the prefix, which seq cannot express without an intermediate
assertion.
adapters (interface unchanged); the no-op FApi.t_low* wrappers are
dropped.
Behaviour is preserved: on the new test, the transcripts of the
reference and new builds (all goals printed after each command,
including every error message) are identical.
A new test, tests/rnd.ec, exercises every logic and form, including
the bdhoare non-negativity premise and the error paths. The stdlib and
the unit tests, and the 24 examples using rnd / rndsem, pass under
EC_RECHECK=1 with no RecheckFailure; each of
the eight checkers, when deliberately broken, is caught only under
EC_RECHECK, on the new test and, where the rule is used there, on the
stdlib (files: hoare-rnd 15, bdhoare-rnd 21, equiv-rnd 25,
equiv-rnd-onesided 13, equiv-rndsem 4; ehoare-rnd, hoare-rndsem and
bdhoare-rndsem are not used by the stdlib).