Skip to content

[theories/modules] law of total probability#968

Open
alleystoughton wants to merge 3 commits intomainfrom
total-probability
Open

[theories/modules] law of total probability#968
alleystoughton wants to merge 3 commits intomainfrom
total-probability

Conversation

@alleystoughton
Copy link
Copy Markdown
Member

Add module-based law of total probability for distributions with finite support.
Put it in theories/modules as it uses event partitioning.

@alleystoughton alleystoughton requested a review from fdupress April 6, 2026 15:46
@alleystoughton
Copy link
Copy Markdown
Member Author

I don't understand why the EC library checking failed.

Add module-based law of total probability for lossless distributions
with finite support.
@alleystoughton
Copy link
Copy Markdown
Member Author

I made the distribution a parameter to the procedure of the Rand module, instead of a theory parameter, and force pushed.

@alleystoughton
Copy link
Copy Markdown
Member Author

I don't understand why the EC library checking failed.

I see, it's because I checked it with Alt-Ergo. Will fix this.

@alleystoughton
Copy link
Copy Markdown
Member Author

I don't understand why the EC library checking failed.

It checked for me with Z3 (4.15.4) and CVC5 (1.3.2). Fixed to check with just Z3.

@fdupress
Copy link
Copy Markdown
Member

fdupress commented Apr 6, 2026

Using make check before committing or pushing to the EC repo (but after moving your file to the EC working directory) should make use of the easycrypt.project we serve, which should ensure that the CI reproduces successes (barring regressions in SMT solvers, which are mostly rare now that we do not use Alt-Ergo).

I'll do a proper review + local edits when it's not a bank holiday, but wanted to guide your workflow to avoid you having to figure out why CI is failing in the future!

hoare; call (_ : true); auto; smt().
qed.

lemma total_prob' (dt' : t distr) (supp : t list) (i' : input) &m :
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be easier to use if supp was computed as to_seq (support dt'), requiring is_finite (support dt'), instead of taking it as an argument.

I suppose the existing variant is simpler if you already have a supp that might be distinct from to_seq (support dt'). Maybe it makes sense to have both variants? For the existing variant it might be better to move supp to the front of the argument list since this cannot be inferred from the LHS in rewrites. If the intention is to rewrite in the other direction where supp can be inferred it might make sense to swap the sides of the equality.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I'd missed that there was this operator.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That worked out nicely, at least as easy to use.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants