Skip to content

refactor(pl): transitivity as recheckable per-logic rules - #1161

Open
strub wants to merge 1 commit into
pl/symfrom
pl/trans
Open

strub wants to merge 1 commit into
pl/symfrom
pl/trans

Conversation

@strub

@strub strub commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

PR of the program-logic reorganization stack (see
src/phl/REFACTORING.md). It migrates the transitivity / replace
tactic class:

  • rules/equiv/ecEquivTrans.ml: the two trusted transitivity rules,
    for statements (t_equivS_trans) and procedures (t_equivF_trans),
    documented as inference rules in the .mli: from
    c1 ~ c2 : P1 ==> Q1, c2 ~ c3 : P2 ==> Q2 and the two composition
    side conditions (P => exists intermediate values, P1 /\ P2;
    Q1 => Q2 => Q), conclude c1 ~ c3 : P ==> Q. Each emits a node
    recording the typed intermediate program (memory type and statement,
    or procedure) and the four relations, with a registered checker; the
    builder takes the goal's hyps (it recomputes the variables of the
    intermediate memory and the procedures' memories) and re-checks that
    the relations are stated over the goal's memories.
  • transitivity* / replace* (t_equivS_trans_eq, also used by
    outline and rewrite equiv) is a derived form: the rule with
    equality relations, its two side conditions closed on the spot.
  • replace involves no position: the pattern only names parts of the
    current program for reuse in the new one, which replaces the whole
    side, so there is no implicit seq-ing or framing to remove.
  • EcPhlTrans is reduced to the dispatcher (matching on the goal kind)
    and positional adapters (interface unchanged); the no-op
    FApi.t_low3 wrappers are dropped.

Behaviour is preserved, error messages and their order included.

A new test, tests/transitivity.ec, exercises the statement (both
sides) and procedure forms, transitivity*, replace / replace*
and the error paths; it passes with and without this change. The
stdlib and the unit tests pass under EC_RECHECK=1 with no
RecheckFailure; each checker, when deliberately broken, is caught only
under EC_RECHECK (stdlib: equivS-trans 13 files, equivF-trans 9).

@strub
strub added this pull request to stack #1156 October 6, 2026 21:39
@strub strub added the stacked Intermediate PR of a stack: CI skipped unless it targets main label Oct 7, 2026
@strub
strub force-pushed the pl/trans branch 2 times, most recently from 3ba63ba to 9ad1a5d Compare October 9, 2026 07:25
PR of the program-logic reorganization stack (see
src/phl/REFACTORING.md). It migrates the `transitivity` / `replace`
tactic class:

- rules/equiv/ecEquivTrans.ml: the two trusted transitivity rules,
  for statements (t_equivS_trans) and procedures (t_equivF_trans),
  documented as inference rules in the .mli: from
  `c1 ~ c2 : P1 ==> Q1`, `c2 ~ c3 : P2 ==> Q2` and the two composition
  side conditions (`P => exists intermediate values, P1 /\ P2`;
  `Q1 => Q2 => Q`), conclude `c1 ~ c3 : P ==> Q`. Each emits a node
  recording the typed intermediate program (memory type and statement,
  or procedure) and the four relations, with a registered checker; the
  builder takes the goal's hyps (it recomputes the variables of the
  intermediate memory and the procedures' memories) and re-checks that
  the relations are stated over the goal's memories.
- `transitivity*` / `replace*` (t_equivS_trans_eq, also used by
  `outline` and `rewrite equiv`) is a derived form: the rule with
  equality relations, its two side conditions closed on the spot.
- `replace` involves no position: the pattern only names parts of the
  current program for reuse in the new one, which replaces the whole
  side, so there is no implicit seq-ing or framing to remove.
- EcPhlTrans is reduced to the dispatcher (matching on the goal kind)
  and positional adapters (interface unchanged); the no-op
  FApi.t_low3 wrappers are dropped.

Behaviour is preserved, error messages and their order included.

A new test, tests/transitivity.ec, exercises the statement (both
sides) and procedure forms, `transitivity*`, `replace` / `replace*`
and the error paths; it passes with and without this change. The
stdlib and the unit tests pass under EC_RECHECK=1 with no
RecheckFailure; each checker, when deliberately broken, is caught only
under EC_RECHECK (stdlib: equivS-trans 13 files, equivF-trans 9).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stacked Intermediate PR of a stack: CI skipped unless it targets main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant