You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Math {
const WAD: nat:= 1_000_000_000_000_000_000 // 18 zerosconst RAY: nat:= 1_000_000_000_000_000_000_000_000_000 // 27const PERCENT: nat:= 1_000_000_000_000_000_000 // 18 zerosconst YEAR: nat:= 30758400 // year in secondsfunctionMax(x: nat, y: nat) : nat {
if x > y then x
else y
}
functionMin(x:nat, y: nat) : nat {
if x < y then x
else y
}
/// Returns `ceil(x * y / d)`. [arredonda para cima]/// Reverts if `x * y` overflows, or `d` is zero.// z := add(iszero(iszero(mod(mul(x, y), d))), div(mul(x, y), d))functionMulDivUp(x:nat, y:nat, z:nat) : (r: nat)
requires z > 0
ensures r == (x * y + z - 1) / z{
(x * y + z - 1) / z
}
/// @dev Returns `floor(x * y / d)`. [arredonda para baixo]/// Reverts if `x * y` overflows, or `d` is zero.functionMulDivDown(x:nat, y:nat, z:nat) : (r: nat)
requires z > 0
ensures r == (x * y) / z {
(x * y) / z
}
functionToWad(x:nat) : nat {
x * WAD
}
//rounds to zero if x*y < WAD / 2functionWmul(x: nat, y: nat) : nat {
var m: nat:= x * y;
var w: nat:= WAD / 2;
(m + w)/WAD
}
//rounds to zero if x*y < WAD / 2functionWdiv(x: nat, y:nat) : (r: nat)
requires y != 0 {
var m: nat:= x * WAD;
var w: nat:= y / 2;
var z: nat:= m + w;
z / y
}
}
// ------- TESTSimportopened Math
methodTestDiv1() { // ----> it freezesassertMulDivUp(7, 3, 4) == 6;
assertMulDivUp(3, 5, 4) == 4;
assertMulDivUp(4, 5, 4) == 5;
assertMulDivUp(10, 5, 2) == 25; // to fix you have to move this to TestDiv2()
}
methodTestDiv2() {
assertMulDivUp(15, 1, 2) == 8;
}
methodTestDiv3() {
assertMulDivDown(7, 3, 4) == 5;
assertMulDivDown(3, 5, 4) == 3;
assertMulDivDown(4, 5, 4) == 5;
}
Command to run and resulting output
dafny verify ./src/math.dfy
What happened?
TestDiv1() method freezes on verifier
What type of operating system are you experiencing the problem on?
Linux
The text was updated successfully, but these errors were encountered:
henry-hz
added
the
kind: bug
Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label
label
Sep 3, 2024
Dafny version
4.7.0+769d1572fdd799c7bf76b78a3bc9cb94d18aac59
Code to produce this issue
Command to run and resulting output
What happened?
TestDiv1() method freezes on verifier
What type of operating system are you experiencing the problem on?
Linux
The text was updated successfully, but these errors were encountered: