-
Notifications
You must be signed in to change notification settings - Fork 2
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
Various cleanups #111
Conversation
@@ -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) |
There was a problem hiding this comment.
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>) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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)
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.