test_ID
stringlengths
3
3
test_file
stringlengths
14
119
ground_truth
stringlengths
70
28.7k
hints_removed
stringlengths
58
28.7k
700
ironsync-osdi2023_tmp_tmpx80antoe_lib_Math_div_def.dfy
//- Specs/implements mathematical div and mod, not the C version. //- This may produce "surprising" results for negative values //- For example, -3 div 5 is -1 and -3 mod 5 is 2. //- Note this is consistent: -3 * -1 + 2 == 5 module Math__div_def_i { /* function mod(x:int, m:int) : int requires m > 0; decreases...
//- Specs/implements mathematical div and mod, not the C version. //- This may produce "surprising" results for negative values //- For example, -3 div 5 is -1 and -3 mod 5 is 2. //- Note this is consistent: -3 * -1 + 2 == 5 module Math__div_def_i { /* function mod(x:int, m:int) : int requires m > 0; { if x < ...
701
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_arrays.dfy
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 method returnANullArray() returns (a: array?<uint32>) ensures a == null { a := null; } method returnANonNullArray() returns (a: array?<uint32>) ensures a != n...
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 method returnANullArray() returns (a: array?<uint32>) ensures a == null { a := null; } method returnANonNullArray() returns (a: array?<uint32>) ensures a != n...
702
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_maps.dfy
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 method Test(name:string, b:bool) requires b { if b { print name, ": This is expected\n"; } else { print name, ": This is *** UNEXPECTED *** !!!!\n"; ...
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 method Test(name:string, b:bool) requires b { if b { print name, ": This is expected\n"; } else { print name, ": This is *** UNEXPECTED *** !!!!\n"; ...
703
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_c++_sets.dfy
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 datatype Example0 = Example0(u:uint32, b:bool) method Test0(e0:Example0) { var s := { e0 }; } datatype Example1 = Ex1a(u:uint32) | Ex1b(b:bool) method Test1(t0:...
// RUN: %dafny /compile:3 /spillTargetCode:2 /compileTarget:cpp "%s" > "%t" // RUN: %diff "%s.expect" "%t" newtype uint32 = i:int | 0 <= i < 0x100000000 datatype Example0 = Example0(u:uint32, b:bool) method Test0(e0:Example0) { var s := { e0 }; } datatype Example1 = Ex1a(u:uint32) | Ex1b(b:bool) method Test1(t0:...
704
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-1158.dfy
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %diff "%s.expect" "%t" type Id(==) function F(s: set<Id>): int lemma Test(x: Id) { var X := {x}; var a := map i | i <= X :: F(i); var b := map[{} := F({}), X := F(X)]; assert a.Keys == b.Keys by { // spurious error reported here forall i ensures i in ...
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %diff "%s.expect" "%t" type Id(==) function F(s: set<Id>): int lemma Test(x: Id) { var X := {x}; var a := map i | i <= X :: F(i); var b := map[{} := F({}), X := F(X)]; forall i ensures i in a.Keys <==> i in b.Keys { calc { i in a.Keys; ...
705
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-283.dfy
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:cs "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:js "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:go "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:java "%s" >> "%t" // RUN: %dif...
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:cs "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:js "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:go "%s" >> "%t" // RUN: %dafny /noVerify /compile:4 /compileTarget:java "%s" >> "%t" // RUN: %dif...
706
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-506.dfy
// RUN: %dafny /compile:4 /compileTarget:cs "%s" > "%t" // RUN: %dafny /compile:4 /compileTarget:js "%s" >> "%t" // RUN: %dafny /compile:4 /compileTarget:go "%s" >> "%t" // RUN: %dafny /compile:4 /compileTarget:java "%s" >> "%t" // RUN: %diff "%s.expect" "%t" method Main() { var a := new int[10]; var index := 6; ...
// RUN: %dafny /compile:4 /compileTarget:cs "%s" > "%t" // RUN: %dafny /compile:4 /compileTarget:js "%s" >> "%t" // RUN: %dafny /compile:4 /compileTarget:go "%s" >> "%t" // RUN: %dafny /compile:4 /compileTarget:java "%s" >> "%t" // RUN: %diff "%s.expect" "%t" method Main() { var a := new int[10]; var index := 6; ...
707
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_Test_git-issues_git-issue-975.dfy
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %diff "%s.expect" "%t" function f():nat ensures f() == 0 { // no problem for methods var x := 0; // no problem without this assert true by {} 0 }
// RUN: %dafny /compile:0 "%s" > "%t" // RUN: %diff "%s.expect" "%t" function f():nat ensures f() == 0 { // no problem for methods var x := 0; // no problem without this 0 }
708
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old.dfy
class A { var value: int method m(i: int) requires i == 6 requires value == 42 modifies this { var j: int := 17; value := 43; label L: j := 18; value := 44; label M: assert old(i) == 6; // i is local, but can't be changed anyway assert old(j) == 18; // j is local and ...
class A { var value: int method m(i: int) requires i == 6 requires value == 42 modifies this { var j: int := 17; value := 43; label L: j := 18; value := 44; label M: // value is this.value; 'this' is the same // same reference in current and pre state but the // v...
709
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old2.dfy
class A { var value: int constructor () ensures value == 10 { value := 10; } } class B { var a: A constructor () { a := new A(); } method m() requires a.value == 11 modifies this, this.a { label L: a.value := 12; label M: a := new A(); // Line X label N...
class A { var value: int constructor () ensures value == 10 { value := 10; } } class B { var a: A constructor () { a := new A(); } method m() requires a.value == 11 modifies this, this.a { label L: a.value := 12; label M: a := new A(); // Line X label N...
710
ironsync-osdi2023_tmp_tmpx80antoe_linear-dafny_docs_DafnyRef_examples_Example-Old3.dfy
class A { var z1: array<nat> var z2: array<nat> method mm() requires z1.Length > 10 && z1[0] == 7 requires z2.Length > 10 && z2[0] == 17 modifies z2 { var a: array<nat> := z1; assert a[0] == 7; a := z2; assert a[0] == 17; assert old(a[0]) == 17; // a is local with value z2 z...
class A { var z1: array<nat> var z2: array<nat> method mm() requires z1.Length > 10 && z1[0] == 7 requires z2.Length > 10 && z2[0] == 17 modifies z2 { var a: array<nat> := z1; a := z2; z2[0] := 27; // z2; in pre-state z2[0] == 17 /...
711
laboratory_tmp_tmps8ws6mu2_dafny-tutorial_exercise12.dfy
method FindMax(a: array<int>) returns (i: int) // Annotate this method with pre- and postconditions // that ensure it behaves as described. requires 0 < a.Length ensures 0 <= i < a.Length ensures forall k: int :: 0 <= k < a.Length ==> a[k] <= a[i] { // Fill in the body that calculates the INDEX ...
method FindMax(a: array<int>) returns (i: int) // Annotate this method with pre- and postconditions // that ensure it behaves as described. requires 0 < a.Length ensures 0 <= i < a.Length ensures forall k: int :: 0 <= k < a.Length ==> a[k] <= a[i] { // Fill in the body that calculates the INDEX ...
712
laboratory_tmp_tmps8ws6mu2_dafny-tutorial_exercise9.dfy
function fib(n: nat): nat { if n == 0 then 0 else if n == 1 then 1 else fib(n - 1) + fib(n - 2) } method ComputeFib(n: nat) returns (b: nat) ensures b == fib(n) // Do not change this postcondition { // Change the method body to instead use c as described. // You will need to cha...
function fib(n: nat): nat { if n == 0 then 0 else if n == 1 then 1 else fib(n - 1) + fib(n - 2) } method ComputeFib(n: nat) returns (b: nat) ensures b == fib(n) // Do not change this postcondition { // Change the method body to instead use c as described. // You will need to cha...
713
lets-prove-blocking-queue_tmp_tmptd_aws1k_dafny_prod-cons.dfy
/** * A proof in Dafny of the non blocking property of a queue. * @author Franck Cassez. * * @note: based off Modelling Concurrency in Dafny, K.R.M. Leino * @link{http://leino.science/papers/krml260.pdf} */ module ProdCons { // A type for process id that supports equality (i.e. p == q is defined). t...
/** * A proof in Dafny of the non blocking property of a queue. * @author Franck Cassez. * * @note: based off Modelling Concurrency in Dafny, K.R.M. Leino * @link{http://leino.science/papers/krml260.pdf} */ module ProdCons { // A type for process id that supports equality (i.e. p == q is defined). t...
714
libraries_tmp_tmp9gegwhqj_examples_MutableMap_MutableMapDafny.dfy
/******************************************************************************* * Copyright by the contributors to the Dafny Project * SPDX-License-Identifier: MIT *******************************************************************************/ // RUN: %verify "%s" /** * Implements mutable maps in Dafny to g...
/******************************************************************************* * Copyright by the contributors to the Dafny Project * SPDX-License-Identifier: MIT *******************************************************************************/ // RUN: %verify "%s" /** * Implements mutable maps in Dafny to g...
715
llm-verified-eval_tmp_tmpd2deqn_i_dafny_0.dfy
function abs(x: real): real { if x < 0.0 then -x else x } method has_close_elements(numbers: seq<real>, threshold: real) returns (result: bool) ensures result <==> exists i, j :: 0 <= i < |numbers| && 0 <= j < |numbers| && i != j && abs(numbers[i] - numbers[j]) < threshold ensures res...
function abs(x: real): real { if x < 0.0 then -x else x } method has_close_elements(numbers: seq<real>, threshold: real) returns (result: bool) ensures result <==> exists i, j :: 0 <= i < |numbers| && 0 <= j < |numbers| && i != j && abs(numbers[i] - numbers[j]) < threshold ensures res...
716
llm-verified-eval_tmp_tmpd2deqn_i_dafny_160.dfy
function pow(base: int, exponent: int): int requires exponent >= 0 decreases exponent { if exponent == 0 then 1 else if exponent % 2 == 0 then pow(base * base, exponent / 2) else base * pow(base, exponent - 1) } method do_algebra(operators: seq<char>, operands: seq<int>) returns (result: int) requires oper...
function pow(base: int, exponent: int): int requires exponent >= 0 { if exponent == 0 then 1 else if exponent % 2 == 0 then pow(base * base, exponent / 2) else base * pow(base, exponent - 1) } method do_algebra(operators: seq<char>, operands: seq<int>) returns (result: int) requires operators != [] && operan...
717
llm-verified-eval_tmp_tmpd2deqn_i_dafny_161.dfy
function IsLetter(c: char): bool { (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') } function NoLetters(s: string, n: nat): bool requires n <= |s| { forall c :: 0 <= c < n ==> !IsLetter(s[c]) } function ToggleCase(c: char): char { if c >= 'a' && c <= 'z' then (c - 'a' + 'A') else if c >= 'A' && ...
function IsLetter(c: char): bool { (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') } function NoLetters(s: string, n: nat): bool requires n <= |s| { forall c :: 0 <= c < n ==> !IsLetter(s[c]) } function ToggleCase(c: char): char { if c >= 'a' && c <= 'z' then (c - 'a' + 'A') else if c >= 'A' && ...
718
llm-verified-eval_tmp_tmpd2deqn_i_dafny_3.dfy
function sum(s: seq<int>, n: nat): int requires n <= |s| { if |s| == 0 || n == 0 then 0 else s[0] + sum(s[1..], n-1) } lemma sum_plus(s: seq<int>, i: nat) requires i < |s| ensures sum(s, i) + s[i] == sum(s, i+1) { } method below_zero(ops: seq<int>) returns (result: bool) ensure...
function sum(s: seq<int>, n: nat): int requires n <= |s| { if |s| == 0 || n == 0 then 0 else s[0] + sum(s[1..], n-1) } lemma sum_plus(s: seq<int>, i: nat) requires i < |s| ensures sum(s, i) + s[i] == sum(s, i+1) { } method below_zero(ops: seq<int>) returns (result: bool) ensure...
719
llm-verified-eval_tmp_tmpd2deqn_i_dafny_5.dfy
method intersperse(numbers: seq<int>, delimiter: int) returns (interspersed: seq<int>) ensures |interspersed| == if |numbers| > 0 then 2 * |numbers| - 1 else 0 ensures forall i :: 0 <= i < |interspersed| ==> i % 2 == 0 ==> interspersed[i] == numbers[i / 2] ensures forall i :: 0 <= i < |inte...
method intersperse(numbers: seq<int>, delimiter: int) returns (interspersed: seq<int>) ensures |interspersed| == if |numbers| > 0 then 2 * |numbers| - 1 else 0 ensures forall i :: 0 <= i < |interspersed| ==> i % 2 == 0 ==> interspersed[i] == numbers[i / 2] ensures forall i :: 0 <= i < |inte...
720
llm-verified-eval_tmp_tmpd2deqn_i_dafny_9.dfy
function isMax(m: int, numbers: seq<int>): bool { m in numbers && forall i :: 0 <= i < |numbers| ==> numbers[i] <= m } method max(numbers: seq<int>) returns (result: int) requires numbers != [] ensures isMax(result, numbers) { result := numbers[0]; for i := 1 to |numbers| invariant isMax(result, n...
function isMax(m: int, numbers: seq<int>): bool { m in numbers && forall i :: 0 <= i < |numbers| ==> numbers[i] <= m } method max(numbers: seq<int>) returns (result: int) requires numbers != [] ensures isMax(result, numbers) { result := numbers[0]; for i := 1 to |numbers| { if numbers[i] >...
721
metodosFormais_tmp_tmp4q2kmya4_T1-MetodosFormais_examples_ex1.dfy
/* Buscar r = 0 enquanto(r<|a|){ se (a[r] == x) retorne r r = r+1 } retorne -1 */ method buscar(a:array<int>, x:int) returns (r:int) ensures r < 0 ==> forall i :: 0 <= i <a.Length ==> a[i] != x ensures 0 <= r < a.Length ==> a[r] == x { r := 0; while r < a.Length decreases a.Length - r invariant...
/* Buscar r = 0 enquanto(r<|a|){ se (a[r] == x) retorne r r = r+1 } retorne -1 */ method buscar(a:array<int>, x:int) returns (r:int) ensures r < 0 ==> forall i :: 0 <= i <a.Length ==> a[i] != x ensures 0 <= r < a.Length ==> a[r] == x { r := 0; while r < a.Length { if a[r] == x { ...
722
metodosFormais_tmp_tmp4q2kmya4_T1-MetodosFormais_examples_somatoriov2.dfy
function somaAteAberto(a:array<nat>, i:nat):nat requires i <= a.Length reads a { if i ==0 then 0 else a[i-1] + somaAteAberto(a,i-1) } method somatorio(a:array<nat>) returns (s:nat) ensures s == somaAteAberto(a, a.Length) { s := 0; for i:= 0 to a.Length invariant s == somaAteAberto(a,i) { ...
function somaAteAberto(a:array<nat>, i:nat):nat requires i <= a.Length reads a { if i ==0 then 0 else a[i-1] + somaAteAberto(a,i-1) } method somatorio(a:array<nat>) returns (s:nat) ensures s == somaAteAberto(a, a.Length) { s := 0; for i:= 0 to a.Length { s := s + a[i]; } }
723
nitwit_tmp_tmplm098gxz_nit.dfy
// Liam Wynn, 3/13/2021, CS 510p /* In this program, I'm hoping to define N's complement: a generalized form of 2's complement. I ran across this idea back in ECE 341, when I asked the professor about a crackpot theoretical "ternary machine". Looking into it, I came across a general form of 2's complement. ...
// Liam Wynn, 3/13/2021, CS 510p /* In this program, I'm hoping to define N's complement: a generalized form of 2's complement. I ran across this idea back in ECE 341, when I asked the professor about a crackpot theoretical "ternary machine". Looking into it, I came across a general form of 2's complement. ...
724
paxos_proof_tmp_tmpxpmiksmt_triggers.dfy
// predicate P(x:int) // predicate Q(x:int) lemma M(a: seq<int>, m: map<bool,int>) requires 2 <= |a| requires false in m && true in m { assume forall i {:trigger a[i]} :: 0 <= i < |a|-1 ==> a[i] <= a[i+1]; var x :| 0 <= x <= |a|-2; assert a[x] <= a[x+1]; }
// predicate P(x:int) // predicate Q(x:int) lemma M(a: seq<int>, m: map<bool,int>) requires 2 <= |a| requires false in m && true in m { assume forall i {:trigger a[i]} :: 0 <= i < |a|-1 ==> a[i] <= a[i+1]; var x :| 0 <= x <= |a|-2; }
725
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_ch01_fast_exp.dfy
function exp(b: nat, n: nat): nat { if n == 0 then 1 else b * exp(b, n-1) } lemma exp_sum(b: nat, n1: nat, n2: nat) ensures exp(b, n1 + n2) == exp(b, n1) * exp(b, n2) { if n1 == 0 { return; } exp_sum(b, n1-1, n2); } // this "auto" version of exp_sum is convenient when we want to let Z3 figure // out h...
function exp(b: nat, n: nat): nat { if n == 0 then 1 else b * exp(b, n-1) } lemma exp_sum(b: nat, n1: nat, n2: nat) ensures exp(b, n1 + n2) == exp(b, n1) * exp(b, n2) { if n1 == 0 { return; } exp_sum(b, n1-1, n2); } // this "auto" version of exp_sum is convenient when we want to let Z3 figure // out h...
726
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_ch03_nim_v3.dfy
// Nim version 3: fix the bug and demonstrate a behavior. // // In this version, we've fixed the bug by actually flipping whose turn it is in // each transition. datatype Player = P1 | P2 { function Other(): Player { if this == P1 then P2 else P1 } } datatype Variables = Variables(piles: seq<nat>, turn: Player...
// Nim version 3: fix the bug and demonstrate a behavior. // // In this version, we've fixed the bug by actually flipping whose turn it is in // each transition. datatype Player = P1 | P2 { function Other(): Player { if this == P1 then P2 else P1 } } datatype Variables = Variables(piles: seq<nat>, turn: Player...
727
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_ch04_inductive_chain.dfy
module Ex { // This simple example illustrates what the process of looking for an // inductive invariant might look like. datatype Variables = Variables(p1: bool, p2: bool, p3: bool, p4: bool) ghost predicate Init(v: Variables) { && !v.p1 && !v.p2 && !v.p3 && !v.p4 } // The state machine ...
module Ex { // This simple example illustrates what the process of looking for an // inductive invariant might look like. datatype Variables = Variables(p1: bool, p2: bool, p3: bool, p4: bool) ghost predicate Init(v: Variables) { && !v.p1 && !v.p2 && !v.p3 && !v.p4 } // The state machine ...
728
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_ch04_invariant_proof.dfy
/* These three declarations are _abstract_ - we declare a state machine, but * don't actually give a definition. Dafny will assume nothing about them, so our * proofs below will be true for an abitrary state machine. */ type Variables predicate Init(v: Variables) predicate Next(v: Variables, v': Variables) /* We'll...
/* These three declarations are _abstract_ - we declare a state machine, but * don't actually give a definition. Dafny will assume nothing about them, so our * proofs below will be true for an abitrary state machine. */ type Variables predicate Init(v: Variables) predicate Next(v: Variables, v': Variables) /* We'll...
729
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_ch04_leader_election.dfy
// We'll define "Between" to capture how the ring wraps around. // SOLUTION ghost predicate Between(start: nat, i: nat, end: nat) { if start < end then start < i < end else i < end || start < i } lemma BetweenTests() { assert Between(3, 4, 5); assert !Between(3, 2, 4); // when start >= end, behavior is a bi...
// We'll define "Between" to capture how the ring wraps around. // SOLUTION ghost predicate Between(start: nat, i: nat, end: nat) { if start < end then start < i < end else i < end || start < i } lemma BetweenTests() { // when start >= end, behavior is a bit tricker // before end // after start // not in ...
730
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_ch04_toy_consensus.dfy
// Ported from ivy/examples/ivy/toy_consensus.ivy. // Ivy only supports first-order logic, which is limited (perhaps in surprising // ways). In this model of consensus, we use some tricks to model quorums in // first-order logic without getting into the arithmetic of why sets of n/2+1 // nodes intersect. type Node(==...
// Ported from ivy/examples/ivy/toy_consensus.ivy. // Ivy only supports first-order logic, which is limited (perhaps in surprising // ways). In this model of consensus, we use some tricks to model quorums in // first-order logic without getting into the arithmetic of why sets of n/2+1 // nodes intersect. type Node(==...
731
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_ch06_refinement_proof.dfy
// Analogous to ch04/invariant_proof.dfy, we show what the conditions on a // refinement (an abstraction function, invariant, an initial condition, and an // inductive property) module Types { type Event(==, 0, !new) } import opened Types module Code { import opened Types type Variables(==, 0, !new) ghost pr...
// Analogous to ch04/invariant_proof.dfy, we show what the conditions on a // refinement (an abstraction function, invariant, an initial condition, and an // inductive property) module Types { type Event(==, 0, !new) } import opened Types module Code { import opened Types type Variables(==, 0, !new) ghost pr...
732
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_dafny-internals_02-triggers_triggers2.dfy
function f(x: int): int function ff(x: int): int lemma {:axiom} ff_eq() ensures forall x {:trigger ff(x)} :: ff(x) == f(f(x)) lemma {:axiom} ff_eq2() ensures forall x {:trigger f(f(x))} :: ff(x) == f(f(x)) lemma {:axiom} ff_eq_bad() // dafny ignores this trigger because it's an obvious loop ensures forall x...
function f(x: int): int function ff(x: int): int lemma {:axiom} ff_eq() ensures forall x {:trigger ff(x)} :: ff(x) == f(f(x)) lemma {:axiom} ff_eq2() ensures forall x {:trigger f(f(x))} :: ff(x) == f(f(x)) lemma {:axiom} ff_eq_bad() // dafny ignores this trigger because it's an obvious loop ensures forall x...
733
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_dafny-internals_03-encoding_lemma_call.dfy
function f(x: int): int lemma {:axiom} f_positive(x: int) requires x >= 0 ensures f(x) >= 0 lemma f_2_pos() ensures f(2) >= 0 { f_positive(2); } lemma f_1_1_pos() ensures f(1 + 1) >= 0 { f_2_pos(); assert 1 + 1 == 2; }
function f(x: int): int lemma {:axiom} f_positive(x: int) requires x >= 0 ensures f(x) >= 0 lemma f_2_pos() ensures f(2) >= 0 { f_positive(2); } lemma f_1_1_pos() ensures f(1 + 1) >= 0 { f_2_pos(); }
734
protocol-verification-fa2023_tmp_tmpw6hy3mjp_demos_dafny-internals_03-encoding_pair.dfy
// based on https://ethz.ch/content/dam/ethz/special-interest/infk/chair-program-method/pm/documents/Education/Courses/SS2019/Program%20Verification/05-EncodingToSMT.pdf module DafnyVersion { datatype Pair = Pair(x: int, y: int) function pair_x(p: Pair): int { p.x } function pair_y(p: Pair): int { p....
// based on https://ethz.ch/content/dam/ethz/special-interest/infk/chair-program-method/pm/documents/Education/Courses/SS2019/Program%20Verification/05-EncodingToSMT.pdf module DafnyVersion { datatype Pair = Pair(x: int, y: int) function pair_x(p: Pair): int { p.x } function pair_y(p: Pair): int { p....
735
protocol-verification-fa2023_tmp_tmpw6hy3mjp_exercises_chapter04-invariants_ch03exercise03.dfy
// Model a lock service that consists of a single server and an // arbitrary number of clients. // // The state of the system includes the server's state (whether the server // knows that some client holds the lock, and if so which one) // and the clients' states (for each client, whether that client knows // it holds...
// Model a lock service that consists of a single server and an // arbitrary number of clients. // // The state of the system includes the server's state (whether the server // knows that some client holds the lock, and if so which one) // and the clients' states (for each client, whether that client knows // it holds...
736
pucrs-metodos-formais-t1_tmp_tmp7gvq3cw4_fila.dfy
/* OK fila de tamanho ilimitado com arrays circulares OK representação ghost: coleção de elementos da fila e qualquer outra informação necessária OK predicate: invariante da representação abstrata associada à coleção do tipo fila Operações - OK construtor inicia fila fazia - OK adic...
/* OK fila de tamanho ilimitado com arrays circulares OK representação ghost: coleção de elementos da fila e qualquer outra informação necessária OK predicate: invariante da representação abstrata associada à coleção do tipo fila Operações - OK construtor inicia fila fazia - OK adic...
737
repo-8967-Ironclad_tmp_tmp4q25en_1_ironclad-apps_src_Dafny_Libraries_Util_seqs_simple.dfy
static lemma lemma_vacuous_statement_about_a_sequence(intseq:seq<int>, j:int) requires 0<=j<|intseq|; ensures intseq[0..j]==intseq[..j]; { } static lemma lemma_painful_statement_about_a_sequence(intseq:seq<int>) ensures intseq==intseq[..|intseq|]; { } static lemma lemma_obvious_statement_about_a_sequence(...
static lemma lemma_vacuous_statement_about_a_sequence(intseq:seq<int>, j:int) requires 0<=j<|intseq|; ensures intseq[0..j]==intseq[..j]; { } static lemma lemma_painful_statement_about_a_sequence(intseq:seq<int>) ensures intseq==intseq[..|intseq|]; { } static lemma lemma_obvious_statement_about_a_sequence(...
738
sat_dfy_tmp_tmpfcyj8am9_dfy_Seq.dfy
module Seq { function seq_sum(s: seq<int>) : (sum: int) { if s == [] then 0 else var x := s[0]; var remaining := s[1..]; x + seq_sum(remaining) } lemma SeqPartsSameSum(s: seq<int>, s1: seq<int>, s2: seq<int>) requires s == s1 + s2 ...
module Seq { function seq_sum(s: seq<int>) : (sum: int) { if s == [] then 0 else var x := s[0]; var remaining := s[1..]; x + seq_sum(remaining) } lemma SeqPartsSameSum(s: seq<int>, s1: seq<int>, s2: seq<int>) requires s == s1 + s2 ...
739
se2011_tmp_tmp71eb82zt_ass1_ex4.dfy
method Eval(x:int) returns (r:int) // do not change requires x >= 0 ensures r == x*x { // do not change var y:int := x; // do not change var z:int := 0; // do not change while y>0 // do not change invariant 0 <= y <= x && z == x*(x-y) decreases y { // do not change z := z + x; ...
method Eval(x:int) returns (r:int) // do not change requires x >= 0 ensures r == x*x { // do not change var y:int := x; // do not change var z:int := 0; // do not change while y>0 // do not change { // do not change z := z + x; // do not change y := y - 1; // do no...
740
se2011_tmp_tmp71eb82zt_ass1_ex6.dfy
method Ceiling7(n:nat) returns (k:nat) requires n >= 0 ensures k == n-(n%7) { k := n-(n%7); } method test7() { var k: nat; k := Ceiling7(43); assert k == 42; k := Ceiling7(6); assert k == 0; k := Ceiling7(1000); assert k == 994; k := Ceiling7(7); assert k == 7; k := Ceiling7(70); assert k == 70; }
method Ceiling7(n:nat) returns (k:nat) requires n >= 0 ensures k == n-(n%7) { k := n-(n%7); } method test7() { var k: nat; k := Ceiling7(43); k := Ceiling7(6); k := Ceiling7(1000); k := Ceiling7(7); k := Ceiling7(70); }
741
se2011_tmp_tmp71eb82zt_ass2_ex2.dfy
// ex2 // this was me playing around to try and get an ensures for the method /*predicate method check(a: array<int>, seclar:int) requires a.Length > 0 reads a { ensures exists i :: 0 <= i < a.Length && forall j :: (0 <= j < a.Length && j != i) ==> (a[i] >= a[j]) && (seclar <= a[i]) && ( if a[j] != a[i] then seclar >...
// ex2 // this was me playing around to try and get an ensures for the method /*predicate method check(a: array<int>, seclar:int) requires a.Length > 0 reads a { ensures exists i :: 0 <= i < a.Length && forall j :: (0 <= j < a.Length && j != i) ==> (a[i] >= a[j]) && (seclar <= a[i]) && ( if a[j] != a[i] then seclar >...
742
software-specification-p1_tmp_tmpz9x6mpxb_BoilerPlate_Ex1.dfy
datatype Tree<V> = Leaf(V) | SingleNode(V, Tree<V>) | DoubleNode(V, Tree<V>, Tree<V>) datatype Code<V> = CLf(V) | CSNd(V) | CDNd(V) function serialise<V>(t : Tree<V>) : seq<Code<V>> decreases t { match t { case Leaf(v) => [ CLf(v) ] case SingleNode(v, t) => serialise(t) + [ CSNd(v) ] case DoubleNode...
datatype Tree<V> = Leaf(V) | SingleNode(V, Tree<V>) | DoubleNode(V, Tree<V>, Tree<V>) datatype Code<V> = CLf(V) | CSNd(V) | CDNd(V) function serialise<V>(t : Tree<V>) : seq<Code<V>> { match t { case Leaf(v) => [ CLf(v) ] case SingleNode(v, t) => serialise(t) + [ CSNd(v) ] case DoubleNode(v, t1, t2) => ...
743
software_analysis_tmp_tmpmt6bo9sf_ss.dfy
method find_min_index(a : array<int>, s: int, e: int) returns (min_i: int) requires a.Length > 0 requires 0 <= s < a.Length requires e <= a.Length requires e > s ensures min_i >= s ensures min_i < e ensures forall k: int :: s <= k < e ==> a[min_i] <= a[k] { min_i := s; var i : int := s; while i < e ...
method find_min_index(a : array<int>, s: int, e: int) returns (min_i: int) requires a.Length > 0 requires 0 <= s < a.Length requires e <= a.Length requires e > s ensures min_i >= s ensures min_i < e ensures forall k: int :: s <= k < e ==> a[min_i] <= a[k] { min_i := s; var i : int := s; while i < e ...
744
specTesting_tmp_tmpueam35lx_examples_binary_search_binary_search_specs.dfy
lemma BinarySearch(intSeq:seq<int>, key:int) returns (r:int) // original requires forall i,j | 0 <= i <= j < |intSeq| :: intSeq[i] <= intSeq[j] ensures r >= 0 ==> r < |intSeq| && intSeq[r] == key ensures r < 0 ==> forall i:nat | i < |intSeq| :: intSeq[i] != key { var lo:nat := 0; var hi:nat :=...
lemma BinarySearch(intSeq:seq<int>, key:int) returns (r:int) // original requires forall i,j | 0 <= i <= j < |intSeq| :: intSeq[i] <= intSeq[j] ensures r >= 0 ==> r < |intSeq| && intSeq[r] == key ensures r < 0 ==> forall i:nat | i < |intSeq| :: intSeq[i] != key { var lo:nat := 0; var hi:nat :=...
745
specTesting_tmp_tmpueam35lx_examples_increment_decrement_spec.dfy
module OneSpec { datatype Variables = Variables(value: int) predicate Init(v: Variables) { v.value == 0 } predicate IncrementOp(v: Variables, v': Variables) { && v'.value == v.value + 1 } predicate DecrementOp(v: Variables, v': Variables) { && v'.value == v...
module OneSpec { datatype Variables = Variables(value: int) predicate Init(v: Variables) { v.value == 0 } predicate IncrementOp(v: Variables, v': Variables) { && v'.value == v.value + 1 } predicate DecrementOp(v: Variables, v': Variables) { && v'.value == v...
746
specTesting_tmp_tmpueam35lx_examples_max_max.dfy
lemma max(a:int, b:int) returns (m:int) ensures m >= a ensures m >= b ensures m == a || m == b { if (a > b) { m := a; } else { m := b; } } predicate post_max(a:int, b:int, m:int) { && m >= a && m >= b && (m == a || m == b) } // to check if it is functioning: postcon...
lemma max(a:int, b:int) returns (m:int) ensures m >= a ensures m >= b ensures m == a || m == b { if (a > b) { m := a; } else { m := b; } } predicate post_max(a:int, b:int, m:int) { && m >= a && m >= b && (m == a || m == b) } // to check if it is functioning: postcon...
747
specTesting_tmp_tmpueam35lx_examples_sort_sort.dfy
method quickSort(intSeq:array<int>) modifies intSeq ensures forall i:nat, j:nat | 0 <= i <= j < intSeq.Length :: intSeq[i] <= intSeq[j] // ensures multiset(intSeq[..]) == multiset(old(intSeq[..])) lemma sort(prevSeq:seq<int>) returns (curSeq:seq<int>) ensures (forall i:nat, j:nat | 0 <= i <= j < |curS...
method quickSort(intSeq:array<int>) modifies intSeq ensures forall i:nat, j:nat | 0 <= i <= j < intSeq.Length :: intSeq[i] <= intSeq[j] // ensures multiset(intSeq[..]) == multiset(old(intSeq[..])) lemma sort(prevSeq:seq<int>) returns (curSeq:seq<int>) ensures (forall i:nat, j:nat | 0 <= i <= j < |curS...
748
stunning-palm-tree_tmp_tmpr84c2iwh_ch1.dfy
// Ex 1.3 method Triple (x: int) returns (r: int) ensures r == 3*x { var y := 2*x; r := y + x; assert r == 3*x; } method Caller() { var t := Triple(18); assert t < 100; } // Ex 1.6 method MinUnderSpec (x: int, y: int) returns (r: int) ensures r <= x && r <= y { if x <= y { r := x - 1; } else { ...
// Ex 1.3 method Triple (x: int) returns (r: int) ensures r == 3*x { var y := 2*x; r := y + x; } method Caller() { var t := Triple(18); } // Ex 1.6 method MinUnderSpec (x: int, y: int) returns (r: int) ensures r <= x && r <= y { if x <= y { r := x - 1; } else { r := y - 1; } } method Min (x: ...
749
stunning-palm-tree_tmp_tmpr84c2iwh_ch10.dfy
// Ch. 10: Datatype Invariants module PQueue { export // Impl provides PQueue provides Empty, IsEmpty, Insert, RemoveMin // Spec provides Valid, Elements, EmptyCorrect, IsEmptyCorrect provides InsertCorrect, RemoveMinCorrect reveals IsMin // Implementati...
// Ch. 10: Datatype Invariants module PQueue { export // Impl provides PQueue provides Empty, IsEmpty, Insert, RemoveMin // Spec provides Valid, Elements, EmptyCorrect, IsEmptyCorrect provides InsertCorrect, RemoveMinCorrect reveals IsMin // Implementati...
750
stunning-palm-tree_tmp_tmpr84c2iwh_ch5.dfy
function More(x: int): int { if x <= 0 then 1 else More(x - 2) + 3 } lemma {:induction false} Increasing(x: int) ensures x < More(x) { if x <= 0 {} else { // x < More(x) <=> x < More(x - 2) + 3 // <=> x - 3 < More(x - 2) // Increasing(x - 2) ==> x - 2 < More(x - 2) // ...
function More(x: int): int { if x <= 0 then 1 else More(x - 2) + 3 } lemma {:induction false} Increasing(x: int) ensures x < More(x) { if x <= 0 {} else { // x < More(x) <=> x < More(x - 2) + 3 // <=> x - 3 < More(x - 2) // Increasing(x - 2) ==> x - 2 < More(x - 2) // ...
751
stunning-palm-tree_tmp_tmpr84c2iwh_ch8.dfy
// Ch. 8: Sorting datatype List<T> = Nil | Cons(head: T, tail: List<T>) function Length<T>(xs: List<T>): int ensures Length(xs) >= 0 { match xs case Nil => 0 case Cons(_, tl) => 1 + Length(tl) } function At<T>(xs: List, i: nat): T requires i < Length(xs) { if i == 0 then xs.head else At(xs.tail, ...
// Ch. 8: Sorting datatype List<T> = Nil | Cons(head: T, tail: List<T>) function Length<T>(xs: List<T>): int ensures Length(xs) >= 0 { match xs case Nil => 0 case Cons(_, tl) => 1 + Length(tl) } function At<T>(xs: List, i: nat): T requires i < Length(xs) { if i == 0 then xs.head else At(xs.tail, ...
752
summer-school-2020_tmp_tmpn8nf7zf0_chapter01_solutions_exercise04_solution.dfy
// Predicates // A common thing you'll want is a function with a boolean result. function AtLeastTwiceAsBigFunction(a:int, b:int) : bool { a >= 2*b } // It's so fantastically common that there's a shorthand for it: `predicate`. predicate AtLeastTwiceAsBigPredicate(a:int, b:int) { a >= 2*b } function Double(a:int...
// Predicates // A common thing you'll want is a function with a boolean result. function AtLeastTwiceAsBigFunction(a:int, b:int) : bool { a >= 2*b } // It's so fantastically common that there's a shorthand for it: `predicate`. predicate AtLeastTwiceAsBigPredicate(a:int, b:int) { a >= 2*b } function Double(a:int...
753
summer-school-2020_tmp_tmpn8nf7zf0_chapter01_solutions_exercise11_solution.dfy
// Algebraic datatypes in their full glory. The include statement. // A struct is a product: // There are 3 HAlign instances, and 3 VAlign instances; // so there are 9 TextAlign instances (all combinations). // Note that it's okay to omit the parens for zero-element constructors. datatype HAlign = Left | Center | Righ...
// Algebraic datatypes in their full glory. The include statement. // A struct is a product: // There are 3 HAlign instances, and 3 VAlign instances; // so there are 9 TextAlign instances (all combinations). // Note that it's okay to omit the parens for zero-element constructors. datatype HAlign = Left | Center | Righ...
754
summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise01_solution.dfy
predicate divides(f:nat, i:nat) requires 1<=f { i % f == 0 } predicate IsPrime(i:nat) { && 1 < i && forall f :: 1 < f < i ==> !divides(f, i) } method Main() { assert !IsPrime(0); assert !IsPrime(1); assert IsPrime(2); assert IsPrime(3); assert divides(2, 6); assert !IsPrime(6); assert IsPrime(7)...
predicate divides(f:nat, i:nat) requires 1<=f { i % f == 0 } predicate IsPrime(i:nat) { && 1 < i && forall f :: 1 < f < i ==> !divides(f, i) } method Main() { }
755
summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise02_solution.dfy
predicate divides(f:nat, i:nat) requires 1<=f { i % f == 0 } predicate IsPrime(i:nat) { && 1<i && ( forall f :: 1 < f < i ==> !divides(f, i) ) } // Convincing the proof to go through requires adding // a loop invariant and a triggering assert. method test_prime(i:nat) returns (result:bool) requires 1<i en...
predicate divides(f:nat, i:nat) requires 1<=f { i % f == 0 } predicate IsPrime(i:nat) { && 1<i && ( forall f :: 1 < f < i ==> !divides(f, i) ) } // Convincing the proof to go through requires adding // a loop invariant and a triggering assert. method test_prime(i:nat) returns (result:bool) requires 1<i en...
756
summer-school-2020_tmp_tmpn8nf7zf0_chapter02_solutions_exercise03_solution.dfy
predicate IsSorted(s:seq<int>) { forall i :: 0 <= i < |s|-1 ==> s[i] <= s[i+1] } predicate SortSpec(input:seq<int>, output:seq<int>) { && IsSorted(output) && multiset(output) == multiset(input) } //lemma SequenceConcat(s:seq<int>, pivot:int) // requires 0<=pivot<|s| // ensures s[..pivot] + s[pivot..] == s //{...
predicate IsSorted(s:seq<int>) { forall i :: 0 <= i < |s|-1 ==> s[i] <= s[i+1] } predicate SortSpec(input:seq<int>, output:seq<int>) { && IsSorted(output) && multiset(output) == multiset(input) } //lemma SequenceConcat(s:seq<int>, pivot:int) // requires 0<=pivot<|s| // ensures s[..pivot] + s[pivot..] == s //{...
757
t1_MF_tmp_tmpi_sqie4j_exemplos_classes_parte1_contadorV1b.dfy
class Contador { var valor: int; //construtor anônimo constructor () ensures valor == 0 { valor := 0; } //construtor com nome constructor Init(v:int) ensures valor == v { valor := v; } method Incrementa() modifies this ensures valor == o...
class Contador { var valor: int; //construtor anônimo constructor () ensures valor == 0 { valor := 0; } //construtor com nome constructor Init(v:int) ensures valor == v { valor := v; } method Incrementa() modifies this ensures valor == o...
758
t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_arrays_ex4.dfy
function SomaAte(a:array<nat>, i:nat):nat requires 0 <= i <= a.Length reads a { if i == 0 then 0 else a[i-1] + SomaAte(a,i-1) } method Somatorio(a:array<nat>) returns (s:nat) ensures s == SomaAte(a,a.Length) { var i := 0; s := 0; while i < a.Length invariant 0 <= i && i <= a.Length ...
function SomaAte(a:array<nat>, i:nat):nat requires 0 <= i <= a.Length reads a { if i == 0 then 0 else a[i-1] + SomaAte(a,i-1) } method Somatorio(a:array<nat>) returns (s:nat) ensures s == SomaAte(a,a.Length) { var i := 0; s := 0; while i < a.Length { s := s + a[i]; i :...
759
t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_arrays_ex5.dfy
method Busca<T(==)>(a:array<T>, x:T) returns (r:int) ensures 0 <= r ==> r < a.Length && a[r] == x ensures r < 0 ==> forall i :: 0 <= i < a.Length ==> a[i] != x { r :=0; while r < a.Length invariant 0 <= r <= a.Length invariant forall i :: 0 <= i < r ==> a[i] != x { if a[r]==x ...
method Busca<T(==)>(a:array<T>, x:T) returns (r:int) ensures 0 <= r ==> r < a.Length && a[r] == x ensures r < 0 ==> forall i :: 0 <= i < a.Length ==> a[i] != x { r :=0; while r < a.Length { if a[r]==x { return; } r := r + 1; } r := -1; }
760
t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_conjuntos_ex5.dfy
function to_seq<T>(a: array<T>, i: int) : (res: seq<T>) requires 0 <= i <= a.Length ensures res == a[i..] reads a decreases a.Length-i { if i == a.Length then [] else [a[i]] + to_seq(a, i + 1) } method Main() { var a: array<int> := new int[2]; a[0] := 2; a[1] := 3; var ms: multiset<int> := multiset(a[.....
function to_seq<T>(a: array<T>, i: int) : (res: seq<T>) requires 0 <= i <= a.Length ensures res == a[i..] reads a { if i == a.Length then [] else [a[i]] + to_seq(a, i + 1) } method Main() { var a: array<int> := new int[2]; a[0] := 2; a[1] := 3; var ms: multiset<int> := multiset(a[..]); }
761
t1_MF_tmp_tmpi_sqie4j_exemplos_colecoes_sequences_ex3.dfy
// line contém uma string de tamanho l // remover p caracteres a partir da posição at method Delete(line:array<char>, l:nat, at:nat, p:nat) requires l <= line.Length requires at+p <= l modifies line ensures line[..at] == old(line[..at]) ensures line[at..l-p] == old(line[at+p..l]) { var i:nat := 0; whi...
// line contém uma string de tamanho l // remover p caracteres a partir da posição at method Delete(line:array<char>, l:nat, at:nat, p:nat) requires l <= line.Length requires at+p <= l modifies line ensures line[..at] == old(line[..at]) ensures line[at..l-p] == old(line[at+p..l]) { var i:nat := 0; whi...
762
t1_MF_tmp_tmpi_sqie4j_exemplos_introducao_ex4.dfy
function Fat(n: nat): nat { if n == 0 then 1 else n * Fat(n-1) } method Fatorial(n:nat) returns (r:nat) ensures r == Fat(n) { r := 1; var i := 0; while i < n invariant 0 <= i <= n invariant r == Fat(i) { i := i + 1; r := r * i; } }
function Fat(n: nat): nat { if n == 0 then 1 else n * Fat(n-1) } method Fatorial(n:nat) returns (r:nat) ensures r == Fat(n) { r := 1; var i := 0; while i < n { i := i + 1; r := r * i; } }
763
tangent-finder_tmp_tmpgyzf44ve_circles.dfy
method Tangent(r: array<int>, x: array<int>) returns (b: bool) requires forall i, j :: 0 <= i <= j < x.Length ==> x[i] <= x[j] // values in x will be in ascending order or empty requires forall i, j :: (0 <= i < r.Length && 0 <= j < x.Length) ==> (r[i] >= 0 && x[j] >= 0) // x and r will contain no negativ...
method Tangent(r: array<int>, x: array<int>) returns (b: bool) requires forall i, j :: 0 <= i <= j < x.Length ==> x[i] <= x[j] // values in x will be in ascending order or empty requires forall i, j :: (0 <= i < r.Length && 0 <= j < x.Length) ==> (r[i] >= 0 && x[j] >= 0) // x and r will contain no negativ...
764
test-generation-examples_tmp_tmptwyqofrp_IntegerSet_dafny_IntegerSet.dfy
module IntegerSet { class Set { var elements: seq<int>; constructor Set0() ensures this.elements == [] ensures |this.elements| == 0 { this.elements := []; } constructor Set(elements: seq<int>) requires forall i, j | 0 <= i < |elements|...
module IntegerSet { class Set { var elements: seq<int>; constructor Set0() ensures this.elements == [] ensures |this.elements| == 0 { this.elements := []; } constructor Set(elements: seq<int>) requires forall i, j | 0 <= i < |elements|...
765
test-generation-examples_tmp_tmptwyqofrp_IntegerSet_dafny_Utils.dfy
module Utils { class Assertions<T> { static method {:extern} assertEquals(expected : T, actual : T) requires expected == actual static method {:extern} expectEquals(expected : T, actual : T) ensures expected == actual static method {:extern} assertTrue(condition : bool) requires condition ...
module Utils { class Assertions<T> { static method {:extern} assertEquals(expected : T, actual : T) requires expected == actual static method {:extern} expectEquals(expected : T, actual : T) ensures expected == actual static method {:extern} assertTrue(condition : bool) requires condition ...
766
test-generation-examples_tmp_tmptwyqofrp_ParamTests_dafny_Utils.dfy
module Utils { export reveals Assertions provides Assertions.assertEquals class Assertions { static method {:axiom} assertEquals<T>(left : T, right : T) requires left == right /* public static void assertEquals<T>(T a, T b) { Xunit.Assert.Equal(a, b); } ...
module Utils { export reveals Assertions provides Assertions.assertEquals class Assertions { static method {:axiom} assertEquals<T>(left : T, right : T) requires left == right /* public static void assertEquals<T>(T a, T b) { Xunit.Assert.Equal(a, b); } ...
767
test-generation-examples_tmp_tmptwyqofrp_RussianMultiplication_dafny_RussianMultiplication.dfy
module RussianMultiplication { export provides mult method mult(n0 : int, m0 : int) returns (res : int) ensures res == (n0 * m0); { var n, m : int; res := 0; if (n0 >= 0) { n,m := n0, m0; } else { n,m := -n0, -m0; } w...
module RussianMultiplication { export provides mult method mult(n0 : int, m0 : int) returns (res : int) ensures res == (n0 * m0); { var n, m : int; res := 0; if (n0 >= 0) { n,m := n0, m0; } else { n,m := -n0, -m0; } w...
768
type-definition_tmp_tmp71kdzz3p_final.dfy
// ------------------------------------------------------------- // 1. Implementing type inference // ------------------------------------------------------------- // Syntax: // // τ := Int | Bool | τ1->τ2 // e ::= x | λx : τ.e | true| false| e1 e2 | if e then e1 else e2 // v ::= true | false | λx : τ.e // E ::= [·] |...
// ------------------------------------------------------------- // 1. Implementing type inference // ------------------------------------------------------------- // Syntax: // // τ := Int | Bool | τ1->τ2 // e ::= x | λx : τ.e | true| false| e1 e2 | if e then e1 else e2 // v ::= true | false | λx : τ.e // E ::= [·] |...
769
veri-sparse_tmp_tmp15fywna6_dafny_concurrent_poc_6.dfy
class Process { var row: nat; var curColumn: nat; var opsLeft: nat; constructor (init_row: nat, initOpsLeft: nat) ensures row == init_row ensures opsLeft == initOpsLeft ensures curColumn == 0 { row := init_row; curColumn := 0; opsLeft := initOpsLeft;...
class Process { var row: nat; var curColumn: nat; var opsLeft: nat; constructor (init_row: nat, initOpsLeft: nat) ensures row == init_row ensures opsLeft == initOpsLeft ensures curColumn == 0 { row := init_row; curColumn := 0; opsLeft := initOpsLeft;...
770
veri-sparse_tmp_tmp15fywna6_dafny_dspmspv.dfy
function sum(X_val : array<int>, X_crd : array<nat>, v_val : array<int>, v_crd : array<nat>, kX : nat, kV : nat, pX_end : nat, pV_end : nat) : (s : int) reads X_val, X_crd requires X_val.Length == X_crd.Length requires pX_end <= X_crd.Length requires 0 <= kX <= X_crd.Length reads v_crd, v_val ...
function sum(X_val : array<int>, X_crd : array<nat>, v_val : array<int>, v_crd : array<nat>, kX : nat, kV : nat, pX_end : nat, pV_end : nat) : (s : int) reads X_val, X_crd requires X_val.Length == X_crd.Length requires pX_end <= X_crd.Length requires 0 <= kX <= X_crd.Length reads v_crd, v_val ...
771
veri-sparse_tmp_tmp15fywna6_dafny_spmv.dfy
function sum(X_val: array<int>, X_crd: array<nat>, v : array<int>, b : int, k : int) : (s : int) reads X_val, X_crd, v requires X_val.Length >= b >= 0 requires k <= X_val.Length requires X_val.Length == X_crd.Length requires forall i :: 0 <= i < X_crd.Length ==> 0 <= X_crd[i] < v.Length decreases k - b { ...
function sum(X_val: array<int>, X_crd: array<nat>, v : array<int>, b : int, k : int) : (s : int) reads X_val, X_crd, v requires X_val.Length >= b >= 0 requires k <= X_val.Length requires X_val.Length == X_crd.Length requires forall i :: 0 <= i < X_crd.Length ==> 0 <= X_crd[i] < v.Length { if k <= b then...
772
veri-titan_tmp_tmpbg2iy0kf_spec_crypto_fntt512.dfy
// include "ct_std2rev_model.dfy" // abstract module ntt_impl { // import opened Seq // import opened Power // import opened Power2 // import opened DivMod // import opened Mul // import opened pows_of_2 // import opened ntt_index // import opened ntt_512_params // import o...
// include "ct_std2rev_model.dfy" // abstract module ntt_impl { // import opened Seq // import opened Power // import opened Power2 // import opened DivMod // import opened Mul // import opened pows_of_2 // import opened ntt_index // import opened ntt_512_params // import o...
773
veribetrkv-osdi2020_tmp_tmpra431m8q_docker-hdd_src_veribetrkv-linear_lib_Base_SetBijectivity.dfy
module SetBijectivity { lemma BijectivityImpliesEqualCardinality<A, B>(setA: set<A>, setB: set<B>, relation: iset<(A, B)>) requires forall a :: a in setA ==> exists b :: b in setB && (a, b) in relation requires forall a1, a2, b :: a1 in setA && a2 in setA && b in setB && (a1, b) in relation && (a2, b) in rela...
module SetBijectivity { lemma BijectivityImpliesEqualCardinality<A, B>(setA: set<A>, setB: set<B>, relation: iset<(A, B)>) requires forall a :: a in setA ==> exists b :: b in setB && (a, b) in relation requires forall a1, a2, b :: a1 in setA && a2 in setA && b in setB && (a1, b) in relation && (a2, b) in rela...
774
veribetrkv-osdi2020_tmp_tmpra431m8q_docker-hdd_src_veribetrkv-linear_lib_Base_Sets.dfy
module Sets { lemma {:opaque} ProperSubsetImpliesSmallerCardinality<T>(a: set<T>, b: set<T>) requires a < b ensures |a| < |b| { assert |b| == |a| + |b-a|; } lemma {:opaque} SetInclusionImpliesSmallerCardinality<T>(a: set<T>, b: set<T>) requires a <= b ensures |a| <= |b| { assert b ==...
module Sets { lemma {:opaque} ProperSubsetImpliesSmallerCardinality<T>(a: set<T>, b: set<T>) requires a < b ensures |a| < |b| { } lemma {:opaque} SetInclusionImpliesSmallerCardinality<T>(a: set<T>, b: set<T>) requires a <= b ensures |a| <= |b| { } lemma {:opaque} SetInclusionImpliesStri...
775
verification-class_tmp_tmpz9ik148s_2022_chapter05-distributed-state-machines_exercises_UtilitiesLibrary.dfy
module UtilitiesLibrary { function DropLast<T>(theSeq: seq<T>) : seq<T> requires 0 < |theSeq| { theSeq[..|theSeq|-1] } function Last<T>(theSeq: seq<T>) : T requires 0 < |theSeq| { theSeq[|theSeq|-1] } function UnionSeqOfSets<T>(theSets: seq<set<T>>) : set<T> { if |theSets| == 0 the...
module UtilitiesLibrary { function DropLast<T>(theSeq: seq<T>) : seq<T> requires 0 < |theSeq| { theSeq[..|theSeq|-1] } function Last<T>(theSeq: seq<T>) : T requires 0 < |theSeq| { theSeq[|theSeq|-1] } function UnionSeqOfSets<T>(theSets: seq<set<T>>) : set<T> { if |theSets| == 0 the...
776
verified-isort_tmp_tmp7hhb8ei__dafny_isort.dfy
// Dafny is designed to be familiar to those programming in an OOP language like // Java, so, we have plain old ordinary mutable arrays rather than the functional // list data structures that we saw in Coq. This means that unlike our Coq // and Python examples, we can sort our array in-place and avoid needing a whole ...
// Dafny is designed to be familiar to those programming in an OOP language like // Java, so, we have plain old ordinary mutable arrays rather than the functional // list data structures that we saw in Coq. This means that unlike our Coq // and Python examples, we can sort our array in-place and avoid needing a whole ...
777
verified-using-dafny_tmp_tmp7jatpjyn_longestZero.dfy
function getSize(i: int, j:int) : int { j - i + 1 } // For a given integer array, let's find the longest subesquence of 0s. // sz: size, pos: position. a[pos..(pos+sz)] will be all zeros method longestZero(a: array<int>) returns (sz:int, pos:int) requires 1 <= a.Length ensures 0 <= sz <= a.Length ...
function getSize(i: int, j:int) : int { j - i + 1 } // For a given integer array, let's find the longest subesquence of 0s. // sz: size, pos: position. a[pos..(pos+sz)] will be all zeros method longestZero(a: array<int>) returns (sz:int, pos:int) requires 1 <= a.Length ensures 0 <= sz <= a.Length ...
778
vfag_tmp_tmpc29dxm1j_Verificacion_torneo.dfy
method torneo(Valores : array?<real>, i : int, j : int, k : int) returns (pos_padre : int, pos_madre : int) requires Valores != null && Valores.Length >= 20 && Valores.Length < 50 && i >= 0 && j >= 0 && k >= 0 requires i < Valores.Length && j < Valores.Length && k < Valores.Length && i != j && j != k && k != i...
method torneo(Valores : array?<real>, i : int, j : int, k : int) returns (pos_padre : int, pos_madre : int) requires Valores != null && Valores.Length >= 20 && Valores.Length < 50 && i >= 0 && j >= 0 && k >= 0 requires i < Valores.Length && j < Valores.Length && k < Valores.Length && i != j && j != k && k != i...
779
vfag_tmp_tmpc29dxm1j_mergesort.dfy
method ordenar_mergesort(V : array?<int>) requires V != null modifies V { mergesort(V, 0, V.Length - 1) ; } method mergesort(V : array?<int>, c : int, f : int) requires V != null requires c >= 0 && f <= V.Length decreases f - c modifies V { if c < f { ...
method ordenar_mergesort(V : array?<int>) requires V != null modifies V { mergesort(V, 0, V.Length - 1) ; } method mergesort(V : array?<int>, c : int, f : int) requires V != null requires c >= 0 && f <= V.Length modifies V { if c < f { var m...
780
vfag_tmp_tmpc29dxm1j_sumar_componentes.dfy
method suma_componentes(V : array?<int>) returns (suma : int) requires V != null ensures suma == suma_aux(V, 0) // x = V[0] + V[1] + ... + V[N - 1] { var n : int ; assert V != null ; // P assert 0 <= V.Length <= V.Length && 0 == suma_aux(V, V.Length) ; // P ==> pmd(n := V.Length ; x := ...
method suma_componentes(V : array?<int>) returns (suma : int) requires V != null ensures suma == suma_aux(V, 0) // x = V[0] + V[1] + ... + V[N - 1] { var n : int ; n := V.Length ; // n := N suma := 0 ; while n != 0 { suma := suma + V[n - 1] ; n := n - 1 ; } ...
781
vmware-verification-2023_tmp_tmpoou5u54i_demos_leader_election.dfy
// Each node's identifier (address) datatype Constants = Constants(ids: seq<nat>) { predicate ValidIdx(i: int) { 0<=i<|ids| } ghost predicate UniqueIds() { (forall i, j | ValidIdx(i) && ValidIdx(j) && ids[i]==ids[j] :: i == j) } ghost predicate WF() { && 0 < |ids| && UniqueIds() } } // Th...
// Each node's identifier (address) datatype Constants = Constants(ids: seq<nat>) { predicate ValidIdx(i: int) { 0<=i<|ids| } ghost predicate UniqueIds() { (forall i, j | ValidIdx(i) && ValidIdx(j) && ids[i]==ids[j] :: i == j) } ghost predicate WF() { && 0 < |ids| && UniqueIds() } } // Th...