dafny-lang / dafny-vmc Goto Github PK
View Code? Open in Web Editor NEWVMC: a Library for Verified Monte Carlo Algorithms
License: MIT License
VMC: a Library for Verified Monte Carlo Algorithms
License: MIT License
I believe the current definition of UniformPowerOfTwo.Model.Sample
is suboptimal and makes the proofs around it more painful than they'd have to be. Currently the correctness predicate has the precondition (n == 0 && k == 0) || (k != 0 && Helper.Power(2, k - 1) <= n < Helper.Power(2, k))
, which is annoying because of the case split and (I believe) because of this we have the weird Helper.Log2
which computes something slightly different from the actual log2.
Instead I think it would be better if Sample
were defined as follows:
function Sample(n: nat): Monad.Hurd<nat>
requires n >= 1
{
if n == 1 then Monad.Return(0) else Monad.Bind(Sample(n/2), UnifStep)
}
Then the correctness predicate would have the precondition Helper.Power(2, k) <= n < Helper.Power(2, k + 1)
and the result range of return values m would be 0 <= m < Helper.Power(2, k)
. Then k
would be the actual logarithm of base 2 rounded down. I think this would be much cleaner because it avoids the extra case split and the - 1
in the exponent, which could a priori lead to negative numbers and has to be proved impossible.
I noticed that Java uses SecureRandom
, but C# just Random
. We should look into whether Random
is actually secure enough in C#.
e.g. https://github.com/dafny-lang/Dafny-VMC/blob/main/src/DafnyVMCTrait.dfy should have a header stating that it is machine generated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.