repo
stringclasses
966 values
path
stringlengths
5
283
license
stringclasses
13 values
stars
int64
0
3.47k
default_branch
stringclasses
15 values
commit_sha
stringclasses
966 values
pushed_at
stringdate
2015-04-17 10:56:12
2026-07-22 05:29:38
size_bytes
int64
0
1.91M
sha256
stringlengths
64
64
content
stringlengths
0
1.91M
Consensys/evm-dafny
src/test/dafny/proofs/GasTests.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
718
233cbd98695625ca67fb6213733d658af70d155a403b4145fcf1ecbd729c82be
// Some tests related to gas. include "../../../dafny/evm.dfy" module GasTests { import opened Int import EVM import EvmFork import Bytecode import opened Opcode import Gas /** The gas loaded in the EVM before executing a program. */ const INITGAS := 0xFFFF method t...
Consensys/evm-dafny
src/test/dafny/proofs/MemoryVerif.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
12,331
6b3da2fcd26612da759af432491bb7bad021434deab6c38ad4a2e0d0743e87a4
/* * Copyright 2022 ConsenSys Software Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Consensys/evm-dafny
src/test/dafny/proofs/Optimisations.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
4,726
a2c0a2f07a27b346bbec55765aa814a28c7df062449decc52b11429d99ecb684
/* * Copyright 2022 ConsenSys Software Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Consensys/evm-dafny
src/test/dafny/proofs/Push.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
703
46a1db6a40609e42bfdeaf7f9a4bfe13d05dfdabc74727350940faf8852bb522
include "../../../dafny/evm.dfy" import opened EvmState import opened Code import opened Int // Some simple sanity tests to check equivalence of Push bytecodes. method test_1(s1: ExecutingState, k:Int.u8) requires s1.CodeOperands() >= 1 requires DecodeUint8(s1.evm.code,s1.evm.pc+1) == k { var s2 := Byte...
Consensys/evm-dafny
src/test/dafny/proofs/Simulation.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
12,808
f9087c692e4e9779dff724910f708abe6a5ce93baaab180cac46c09dd37e7348
/* * Copyright 2022 ConsenSys Software Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Consensys/evm-dafny
src/test/dafny/proofs/SimulationProof.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
3,108
4c337fdf69633c2360d88de759acee32c4071365e3811519af389793a30ef4e1
// The following presents a simulation proof that two sequences of bytecode are // semantically equivalent. The two sequences were both generated from the // following Yul code: // // let x := add(sload(0x00),0x01) // if eq(x,0) { revert(0, 0) } // sstore(0x00, x) // stop() // // One sequence was generated wi...
Consensys/evm-dafny
src/test/dafny/proofs/test.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
6,661
d74125f21d03772a1885f418369ac8027edec9ef9e8ee4922e48294e5a822b5d
include "../../../dafny/evm.dfy" include "../../../dafny/core/fork.dfy" import opened Int import opened Opcode /** */ module Test { import opened Int import opened Opcode import EVM import EvmFork import Bytecode import ByteUtils import Gas /** The gas loaded in th...
Consensys/evm-dafny
src/test/dafny/proofs/Test10-with-gas.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
8,963
6cf7a2c7a2da374851d8bf4e06c2ae697bc2ee75eb37486e7e38e8b9f2dfd465
/* * Copyright 2022 ConsenSys Software Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Consensys/evm-dafny
src/test/dafny/proofs/Transient.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
9,122
67508a361dab2742e5865835da8a7f5007f96bb8bf443f932ec3255adba8dced
include "../../../dafny/evm.dfy" module Transient { import opened Int import opened Bytecode import opened EVM import opened EvmState import opened Opcode import Stack import Gas // Some simple tests for transient storage method test_1(s1: ExecutingState) requi...
Consensys/evm-dafny
src/test/dafny/tests/ArrayTests.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
1,070
9f2d60753a6fadb01ca570ce24cffb8ae19cf8122f647a169b31b1d87bb09826
include "../../../dafny/util/arrays.dfy" include "../utils.dfy" module ArrayTests{ import opened Arrays import opened Utils method {:test} CopyTests() { // n=0 AssertAndExpect(Copy([],[1,2,3],0) == [1,2,3]); // n=1 AssertAndExpect(Copy([4],[1,2,3],0) == [4,2,3]);...
Consensys/evm-dafny
src/test/dafny/tests/ByteTests.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
5,348
c323285caf25755c667d999ee82e5fc275860bd245ca73f78d1422ca96c2b7c7
include "../../../dafny/util/bytes.dfy" include "../utils.dfy" module ByteTests{ import opened ByteUtils import opened Utils method {:test} ReadTests() { // U8 AssertAndExpect(ReadUint8([],0) == 0); AssertAndExpect(ReadUint8([0],0) == 0); AssertAndExpect(ReadUint...
Consensys/evm-dafny
src/test/dafny/tests/CallExample.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
4,376
23c9fa0b30657c12e3c722bcfc645daeeecddb3c18b5a48fbd028d5098ca8012
// An set of examples illustrating contract calls. include "../../../dafny/evm.dfy" include "../utils.dfy" module CallExamples { import opened Int import opened Opcode import opened Memory import EVM import WorldState import opened Bytecode import opened Utils /** The ga...
Consensys/evm-dafny
src/test/dafny/tests/ForkTests.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
1,439
f13691c6081aec8fae4999159605a230c64eb8e66a293373558e9945cbb022d6
/* * Copyright 2022 ConsenSys Software Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Consensys/evm-dafny
src/test/dafny/tests/IntTests.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
24,021
4a07226a088287faafbd1c65c2667b9e062050b33e68dcf9c555bfad956a4c14
include "../../../dafny/util/int.dfy" include "../utils.dfy" module IntTests { import opened Int import opened Utils import opened U16 import opened U256 import opened I256 import opened Word import opened Optional // Various tests for roundup method {:test} RoundUpTes...
Consensys/evm-dafny
src/test/dafny/tests/Test10.dfy
Apache-2.0
140
master
e2e52e86d6623d48d0849f5ce1664f88c8f0e547
2026-05-11T14:57:28Z
8,617
f40e9cfcc1575cb78e83f1cf8d56688e05dd03732cb950b297da54fb26590684
/* * Copyright 2022 ConsenSys Software Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
CarlKCarlK/range-set-blaze
tests/formal/countdown.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
257
dcc7f1f58971e77b91b830e6dae8264b777cf93164160679c2bbdaad07a10697
method SlowAdd(x: nat, y: nat) returns (r: nat) ensures r == x + y { r := x; var y2 := y; while y2 > 0 invariant r + y2 == x + y { r := r + 1; y2 := y2 - 1; } } method Main() { var r := SlowAdd(2, 3); print r; }
CarlKCarlK/range-set-blaze
tests/formal/hello.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
78
908aad1bd742ab98efc12f32bbe6ae44748d233a4eaaf908fb9485af42f50e1e
// hello.dfy method Main() { var s := "Hello World"; print s, "\n"; }
CarlKCarlK/range-set-blaze
tests/formal/Rule3.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
1,075
99b9d6855eff4c044e7e6f9f4bfa13c64df98ba9301de84afef637e5382494e8
ghost predicate ValidSeq(sequence: seq<NeIntRange>) { (forall i:nat, j:nat | i < j < |sequence| :: sequence[i].0 < sequence[j].0) && (forall i:nat, j:nat | i < j < |sequence| :: !Touch(sequence[i], sequence[j])) } type IntRange = (int, int) type NeIntRange = x: IntRange | !IsEmpty(x) witness (0,0) functio...
CarlKCarlK/range-set-blaze
tests/formal/Rule4.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
702
cf44fa75717ef2bbde30e35b8a53bb05b705d800905c9ac40433f127557b9370
include "Rule3.dfy" method InternalAdd(xs: seq<NeIntRange>, a: IntRange) returns (rs: seq<NeIntRange>) requires ValidSeq(xs) ensures ValidSeq(rs) ensures SeqToSet(rs) == SeqToSet(xs) + RangeToSet(a) { if IsEmpty(a) { rs := xs; } else { assume false; // cheat for now } } ghos...
CarlKCarlK/range-set-blaze
tests/formal/Rule6.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
6,078
f6283f6d43ada4bb73ee498e0957a53c650d711fa1e33331b2209bc9b7a0eeb2
include "Rule3.dfy" method InternalAdd(xs: seq<NeIntRange>, a: IntRange) returns (rs: seq<NeIntRange>) requires ValidSeq(xs) ensures ValidSeq(rs) ensures SeqToSet(rs) == SeqToSet(xs) + RangeToSet(a) { if IsEmpty(a) { rs := xs; } else { var notTouching, merged := PartitionAndMerge(x...
CarlKCarlK/range-set-blaze
tests/formal/Rule7.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
5,698
6b0f271767db48e46155e6d1254a41b00e6bbc5438cd9332e90c83afa005e2e5
// doesn't validate include "Rule3.dfy" method InternalAdd(xs: seq<NeIntRange>, range: IntRange) returns (r: seq<NeIntRange>) requires ValidSeq(xs) ensures ValidSeq(r) ensures SeqToSet(r) == SeqToSet(xs) + RangeToSet(range) { var (start, end) := range; if end < start { r := xs; return; ...
CarlKCarlK/range-set-blaze
tests/formal/Rule8a.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
6,575
1333e34d672cc32c5e4b7b565b9968769a369b01f0bb3fc8ef5e4cc772efd57b
// does not validate include "Rule3.dfy" method InternalAdd(xs: seq<NeIntRange>, range: IntRange) returns (r: seq<NeIntRange>) requires ValidSeq(xs) ensures ValidSeq(r) ensures SeqToSet(r) == SeqToSet(xs) + RangeToSet(range) { var (start, end) := range; if end < start { r := xs; assert S...
CarlKCarlK/range-set-blaze
tests/formal/Rule8b.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
14,543
6aee009067be6a2313d78951e4a797b1b9e2fd7fc7d0d4a8995b6cbae6cabf86
// usually doesn't validate, but it could include "Rule3.dfy" method InternalAdd(xs: seq<NeIntRange>, range: IntRange) returns (r: seq<NeIntRange>) requires ValidSeq(xs) ensures ValidSeq(r) ensures SeqToSet(r) == SeqToSet(xs) + RangeToSet(range) { var (start, end) := range; if end < start { r...
CarlKCarlK/range-set-blaze
tests/formal/Step9.dfy
NOASSERTION
111
main
aec75cd6d58ba8898c7393f456027123b85adbf5
2026-07-11T22:04:13Z
14,482
a75b379ee2525d59a11fe45da958f047f14878c1014ded97d86ee299ff39994b
include "Rule3.dfy" method InternalAdd(xs: seq<NeIntRange>, range: IntRange) returns (r: seq<NeIntRange>) requires ValidSeq(xs) ensures ValidSeq(r) ensures SeqToSet(r) == SeqToSet(xs) + RangeToSet(range) { var (start, end) := range; if end < start { r := xs; return; } var beforeHi :...
knightking100/hello-worlds
examples/d/Dafny.dfy
Unlicense
69
master
217684a506ae980ed4e47f5f8970e62fdbf686eb
2023-01-03T19:34:38Z
49
4630c1fb9b2c2f1824f92958dbb8b9ba603ef2a66982097e65ca4b8b3c331f64
method Main() { print "Hello, World!\n"; }
midspiral/LemmaScript
examples/andChainStmt.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,174
b166a40a8cb9e4cab1e42fda9c604530c3b70798cce0d18d311964dec646858b
// Generated by lsc from andChainStmt.ts datatype Option<T> = None | Some(value: T) datatype Inner = Inner(val: int) datatype Box = Box(items: seq<int>, inner: Option<Inner>) function total(xs: seq<int>): int { |xs| } lemma total_ensures(xs: seq<int>) ensures (total(xs) == |xs|) { } function...
midspiral/LemmaScript
examples/arrayContains.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
729
f1690a54673505d1cdbd8f45eef7ce7c3e431efad2f23291766c89cc81bbb7b4
// Generated by lsc from arrayContains.ts method arrayContains(arr: seq<int>, target: int) returns (res: bool) ensures ((res == true) ==> exists k: nat :: ((k < |arr|) && (arr[k] == target))) ensures ((res == false) ==> forall k: nat :: ((k < |arr|) ==> (arr[k] != target))) { var found := false; var i_x...
midspiral/LemmaScript
examples/arrayIsArrayChain.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
754
c13f6b2513225627af4a641f52a88315b8c2ae0e95c4786e6817af5072121a41
// Generated by lsc from arrayIsArrayChain.ts datatype Part = Part(type_: string) datatype ArrayOf_Part_Or_string = ArrayBranch(arr: seq<Part>) | NonArrayBranch(val: string) datatype Msg = Msg(role: string, content: ArrayOf_Part_Or_string) method countAssistantParts(msgs: seq<Msg>) returns (res: int) ens...
midspiral/LemmaScript
examples/arraySum.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
513
893375d68feed98c4819107c5d9b7218b977069bf7e8f435dd9763867268286e
// Generated by lsc from arraySum.ts function sumTo(arr: seq<int>, n: int): int requires 0 <= n <= |arr| { if n == 0 then 0 else sumTo(arr, n - 1) + arr[n - 1] } method arraySum(arr: seq<int>) returns (res: int) ensures (res == sumTo(arr, |arr|)) { var sum := 0; var i := 0; while (i < |arr|) ...
midspiral/LemmaScript
examples/assume.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
240
9bb9ce9c7654a4d469b62614c2eb9de31089ef4dfd06f8063e2408f0646bde2f
// Generated by lsc from assume.ts method shortenString(text: string) returns (res: int) ensures (res >= 0) ensures (res <= |text|) { var cleaned: string := *; assume {:axiom} (|cleaned| <= |text|); return |cleaned|; }
midspiral/LemmaScript
examples/auction.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
2,693
a70a162c069ed6a62984635edd9811f4ed19f43063cbd649badbfc0176e0cfab
// Generated by lsc from auction.ts datatype Option<T> = None | Some(value: T) datatype Bid = Bid(key: string, amount: int) method highestBid(bids: seq<Option<Bid>>, key: string, reserve: int) returns (res: int) ensures (res >= reserve) { var best := reserve; var i := 0; while (i < |bids|) in...
midspiral/LemmaScript
examples/autohavoc.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
2,155
0ed05ec52e56d14a8380e8d4895f92e84fd8d71de82e051e457be2686670b790
// Generated by lsc from autohavoc.ts type Unknown(==, 0) function StringIndexOf(s: string, sub: string): int ensures StringIndexOf(s, sub) == -1 || (0 <= StringIndexOf(s, sub) <= |s| - |sub| && s[StringIndexOf(s, sub)..StringIndexOf(s, sub) + |sub|] == sub) { StringIndexOfFrom(s, sub, 0) } fun...
midspiral/LemmaScript
examples/binarySearch.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,365
77b3577d1d17337ba64c138b058d4f3b3fa735b723e64696767cfe8554820d78
// Generated by lsc from binarySearch.ts function JSFloorDiv(a: int, b: int): int requires b != 0 { if b > 0 then if a >= 0 then a / b else -((-a - 1) / b) - 1 else if a <= 0 then (-a) / (-b) else -((a - 1) / (-b)) - 1 } predicate sorted(s: seq<int>) { forall i, j :: 0 <= i < j <...
midspiral/LemmaScript
examples/bitOr.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
569
5509e6c5cbe394a0adfaac58313b6333b63a69c1f6f68e4e1e0645c0d5869446
// Generated by lsc from bitOr.ts function BitOr(x: int, y: int): int requires x >= 0 && y >= 0 decreases x { if x == 0 then y else if y == 0 then x else 2 * BitOr(x / 2, y / 2) + (if x % 2 == 1 || y % 2 == 1 then 1 else 0) } function orZero(x: int): int requires (x >= 0) { BitOr(x, 0) } ...
midspiral/LemmaScript
examples/blockScopeReuse.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,070
3066007ce809d2d458aaff05f655065c191aa27de405106d9c2170d8a0cc2d99
// Generated by lsc from blockScopeReuse.ts method sumThenCount(xs: seq<int>) returns (res: int) ensures (res >= 0) { var total := 0; var i_2 := 0; while (i_2 < |xs|) invariant (i_2 <= |xs|) invariant (total >= 0) decreases (|xs| - i_2) { if (xs[i_2] > 0) { total := (total ...
midspiral/LemmaScript
examples/clamp.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
337
b8196ae4052abd54f6b6c5e7cef318a80c4444211ea7080d1741239ad5760fad
// Generated by lsc from clamp.ts method clamp(x: int, lo: int, hi: int) returns (res: int) requires (lo <= hi) ensures (res >= lo) ensures (res <= hi) { var result := x; if (result < lo) { result := lo; } if (result > hi) { result := hi; } return result; } // LemmaScript: s...
midspiral/LemmaScript
examples/containsDuplicate.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
2,362
a11813d6c96c48049ab9e137f68a336a86ca8197e2f0ec1567f7d85513052923
// Generated by lsc from containsDuplicate.ts method containsDuplicate(nums: seq<int>) returns (res: bool) ensures ((res == true) ==> exists i: nat, j: nat :: ((((i < j) && (i < |nums|)) && (j < |nums|)) && (nums[i] == nums[j]))) ensures ((res == false) ==> forall i: nat, j: nat :: ((i < j) ==> (i < |nums|) ==...
midspiral/LemmaScript
examples/contentDispatch.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
722
c2ebdae7db1974c30a9b7362bbf9a84c2f7b1ea5a792dde660ae177022c94730
// Generated by lsc from contentDispatch.ts datatype Part = Part(type_: string, toolCallId: string) datatype ArrayOf_Part_Or_string = ArrayBranch(arr: seq<Part>) | NonArrayBranch(val: string) function partsOrEmpty(content: ArrayOf_Part_Or_string): seq<Part> { match content { case ArrayBranch(i_content...
midspiral/LemmaScript
examples/countBadPairs.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
22,412
e9ab222b79021b29f85d6fbf29150885578c5dbd886124887bd8dd3514af5b55
// Generated by lsc from countBadPairs.ts // // Hand-written proof scaffolding for the strong post-condition // `count == |badPairsImpl(nums)|`. Adapted from // https://github.com/hath995/Dafny4.4/blob/main/leetcode/CountBadPairs.dfy // // Pair-set predicates are defined in terms of the user-visible // `Pair...
midspiral/LemmaScript
examples/counter.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
650
af672c99e47c2757951243048e90d70b0e3da9699efb7bddb9a229394ccb8347
// Generated by lsc from counter.ts class Counter { var count: int var max: int method increment() returns (res: int) modifies this requires (this.count < this.max) ensures res == old(this.count) ensures this.count == old(this.count) + 1 ensures (this.count <= this.max) { ...
midspiral/LemmaScript
examples/declareTypeEnum.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
529
52e70b8141cb6b8b24e4700253f11d9667ff128cb452b20ef8b88338923936b0
// Generated by lsc from declareTypeEnum.ts datatype Role = user | assistant | toolResult datatype Msg = Msg(role: Role) function roleTag(m: Msg): string { var role := m.role; match role { case user => "u" case assistant => "a" case toolResult => "t" } } lemma ...
midspiral/LemmaScript
examples/declareTypeShadow.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
237
1b18d4f219d84c8d10ed1962d76e9b67aa7d8b17bc3c5ce15b0d2e0b873a3802
// Generated by lsc from declareTypeShadow.ts datatype RawMsg = RawMsg(kind: string) function countMsgs(msgs: seq<RawMsg>): int { |msgs| } lemma countMsgs_ensures(msgs: seq<RawMsg>) ensures (countMsgs(msgs) >= 0) { }
midspiral/LemmaScript
examples/discriminantTrailing.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
487
b8c3dbd0f63291753b14a59fa97898e0137207e95112059c3c1476ff5c869f61
// Generated by lsc from discriminantTrailing.ts datatype Shape = circle | square | triangle function classify(s: Shape): string { match s { case circle => "round" case square => "boxy" case triangle => "other" } } method tally(s: Shape) returns (res: int) ensures...
midspiral/LemmaScript
examples/division.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
813
1e9aaae108ad2fdd6a8c62591cf85db1a2527a55f67e5ead574e72a2e078d30e
// Generated by lsc from division.ts function JSFloorDiv(a: int, b: int): int requires b != 0 { if b > 0 then if a >= 0 then a / b else -((-a - 1) / b) - 1 else if a <= 0 then (-a) / (-b) else -((a - 1) / (-b)) - 1 } function threeHalves(): real { ((3 as real) / (2 as real)) } ...
midspiral/LemmaScript
examples/filterMap.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
595
4bc7dba8b4b5d7ff7ca5cb0202b5cb4bd2a75a907ffbc2972fb423c8c86c5e99
// Generated by lsc from filterMap.ts datatype Option<T> = None | Some(value: T) function SeqFilterSome<T>(xs: seq<Option<T>>): seq<T> ensures |SeqFilterSome(xs)| <= |xs| { if |xs| == 0 then [] else (if xs[0].Some? then [xs[0].value] else []) + SeqFilterSome(xs[1..]) } datatype In = In(keep: bool, n...
midspiral/LemmaScript
examples/forContinue.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
2,956
5555107019813c2bd999720116f78c4e603ed7300f614fd557b68a03516ca770
// Generated by lsc from forContinue.ts datatype Option<T> = None | Some(value: T) function JSRem(a: int, b: int): int requires b != 0 { var r := (if a < 0 then -a else a) % (if b < 0 then -b else b); if a < 0 then -r else r } datatype Kind = keep | skip | stop datatype Item = Item(kind: Kind) ...
midspiral/LemmaScript
examples/genericExtern.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
289
58294e0036d3ec96b13d9f2b75ca410d3e2ae9646a4782487a6e79af84cab4a5
// Generated by lsc from genericExtern.ts function {:axiom} step<S, A>(s: S, a: A): S function applyTwice<S(==), A>(s: S, a: A): S { var s1 := step(s, a); step(s1, a) } lemma applyTwice_ensures<S, A>(s: S, a: A) ensures (applyTwice(s, a) == step(step(s, a), a)) { }
midspiral/LemmaScript
examples/havoc.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
942
88c5b37d91764aaa548336415218359c58c41ea5fa03938f27e9c176edcf8d41
// Generated by lsc from havoc.ts method countMatches(items: seq<string>, validKeys: set<string>) returns (res: int) ensures (res >= 0) { var count := 0; var i_item_idx := 0; while i_item_idx < |items| invariant (i_item_idx <= |items|) invariant (count >= 0) { var item := items[i_item_...
midspiral/LemmaScript
examples/hof.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
527
1d484ff3e27a23996c699f03f564e028acfda036aedfb745740fe1382f6e124f
// Generated by lsc from hof.ts function doubleAll(arr: seq<int>): seq<int> { Std.Collections.Seq.Map((x: int) => (x * 2), arr) } lemma doubleAll_ensures(arr: seq<int>) ensures (|doubleAll(arr)| == |arr|) { } function positives(arr: seq<int>): seq<int> { Std.Collections.Seq.Filter((x: int) => (x ...
midspiral/LemmaScript
examples/iff.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
676
07a349275280b56a42479d6ca3975f4ba2c3e0d740f45a9c32dba8e668d724f8
// Generated by lsc from iff.ts function JSRem(a: int, b: int): int requires b != 0 { var r := (if a < 0 then -a else a) % (if b < 0 then -b else b); if a < 0 then -r else r } function isEven(x: int): bool requires (x >= 0) { (JSRem(x, 2) == 0) } lemma isEven_ensures(x: int) requires (x >...
midspiral/LemmaScript
examples/inlineHandler.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,683
6efd971e067a92c5b9047bb5b2bfee0951a5b713790afe1103ae6b1f2cafe1b2
// Generated by lsc from inlineHandler.ts type Unknown(==, 0) function StringIndexOf(s: string, sub: string): int ensures StringIndexOf(s, sub) == -1 || (0 <= StringIndexOf(s, sub) <= |s| - |sub| && s[StringIndexOf(s, sub)..StringIndexOf(s, sub) + |sub|] == sub) { StringIndexOfFrom(s, sub, 0) } ...
midspiral/LemmaScript
examples/isSorted.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
757
a455d7b7a5280a055d7086b1d1839de6dea2acb3888313bfd8670e6a307e3e22
// Generated by lsc from isSorted.ts method isSorted(arr: seq<int>) returns (res: bool) requires (|arr| > 0) ensures ((res == true) ==> forall k: nat :: (((k + 1) < |arr|) ==> (arr[k] <= arr[(k + 1)]))) ensures ((res == false) ==> exists k: nat :: (((k + 1) < |arr|) && (arr[k] > arr[(k + 1)]))) { var re...
midspiral/LemmaScript
examples/lambdaFlatten.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
595
9d99b2c52fb276ebacc31ce7a42edf37e3828c53bda866fa1a52b2f72deab952
// Generated by lsc from lambdaFlatten.ts datatype Option<T> = None | Some(value: T) datatype Part = Part(type_: string, providerExecuted: Option<bool>, toolCallId: string) function keepParts(parts: seq<Part>, valid: set<string>): seq<Part> { Std.Collections.Seq.Filter((p: Part) => ((p.type_ != "tool-call"...
midspiral/LemmaScript
examples/leftPad.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
590
e40ad5ab3a6ba425b21921c03f6638f6a1cde1f8d8b5c8f81074110ca80a5ad6
// Generated by lsc from leftPad.ts method leftPad(str: string, len: nat, ch: string) returns (res: string) requires (|ch| == 1) ensures ((|str| >= len) ==> (res == str)) ensures ((|str| < len) ==> (|res| == len)) { var len := len; var result := str; len := (len - |str|); var i := 0; while (...
midspiral/LemmaScript
examples/linearSearch.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
716
0dda3c4b0fa90baf318414f3b1638cb63d008cbaa16f522fde1a0be9add5e9eb
// Generated by lsc from linearSearch.ts method linearSearch(arr: seq<int>, target: int) returns (res: int) ensures (res >= -1) ensures (res < |arr|) ensures ((res >= 0) ==> (arr[res] == target)) ensures ((res == -1) ==> forall k: nat :: ((k < |arr|) ==> (arr[k] != target))) { var i := 0; var resu...
midspiral/LemmaScript
examples/majority.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,438
1144c9a92505d82d75c1e8036f8c4c2178128b1ba17b68e98747a0d21368d5dc
// Generated by lsc from majority.ts function occOf(arr: seq<int>, x: int, n: nat): int requires (0 <= n) requires (n <= |arr|) decreases n { if (n == 0) then 0 else (occOf(arr, x, (n - 1)) + (if (arr[(n - 1)] == x) then 1 else 0)) } method majority(arr: seq<int>) returns (res: int) ...
midspiral/LemmaScript
examples/mapRecord.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
343
8c855187ce191737857df37127930e18878eb2863b7253ece9c9b821917a9cf3
// Generated by lsc from mapRecord.ts datatype In = In(tag: string, n: int) datatype Out = Out(label_: string, doubled: int) function relabel(items: seq<In>): seq<Out> { Std.Collections.Seq.Map((it: In) => Out(it.tag, (it.n * 2)), items) } lemma relabel_ensures(items: seq<In>) ensures (|relabel(item...
midspiral/LemmaScript
examples/maxElement.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
606
3a418940e907ebcbc4c0c594ae34736da0b42f9fbc4bbcff17297134b685a6ed
// Generated by lsc from maxElement.ts method maxElement(arr: seq<int>) returns (res: int) requires (|arr| > 0) ensures forall k: nat :: ((k < |arr|) ==> (arr[k] <= res)) ensures exists k: nat :: ((k < |arr|) && (arr[k] == res)) { var max := arr[0]; var i := 1; while (i < |arr|) invariant (1 ...
midspiral/LemmaScript
examples/maxSpread.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
3,608
8a74dceacd969ce03d66291f126021f4c37a1be1e466056b9150d09799e0ae8b
// Generated by lsc from maxSpread.ts function MathMin(a: int, b: int): int { if a <= b then a else b } function MathMax(a: int, b: int): int { if a >= b then a else b } function MaxOfSeq(s: seq<int>): int requires |s| > 0 ensures forall i: nat :: i < |s| ==> s[i] <= MaxOfSeq(s) ensures exists i: nat ...
midspiral/LemmaScript
examples/nameClash.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
2,801
414aa9362d113f1aa1d82817ecc008f20a21c8b40348423ce835cb9436ac84ec
// Generated by lsc from nameClash.ts function JSRem(a: int, b: int): int requires b != 0 { var r := (if a < 0 then -a else a) % (if b < 0 then -b else b); if a < 0 then -r else r } datatype i_Box' = i_Box'(x: int) function delKey(d: map<string, int>, k: string): map<string, int> { var rest := (...
midspiral/LemmaScript
examples/nestedLoopInvariants.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
537
59a0a22a570fe28a9e2d6b3ce66466968c2414fcc8a163e85b4cb85078acb46d
// Generated by lsc from nestedLoopInvariants.ts method nestedSum(n: int) returns (res: int) requires (n >= 0) ensures (res >= 0) { var acc := 0; var i := 0; while (i < n) invariant (0 <= i) invariant (i <= n) invariant (acc >= 0) decreases (n - i) { var j := 0; while...
midspiral/LemmaScript
examples/nestedPush.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
301
be1c80f5c2f787c3c7807ffdb1e65581d3ad891b0d88d59e4069e5bb0f9081f5
// Generated by lsc from nestedPush.ts datatype Bag = Bag(items: seq<int>) method pushItem(items: seq<int>, v: int) returns (res: seq<int>) ensures (|res| == (|items| + 1)) ensures (res[|items|] == v) { var b := Bag(items); b := b.(items := (b.items + [v])); return b.items; }
midspiral/LemmaScript
examples/nullableArray.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,516
5d0f369f870ce03b7f6b33840e31b77bf26ba67f48d855b597e532fae0bd1780
// Generated by lsc from nullableArray.ts datatype Option<T> = None | Some(value: T) datatype Part = Part(type_: string, toolCallId: string) datatype ArrayOf_Part_Or_string = ArrayBranch(arr: seq<Part>) | NonArrayBranch(val: string) datatype Message = Message(role: string, content: ArrayOf_Part_Or_string) ...
midspiral/LemmaScript
examples/opaqueUnion.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,003
168e1a86fa6675a0698f9b822ddd70c8db9cfb14700fb5dd735906f025efab30
// Generated by lsc from opaqueUnion.ts type Opaque_TextContent_or_ImageContent(==) datatype ArrayOf_Opaque_TextContent_or_ImageContent_Or_string = ArrayBranch(arr: seq<Opaque_TextContent_or_ImageContent>) | NonArrayBranch(val: string) datatype Entry = message(role: string) | custom_message(content: ArrayOf_Op...
midspiral/LemmaScript
examples/packet.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
625
96341b60220d1eea7db595091d8bc92f1244f366b4581114d42242103eb6cc39
// Generated by lsc from packet.ts datatype Packet = syn(seq_: int) | ack(seq_: int) | data(seq_: int, len: int) | fin function nextSeq(state: int, pkt: Packet): int { match pkt { case syn(i_pkt_seq) => i_pkt_seq case ack(i_pkt_seq) => state case data(i_pkt_seq, i_pkt_len) => ...
midspiral/LemmaScript
examples/perm.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,676
af2fa82abe6f1422b2cd32fdd781f658f52f52e99dad7ebba217b46d6bc85f25
// Generated by lsc from perm.ts predicate Perm<T(==)>(a: seq<T>, b: seq<T>) { multiset(a) == multiset(b) } function countOn(xs: seq<bool>): int decreases |xs| { if (|xs| == 0) then 0 else ((if xs[0] then 1 else 0) + countOn(xs[1..])) } lemma countOn_ensures(xs: seq<bool>) ensures (0 <=...
midspiral/LemmaScript
examples/preorder.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
9,923
1e94d652984490ef9c3425feb5d8fed60a26948ba85fe0cefeae94341d6bfcd7
// Generated by lsc from preorder.ts // // Hand-written proof scaffolding for the strong post-condition // `result == preorderTraversal(root)` on the iterative `traverseBasic`. // // Adapted from dafny-aoc-2025/preorder.dfy. The TS-side has the Tree // datatype and the pure `preorderTraversal` / `childStack` he...
midspiral/LemmaScript
examples/readonlyArray.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
432
efda69395871278c04849e016c152f31b24e0e7993624eddd1bf408d9130a0c2
// Generated by lsc from readonlyArray.ts function firstOrZero(xs: seq<int>): int { if (|xs| > 0) then xs[0] else 0 } lemma firstOrZero_ensures(xs: seq<int>) ensures ((|xs| > 0) ==> (firstOrZero(xs) == xs[0])) ensures ((|xs| == 0) ==> (firstOrZero(xs) == 0)) { } function lengthOf<T>(x...
midspiral/LemmaScript
examples/recordIndexByEnum.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,164
b84095570a0d130c181b034c24a3f37b61c25eee06dfa42a741599185d7df3d2
// Generated by lsc from recordIndexByEnum.ts datatype Option<T> = None | Some(value: T) datatype Level = low | medium | high datatype Budgets = Budgets(low: int, medium: int, high: int) datatype OptBudgets = OptBudgets(low: Option<int>, high: Option<int>) function budgetFor(b: Budgets, level: Level): in...
midspiral/LemmaScript
examples/safeSlice.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
998
ee3c4c4a2fe41c3ec8e78b331f8a55c1c4e82d579a8d0e918c342cc376a817ee
// Generated by lsc from safeSlice.ts function NormalizeSliceIndex(n: nat, i: int): int ensures 0 <= NormalizeSliceIndex(n, i) <= n as int { if i < 0 then if n as int + i < 0 then 0 else n as int + i else if i > n as int then n as int else i } function SafeSlice<T>(s: seq<T>, lo: int, hi: int):...
midspiral/LemmaScript
examples/setFromArray.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
423
3ebe6c5c36976e4170679a6b73dd958a68619922ed892b414c762e78e0da6da2
// Generated by lsc from setFromArray.ts function SetFromSeq<T(==)>(s: seq<T>): set<T> { set x | x in s } function dedupSize(arr: seq<int>): int { var s := SetFromSeq(arr); |s| } function member(arr: seq<int>, x: int): bool { var s := SetFromSeq(arr); (x in s) } lemma member_ensures(arr: seq...
midspiral/LemmaScript
examples/sharedDestructorCollision.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
610
db7f6a603219dc91fd44b8322a4e7237e714d70e3a9260cf3d745b9f3870d4dd
// Generated by lsc from sharedDestructorCollision.ts datatype Option<T> = None | Some(value: T) datatype TreeEntry = label_(targetId_label: string) | leaf(targetId_leaf: Option<string>) datatype LabelEntry = LabelEntry(type_: string, targetId: string) datatype LeafEntry = LeafEntry(type_: string, targetId:...
midspiral/LemmaScript
examples/sortBy.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
793
454dad6ed3ab3afddceecde713efc3b94f53a2848cd46aab29b428913567b38c
// Generated by lsc from sortBy.ts function {:axiom} SeqSortBy<T(==,!new)>(s: seq<T>, cmp: (T, T) -> int): seq<T> requires forall a: T, b: T :: cmp(a, b) <= 0 || cmp(b, a) <= 0 requires forall a: T, b: T, c: T :: cmp(a, b) <= 0 && cmp(b, c) <= 0 ==> cmp(a, c) <= 0 ensures multiset(SeqSortBy(s, cmp)) == mult...
midspiral/LemmaScript
examples/spec.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
17,664
25c4fb1ce8e46e6880a580462297f95ca4676a6d1a92de33ede666c451abb13f
// Generated by lsc from spec.ts datatype Option<T> = None | Some(value: T) function JSFloorDiv(a: int, b: int): int requires b != 0 { if b > 0 then if a >= 0 then a / b else -((-a - 1) / b) - 1 else if a <= 0 then (-a) / (-b) else -((a - 1) / (-b)) - 1 } function StringIndexOf(s...
midspiral/LemmaScript
examples/spreadMerge.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
2,245
2d41136886201c98000274e63668623fe4d8490f6b4348fb3e9a15827ebebdb8
// Generated by lsc from spreadMerge.ts datatype Option<T> = None | Some(value: T) datatype Budgets = Budgets(low: int, high: int) datatype Config = Config(retries: Option<int>, timeout: Option<int>) function mergeComplete(base: Budgets, over: Budgets): Budgets { Budgets(over.low, over.high) } lemma...
midspiral/LemmaScript
examples/swap.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
379
b3652ee5585f72ada39afa4f1ba6a617d11a4983a7be8744c3c665e0125a3cec
// Generated by lsc from swap.ts method swap(arr: seq<int>, i: nat, j: nat) returns (res: seq<int>) requires (i < |arr|) requires (j < |arr|) ensures (|res| == |arr|) ensures (res[i] == arr[j]) ensures (res[j] == arr[i]) { var result := arr; var tmp := result[i]; result := result[i := result...
midspiral/LemmaScript
examples/switchEnumField.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
339
ffc25ed3fe896193f75aeba9b157db37de46d1d02b2eb718529cbe3f6aaf6b8c
// Generated by lsc from switchEnumField.ts datatype Tag = read | write | exec datatype Perm = Perm(tag: Tag, level: int) function weight(p: Perm): int { match p.tag { case read => 1 case write => 2 case exec => 3 } } lemma weight_ensures(p: Perm) ensures (weig...
midspiral/LemmaScript
examples/switchFallthrough.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
917
15c742e4260e1cee62e084bc50022544ba5e97c485338f67cef2859c64901fa7
// Generated by lsc from switchFallthrough.ts datatype Tag = a | b | c | skip datatype Item = Item(tag: Tag) method collect(items: seq<Item>) returns (res: seq<int>) ensures (|res| <= |items|) { var out: seq<int> := []; var i := 0; while (i < |items|) invariant (0 <= i) invariant (i <= |...
midspiral/LemmaScript
examples/switchLambda.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
469
f4c1f38b127814b9d29976be95060e56e6ed4b117dfba94291841cf85e03af48
// Generated by lsc from switchLambda.ts datatype Msg = user(text: string) | system(code: int) datatype UserMsg = UserMsg(role: string, text: string) datatype SysMsg = SysMsg(role: string, code: int) function priorities(msgs: seq<Msg>): seq<int> { Std.Collections.Seq.Map((m: Msg) => (match m { case user...
midspiral/LemmaScript
examples/templateConcat.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
609
4d7514e24b4f30da91d9a44a883f5e49393681e2037a0256caca898c2cdaab6a
// Generated by lsc from templateConcat.ts function NatToString(n: nat): string decreases n { var digit := ('0' as int + n % 10) as char; if n < 10 then [digit] else NatToString(n / 10) + [digit] } function IntToString(n: int): string { if n < 0 then "-" + NatToString(-n) else NatToString(n) } ...
midspiral/LemmaScript
examples/todo-domain.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
34,322
0aa0a1136b4d8529efff75361203ce24b1db9f80e20aa0af4c105582d16ae0a0
// Generated by lsc from todo-domain.ts datatype Option<T> = None | Some(value: T) type Unknown(==, 0) method SetToSeq<T>(s: set<T>) returns (res: seq<T>) ensures forall x :: x in s <==> x in res ensures |res| == |s| ensures forall i, j :: 0 <= i < j < |res| ==> res[i] != res[j] { var remaining :=...
midspiral/LemmaScript
examples/toposort.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
9,116
875a6916519993c85acff7be8abd981c3a1978fbf579b7c0d0a508706239f66e
// Generated by lsc from toposort.ts method SetToSeq<T>(s: set<T>) returns (res: seq<T>) ensures forall x :: x in s <==> x in res ensures |res| == |s| ensures forall i, j :: 0 <= i < j < |res| ==> res[i] != res[j] { var remaining := s; res := []; while remaining != {} invariant remaining <= s...
midspiral/LemmaScript
examples/transition.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,112
ccfe60aacaa2f0dd71d20ebaa2611167943b50e1bc058b8f880903bacca51148
// Generated by lsc from transition.ts datatype State = idle | connecting | connected | closing datatype Event = connect | ack | close | timeout function transition(state: State, event: Event): State { if (state.idle? && event.connect?) then State.connecting else if (state.connecting? && event...
midspiral/LemmaScript
examples/trim.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,437
63edbbc14e9e8da65ddf9ae87cc61d29bd39ca4b165585667653e071ecf558ac
// Generated by lsc from trim.ts predicate IsJSWhitespace(c: char) { c == '\U{0009}' || c == '\U{000A}' || c == '\U{000B}' || c == '\U{000C}' || c == '\U{000D}' || c == '\U{0020}' || c == '\U{00A0}' || c == '\U{1680}' || ('\U{2000}' <= c <= '\U{200A}') || c == '\U{2028}' || c == '\U{2029}' || c == '\U{2...
midspiral/LemmaScript
examples/truthiness.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
3,656
058af6148ad9c860085c9c6f1277d7c343c644b16c09d1f77be1066c2279d26a
// Generated by lsc from truthiness.ts datatype Option<T> = None | Some(value: T) function boolCond(b: bool): int { if b then 1 else 0 } lemma boolCond_ensures(b: bool) ensures (b ==> (boolCond(b) == 1)) ensures (!(b) ==> (boolCond(b) == 0)) { } function numCond(n: int): int { ...
midspiral/LemmaScript
examples/tuples.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,163
289e3f89ef8159f1f67b5bc0991176364c694148b9555a4e26beca91c31a861f
// Generated by lsc from tuples.ts function swap(p: (int, string)): (string, int) { (p.1, p.0) } lemma swap_ensures(p: (int, string)) ensures (swap(p).0 == p.1) ensures (swap(p).1 == p.0) { } function middle(t: (int, string, bool)): string { t.1 } lemma middle_ensures(t: (int, string, bool...
midspiral/LemmaScript
examples/unionInArray.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
491
f77e821574b357609cd09d11cb15c8887ae575627d22255a360de8520b8ead17
// Generated by lsc from unionInArray.ts datatype Shape = circle(r: int) | rect(w: int, h: int) function area(s: Shape): int { match s { case circle(i_s_r) => ((3 * i_s_r) * i_s_r) case rect(i_s_w, i_s_h) => (i_s_w * i_s_h) } } function shapes(): seq<Shape> { [circle(2), rec...
midspiral/LemmaScript
examples/zigzag.dfy
MIT
69
main
9307dce1b1b140d3bc08f77d333beea00d2ed792
2026-07-22T00:07:48Z
1,056
990a5348223ddd726183ed52ef290e6bd2e4b39d62b340a789a26db88ef70872
// Generated by lsc from zigzag.ts function JSFloorDiv(a: int, b: int): int requires b != 0 { if b > 0 then if a >= 0 then a / b else -((-a - 1) / b) - 1 else if a <= 0 then (-a) / (-b) else -((a - 1) / (-b)) - 1 } function JSRem(a: int, b: int): int requires b != 0 { var r :...
microsoft/verified-storage
capybaraNS/src/Framework/ExternalMethods_t.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
4,447
70103e046199ba89386a0394cb9207683c037cbe10c9b2f5ebc26a5c19dee272
include "NativeTypes_t.dfy" include "PersistentMemory_t.dfy" module ExternalMethodsModule { import opened NativeTypesModule import opened PersistentMemoryModule class ExternalMethods { static method {:axiom} {:extern} SerializeUint64(value: uint64, outputBuffer: array<byte>, start: int32) requir...
microsoft/verified-storage
capybaraNS/src/Framework/NativeTypes_t.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
1,416
c56f77cdb7334e5e0d9b52fdb0177584f5f67de0efa0268e5a2cd58fec01c900
module NativeTypesModule { newtype{:nativeType "sbyte"} sbyte = i:int | -0x80 <= i < 0x80 newtype{:nativeType "byte"} byte = i:int | 0 <= i < 0x100 newtype{:nativeType "short"} int16 = i:int | -0x8000 <= i < 0x8000 newtype{:nativeType "ushort"} uint16 = i:int | 0 <= i < 0x10000 newtype{:nativeType "int"} int32 =...
microsoft/verified-storage
capybaraNS/src/Framework/PersistentMemory_t.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
9,153
09cd761f70483241de7eb682940e4a100743468cfad1a8309411fc164539fccc
include "NativeTypes_t.dfy" module PersistentMemoryModule { import opened NativeTypesModule ghost predicate MaybeCorruptedByte(read_value: byte, true_value: byte, addr: int) ghost predicate AllElementsUnique(s: seq<int>) { forall i: int, j: int :: 0 <= i < j < |s| ==> s[i] != s[j] } ghost predicat...
microsoft/verified-storage
capybaraNS/src/Framework/PmemUtil_v.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
6,288
72444985e580735b3e4c7d8332a5b0aac5149bb47ef1c0478c37c69fbde31e08
include "NativeTypes_t.dfy" include "PersistentMemory_t.dfy" module PmemUtilModule { import opened NativeTypesModule import opened PersistentMemoryModule ghost function ExtractBytes(s: seq<byte>, start: int, length: int) : seq<byte> requires 0 <= start requires 0 <= length requires start + lengt...
microsoft/verified-storage
capybaraNS/src/NotaryServer/Advance_v.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
13,688
a13ae0c07a2f7c5152b18cf0853337e252d2767d8f2846ba1bc61d21867a6944
include "../Framework/ExternalMethods_t.dfy" include "../Framework/NativeTypes_t.dfy" include "../Framework/PersistentMemory_t.dfy" include "../Framework/PmemUtil_v.dfy" include "Layout_v.dfy" include "NotarySpec_t.dfy" include "Util_v.dfy" module NotaryAdvanceModule { import opened ExternalMethodsModule imp...
microsoft/verified-storage
capybaraNS/src/NotaryServer/Layout_v.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
4,473
92190339d70e08989811664b3403ebabb92b3d23ec0f4ee7111009341ba1f758
include "../Framework/ExternalMethods_t.dfy" include "../Framework/NativeTypes_t.dfy" include "../Framework/PersistentMemory_t.dfy" include "../Framework/PmemUtil_v.dfy" include "NotarySpec_t.dfy" module NotaryLayoutModule { import opened ExternalMethodsModule import opened PersistentMemoryModule import opene...
microsoft/verified-storage
capybaraNS/src/NotaryServer/NotarySpec_t.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
4,819
92f41d3a435ee53fa527d6dc715f8292844c98f479980fc926df9dcfed031ea4
/// This file contains the trusted specification of the notary /// service. Since it's a trusted file, an auditor must read and check /// it; it's not sufficient to just verify it. The file describes the /// abstract state of the notary service, its legal initial states, /// and the semantics of each function in th...
microsoft/verified-storage
capybaraNS/src/NotaryServer/Setup_v.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
4,617
c1c16ac3da771d9010089629f2eb92e03864837ff1a6ae9ac7feabf7516199eb
include "../Framework/ExternalMethods_t.dfy" include "../Framework/NativeTypes_t.dfy" include "../Framework/PersistentMemory_t.dfy" include "../Framework/PmemUtil_v.dfy" include "Layout_v.dfy" include "NotarySpec_t.dfy" module NotarySetupModule { import opened ExternalMethodsModule import opened PersistentMem...
microsoft/verified-storage
capybaraNS/src/NotaryServer/Start_v.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
16,055
404275baefaeedf2c89bc57143050caea01a31b915dddc76e0ca5ea20bfe16d0
include "../Framework/ExternalMethods_t.dfy" include "../Framework/NativeTypes_t.dfy" include "../Framework/PersistentMemory_t.dfy" include "../Framework/PmemUtil_v.dfy" include "Layout_v.dfy" include "NotarySpec_t.dfy" include "Util_v.dfy" module NotaryStartModule { import opened ExternalMethodsModule impor...
microsoft/verified-storage
capybaraNS/src/NotaryServer/TrustedNotary_t.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
12,472
fc4938bfc6a687d942cfac3c9fcdb6b1fd926adee461baef85db916e4c7f446b
/// This file contains the trusted interface `TrustedNotary` of the /// notary service. Since it's a trusted file, an auditor must read /// and check it; it's not sufficient to just verify it. /// /// To use the trusted notary from C#, compile this Dafny code to C# /// then invoke the `TrustedNotary` methods from ...
microsoft/verified-storage
capybaraNS/src/NotaryServer/UntrustedNotary_v.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
28,008
9b35805479a78407cde333f373cb7eb572f3c436cfa7968d8aa4cff42c4b283d
/// This file contains the implementation of `UntrustedNotary`, i.e., /// the main logic for the notary server. It's untrusted in that it /// doesn't have to be read by the auditor to be sure of the notary's /// correctness; the fact that it passes verification is sufficient. /// /// It's invoked by `TrustedNotary...
microsoft/verified-storage
capybaraNS/src/NotaryServer/Util_v.dfy
MIT
68
main
6febb204980f5d594219d284d2bf62a311ce0386
2026-06-15T20:28:27Z
5,790
19f7ddc2097044f7c91862db0064c869afd1b22f7a94cdb82940251ee7962ff5
include "../Framework/ExternalMethods_t.dfy" include "../Framework/NativeTypes_t.dfy" include "../Framework/PersistentMemory_t.dfy" include "../Framework/PmemUtil_v.dfy" include "Layout_v.dfy" include "NotarySpec_t.dfy" module NotaryUtilModule { import opened ExternalMethodsModule import opened PersistentMemo...