Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various cleanups #111

Merged
merged 6 commits into from
Nov 6, 2023
Merged

Various cleanups #111

merged 6 commits into from
Nov 6, 2023

Conversation

fzaiser
Copy link
Collaborator

@fzaiser fzaiser commented Nov 3, 2023

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@@ -52,6 +52,16 @@ module Independence {
lemma {:axiom} ReturnIsIndep<T>(x: T)
ensures IsIndep(Monad.Return(x))

lemma MapIsIndep<A, B(!new)>(f: Monad.Hurd<A>, g: A -> B)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice, thank you.

// TODO: While(condition, body)(init) would be cleaner
opaque ghost function While<A>(condition: A -> bool, body: A -> Monad.Hurd<A>, init: A): (f: Monad.Hurd<A>)
ensures forall s: Rand.Bitstream :: !condition(init) ==> f(s) == Monad.Return(init)(s)
opaque ghost function While<A(!new)>(condition: A -> bool, body: A -> Monad.Hurd<A>): (loop: A -> Monad.Hurd<A>)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't quite see what has caused this change yet. How does it make our life easier if we use this curried version of the current While?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's easier to view a while loop as transforming a value a: A. If you look at the diff, it was used as a function (init: A) => While(condition, body, init) in many places in the file. The curried version can just be written as While(condition, body).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But I'm not super attached to that change, so if you don't like it, I can undo it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, makes sense!

@@ -37,7 +37,7 @@ module DiscreteLaplace.Implementation {
}
var x := u + scale.numer * v;
y := x / scale.denom;
b := BernoulliSample(Rationals.Rational(1, 2));
b := CoinSample();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch.

@stefan-aws stefan-aws merged commit 9568c0e into main Nov 6, 2023
7 checks passed
@fzaiser fzaiser deleted the cleanup branch November 6, 2023 17:44
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.

2 participants