Skip to content

Simplify rewriting of events in Pr expressions #846

Closed

Description

@jjanku

Before #789 (v2025.10 and earlier), it was possible to easily rewrite events, for example, as follows:

require import AllCore.

module M = {
  proc run() : int = {
    return 1;
  }
}.

lemma l0 &m : Pr[M.run() @ &m : 0 <= res < 0] = 0%r.
proof.
rewrite (: forall x, (0 <= x < 0) = false).
+ smt().
by rewrite Pr[mu_false].
qed.

After #789, one has to, in general, use a combination of rewrite and byequiv (with conseq):

lemma l1 &m : Pr[M.run() @ &m : 0 <= res < 0] = 0%r.
proof.
rewrite (: Pr[M.run() @ &m: 0 <= res < 0] = Pr[M.run() @ &m: false]).
+ byequiv (_ : _ ==> true) => //.
  + sim.
  smt().
by rewrite Pr[mu_false].
qed.

See the changes to theories/modules/EventPartitioning.ec made by #789 for some more real-world examples.

It would be great if such rewriting of events was less verbose.

Also see the Zulip thread #EasyCrypt: dev > ✔ Cannot rewrite inside Pr in v2025.11 where I first reported this issue and where @fdupress suggested how this could be addressed.

Activity

  1. strub commented on Jan 12, 2026

    @strub
    Member

    #789 fixes a bug where rewrite was doing non-capture free rewritings and could leak to ill-formed formulas. The proper fix would be to allow rewrites below binders.

  2. strub commented on Jan 12, 2026

    @strub
    Member

    See #864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions