Skip to content

Commit

Permalink
Merge branch 'main' into fabian
Browse files Browse the repository at this point in the history
  • Loading branch information
jtristan authored Sep 29, 2023
2 parents 434c932 + beca2ef commit d6a358b
Show file tree
Hide file tree
Showing 36 changed files with 172 additions and 178 deletions.
6 changes: 3 additions & 3 deletions src/Distributions/Base/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../ProbabilisticProgramming/RandomNumberGenerator.dfy"
include "Model.dfy"
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Base/Model.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../ProbabilisticProgramming/RandomNumberGenerator.dfy"
include "../../ProbabilisticProgramming/Monad.dfy"
Expand Down
8 changes: 4 additions & 4 deletions src/Distributions/Bernoulli/Correctness.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../Math/MeasureTheory.dfy"
include "../../ProbabilisticProgramming/RandomNumberGenerator.dfy"
Expand All @@ -13,7 +13,7 @@ module BernoulliCorrectness {
import RandomNumberGenerator
import Independence
import BernoulliModel

/*******
Lemmas
*******/
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Bernoulli/Implementation.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../Math/MeasureTheory.dfy"
include "Interface.dfy"
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Bernoulli/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../Base/Interface.dfy"
include "Model.dfy"
Expand Down
16 changes: 5 additions & 11 deletions src/Distributions/Bernoulli/Model.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../Math/MeasureTheory.dfy"
include "../../ProbabilisticProgramming/Monad.dfy"
Expand All @@ -16,15 +16,9 @@ module BernoulliModel {
var f :=
(b: bool) =>
if b then
if p <= 0.5 then
Monad.Return(false)
else
ProbBernoulli(2.0 * p - 1.0)
(if p <= 0.5 then Monad.Return(false) else ProbBernoulli(2.0 * p - 1.0))
else
if p <= 0.5 then
ProbBernoulli(2.0 * p)
else
Monad.Return(true);
(if p <= 0.5 then ProbBernoulli(2.0 * p) else Monad.Return(true));
Monad.Bind(Monad.Deconstruct, f)
}
}
6 changes: 3 additions & 3 deletions src/Distributions/BernoulliExpNeg/Implementation.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../Bernoulli/Interface.dfy"
include "Interface.dfy"
Expand Down
8 changes: 4 additions & 4 deletions src/Distributions/BernoulliExpNeg/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../Bernoulli/Interface.dfy"

module BernoulliExpNegInterface {
import BernoulliInterface

trait {:termination false} IBernoulliExpNeg extends BernoulliInterface.IBernoulli {

method BernoulliExpNeg(gamma: real) returns (c: bool)
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/BernoulliRational/Correctness.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../Math/MeasureTheory.dfy"
include "../../Math/Helper.dfy"
Expand Down
8 changes: 4 additions & 4 deletions src/Distributions/BernoulliRational/Implementation.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "Interface.dfy"
include "Model.dfy"
Expand All @@ -12,7 +12,7 @@ module BernoulliRationalImplementation {

trait {:termination false} TBernoulliRational extends BernoulliRationalInterface.IBernoulliRational {

method BernoulliRational(m: nat, n: nat) returns (c: bool)
method BernoulliRational(m: nat, n: nat) returns (c: bool)
modifies this
decreases *
requires n != 0
Expand Down
8 changes: 4 additions & 4 deletions src/Distributions/BernoulliRational/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../Uniform/Interface.dfy"
include "Model.dfy"

module BernoulliRationalInterface {
import UniformInterface
import BernoulliRationalModel

trait {:termination false} IBernoulliRational extends UniformInterface.IUniform {

method BernoulliRational(m: nat, n: nat) returns (c: bool)
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/BernoulliRational/Model.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../Uniform/Model.dfy"
include "../../ProbabilisticProgramming/Monad.dfy"
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/DiscreteGaussian/Implementation.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "Interface.dfy"

Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/DiscreteGaussian/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../BernoulliExpNeg/Interface.dfy"
include "../DiscreteLaplace/Interface.dfy"
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/DiscreteLaplace/Implementation.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "Interface.dfy"

Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/DiscreteLaplace/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../Bernoulli/Interface.dfy"
include "../Uniform/Interface.dfy"
Expand Down
8 changes: 4 additions & 4 deletions src/Distributions/Geometric/Correctness.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../Math/Helper.dfy"
include "../../ProbabilisticProgramming/Monad.dfy"
Expand All @@ -20,7 +20,7 @@ module GeometricCorrectness {
/*******
Lemmas
*******/

// Equation (4.19)
lemma {:axiom} ProbGeometricIsIndepFn()
ensures Independence.IsIndepFn(GeometricModel.ProbGeometric())
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Geometric/Implementation.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../ProbabilisticProgramming/Monad.dfy"
include "Interface.dfy"
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Geometric/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../ProbabilisticProgramming/Monad.dfy"
include "../Base/Interface.dfy"
Expand Down
8 changes: 4 additions & 4 deletions src/Distributions/Geometric/Model.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../ProbabilisticProgramming/Monad.dfy"
include "../../ProbabilisticProgramming/WhileAndUntil.dfy"
Expand All @@ -19,7 +19,7 @@ module GeometricModel {
Monad.Bind(g, f)
}

// Equation (4.17)
// Equation (4.17)
function ProbGeometricIter(t: (bool, int)): (f: Monad.Hurd<(bool, int)>)
ensures forall s :: f(s) == ((Monad.Head(s), t.1 + 1), Monad.Tail(s))
{
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Uniform/Implementation.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../UniformPowerOfTwo/Interface.dfy"
include "../UniformPowerOfTwo/Implementation.dfy"
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Uniform/Interface.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../Base/Interface.dfy"
include "../UniformPowerOfTwo/Interface.dfy"
Expand Down
6 changes: 3 additions & 3 deletions src/Distributions/Uniform/Model.dfy
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

include "../../ProbabilisticProgramming/RandomNumberGenerator.dfy"
include "../../ProbabilisticProgramming/Monad.dfy"
Expand Down
Loading

0 comments on commit d6a358b

Please sign in to comment.