Skip to content

Releases

Quod 0.7.1

Choose a tag to compare

@github-actions github-actions released this 14 Nov 19:11

Quod 0.7.1: three fixes found by the first human trial of 0.7.0 (a prime-number program with a console prompt). Nothing else changes.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md.

Fixed

  • Python: a block left empty by erased proof steps. if x > 0 { lemma(x); assert ...; } generated an if with no statement, which Python refuses to load (IndentationError) while quod_build said built: true. Such a block now holds pass.
  • A function that ends by calling itself after a let. let r = read_line(c); match r.1 { None => r.0, Some(_) => f(r.0) } was not run as a loop, as the reference says it is, and overflowed the stack after a few hundred calls. A body of statements whose last one returns the tail call now runs as a loop, as a body of one expression already did.
  • A loop that reads the console was refused. The pair let r = console.read_line(d) declared in the body counted as a console used and not handed back, though d = r.0 handed it back, so no loop could read the console. What a turn declares is forgotten at its end.

Measured

  • Tests: 297, all passing; 3 were added, one per fix.

Quod 0.7.0

Choose a tag to compare

@github-actions github-actions released this 14 Nov 13:39

Quod 0.7.0: files, as a capability, and maps that hold strings in C#. Nothing changes for a program that imports neither files nor uses a map of strings in C#.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

A program

import files
import option

fn copy(f: files.Files, from: string, to: string) -> files.Files
  requires from != to
  ensures from in files.contents(f) ==> files.contents(result) == put(files.contents(f), to, files.contents(f)[from])
  ensures !(from in files.contents(f)) ==> files.contents(result) == files.contents(f)
{
  let r = files.read_file(f, from);
  let g = r.0;
  match r.1 {
    None => g,
    Some(text) => files.write_file(g, to, text),
  }
}

quod run copy.quod --function copy needs a main; examples/files/backup.quod is one that reads notes.txt and writes notes.bak, with a console to say what it did: quod run examples/files/backup.quod --files DIR.

Added

  • The files module of the standard library. files.Files is a capability, like the console of 0.6: a function reads and writes files only through a Files it receives, used once, which a program cannot build and whose model it cannot read in code. files.read_file(f, path) returns the next Files and an option.Option<string> (None if there is no such file), files.write_file(f, path, text) and files.delete_file(f, path) return the next Files. In a contract, files.contents(f) is a map<string, string> from path to text, and the operations are specified by it: contents(result) == put(contents(f), path, text) for a write, remove(contents(f), path) for a delete. What the files hold when the program starts is any map. As for the console, a contract has to say what becomes of the files, or the completeness check says that two results are possible.
  • Rooted in a directory. The real Files is rooted in a directory chosen by whoever runs the program: files.Files(root) in Python, new FilesModule.Files(root) in C#, --files DIR in quod run. A path that is empty, absolute or that leaves the root (..) is refused (ValueError, ArgumentException). Text is UTF-8, read and written with no change of its line ends.
  • quod run file.quod --files DIR loads the files under DIR (at most 1000 files of 1 MB, all UTF-8) into the model, runs main (any capabilities in, the same ones out, as a tuple when there are several), then writes back to DIR what the program changed or deleted, when it ends. quod_run (MCP) takes a Files as an object from path to text ({} for none) and returns the files that result.
  • C#: strings, and lists of numbers or booleans, as values of a map. map<string, string> and map<string, seq<int>> are generated: until now only integers, booleans, tuples, structs, enums, maps and sets could be values. A string is a C# string inside the map, as a key is, and a list is held as it is; a map compares its values by content. Not yet: a char, a list of strings or of lists, as a value.

Fixed

  • A private fn that only contracts call is no longer generated. It had no use in the generated code, and it could stop it: a helper over a map<string, string> used by a contract only made the C# refuse the program (found by an agent trial). A private function that code calls, however indirectly, is kept, and nothing is left out when --runtime-checks makes the contracts that were not proved run with the code.

Known

  • The same restrictions as the console. A contract on a function that has a Files must say what becomes of the files. The model has no directories, no permissions, no other program changing the files meanwhile; a write that fails for the disk (full, a path that is a directory, a file that is not UTF-8) raises an error, which is outside what is proved.
  • quod run --files loads the whole directory, and writes back at the end, not as the program goes. The generated Python and C# act on the disk as they go.
  • In C#, a char and a list of strings are still refused as map values, and sorted of structs is not generated. A caller must not change a map, a set or a list it passed, or one it received.
  • A lone surrogate in a C# string that a caller puts in a map is not rejected where it enters, but when the program first reads it as text (an ArgumentException), as for a key.
  • The MCP server of a build that is not native sometimes fails to start under an agent runner (5 runs of 12 lost in the file trial): use the native binary.

Measured

  • Tests: see the commit; 3 on files and 1 on private helpers were added to those of 0.6, and 2 on the C# values of maps.
  • An agent trial on files (claude-haiku-5-5, copy_file and append_line, 0.147 USD for 12 runs, 5 lost to the MCP server): copy_file 3 of 3 verified and passing, append_line 2 of 2 verified and passing once the wording was right (the first wording was ambiguous, and the agents followed the sentence: reported in the report); every contract says what becomes of the files.

Quod 0.6.0

Choose a tag to compare

@github-actions github-actions released this 13 Nov 17:16

Quod 0.6.0: the console, as a capability. A program can now write and read lines, and a contract says what it writes and what it leaves to read. Nothing changes for a program that does not import console.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

A program

import console

fn main(c: console.Console) -> console.Console
  ensures console.written(result) == console.written(c) + ["Hello from Quod", "this line was proved"]
  ensures console.pending(result) == console.pending(c)
{
  let a = console.say(c, "Hello from Quod");
  console.say(a, "this line was proved")
}

quod run hello.quod checks the file, then runs main and prints the two lines. examples/console/echo.quod reads a line and says what it read, or that there was none, with a contract that is proved and determines its result.

Added

  • The console module of the standard library. console.Console is a capability: a function writes only through a Console it receives, so a function that has none among its parameters cannot write, and its signature says so. console.say(c, line) writes the line and returns the next Console. In a contract, console.written(c) is the sequence of the lines written so far and console.pending(c) the lines still to be read, and the operations are specified by them: say gives written(result) == written(c) + [line], and read_line returns None when pending(c) is empty and Some(pending(c)[0]) otherwise, with the rest of pending left. The proofs rest on that model; the real console is not verified, and what the one who runs the program gives to read is any sequence of lines.
  • A Console is used once. let d = console.say(c, "a") consumes c, and naming c again is an error: otherwise written(c) would speak of a console that no longer exists, and the proof would be false. Each branch of an if or a match may use it; a loop that uses one must end each turn by assigning the one it went on with (d = console.say(d, ...)). A program cannot build a Console, read its lines in code, or keep one in a sequence, a map, a set, a field or a type argument; it passes it on or returns it, alone or in a tuple.
  • console.read_line(c) returns a pair: the next Console and an option.Option<string>, None when there is nothing left to read. Both parts of the pair are used once, like any Console.
  • The completeness check covers what is written, and what is left to read. A contract that says only how many lines a function writes is refused, as one that says only the length of a result is: ensures len(console.written(result)) == len(console.written(c)) + 1 accepts any line. A contract that does not say what the function does to pending leaves two results possible: a program that only writes says console.pending(result) == console.pending(c).
  • quod run file.quod [--function NAME] checks the program, then runs main(c: console.Console) -> console.Console with the evaluator and prints the lines written, at the end of the run. What it reads is the standard input, taken whole before the run (nothing when it is a terminal). It needs neither Python nor .NET.
  • quod_run (MCP) takes a console as the array of lines already written ([] for a new one), or as {"written": [...], "input": [...]} to give lines to read, and returns the lines written.
  • Python: console.Console() uses the standard output and input, console.Console(stream, source) any text streams (a test gives io.StringIO objects); console.say and console.read_line return the same object. C#: new ConsoleModule.Console() or new ConsoleModule.Console(textWriter, textReader); ConsoleModule.Say and ConsoleModule.ReadLine return the same object. The Option module is generated next to them, since read_line returns one. The module is written by Quod next to the generated files, not generated from console.quod.

Fixed

  • A proof with a string literal of 12 characters or more could take 25 seconds or give up. A literal was a chain of concatenations, one per character, and the solver unfolded them all when two lines were compared (written(result) == written(c) + [a, b]). A long literal is now a constant of the proof, with its length and its characters: the same proof takes a second. This applies to every program with long strings, not only to the console. Short literals are unchanged.

Known

  • The console only. No files, no network yet: files come next (the model of a file system will be a map<string, string>). A line is read whole; there is no way to read a character, or to know whether more input is coming without trying.
  • quod run runs the program with the evaluator, which is slow on big loops, and prints the lines when the run ends, not as they are written: a program that asks a question and waits for the answer cannot be run interactively with it (the generated Python and C# do). The generated Python and C# write as they go.
  • The model of the console is two lists of lines. It says nothing of a console that fails (a closed pipe), of two processes writing together, or of the encoding of the input and the output. Every contract of a function that has a console has to say what happens to pending, which is one more line to write; a loop that writes lines proves in about twenty seconds, mostly because of the quantified invariants on sequences of strings (the order of the invariants mattered).
  • Without the sugar of a mut parameter, a program that writes much repeats let c2 = ...; whether to add it will be decided on programs written with this form.
  • No agent has written a program with a console yet: whether the rule of use-once costs agents anything is not measured.
  • The Console of the C# module is a class over a TextWriter, not an interface; a test substitutes a StringWriter.
  • Sealed contracts and general refinement types, announced for 0.6, move to 0.7.

Measured

  • 286 tests pass, among them 15 on the console and 2 on long literals.
  • An agent trial on the console (claude-haiku-5-5, two easy tasks, 3 trials each, 0.08 USD in all; report): 6 of 6 verified, 6 of 6 pass the hidden tests, 6 of 6 generate C# that compiles, and all 6 contracts say what they do to pending. The reference tells them to, so this measures that they follow it. One run was started again because the MCP server did not connect.
  • Mutants, on a Release build (15 per file, a larger sample than in 0.5, so the counts are not comparable): the reference programs, 81 refuted of 88 (2 rejected without a hint, 5 survived); the quantified requires, 13 of 15; the dictionaries, 11 of 11. The two rejected without a hint (merge_intervals, 13 and 17 s) give the same verdict on 0.5.0: they are not new. Slowest check to reject a mutant: 107 s (a program of the bench, on a build that is not AOT).

Quod 0.5.0

Choose a tag to compare

@github-actions github-actions released this 12 Nov 10:34

Quod 0.5.0: maps and sets. map<K, V> and set<T> are finite and immutable, proved by the solver, and generated for Python and C#. Nothing changes for a program that does not use them.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

A program

fn bump(m: map<int, nat>, k: int) -> map<int, nat>
  ensures k in result
  ensures result[k] == (if k in m { m[k] + 1 } else { 1 })
  ensures forall j in keys(result): j == k || j in m
  ensures forall j in keys(m): j != k ==> j in result && result[j] == m[j]
{
  put(m, k, if k in m { m[k] + 1 } else { 1 })
}

Added

  • map<K, V> and set<T>, equal by their entries whatever the order they were built in. Keys and elements are of an ordered type: the integers, char, bool, string, and the tuples, structs and enums made of those. Values are of any type. Design note (in French) and the reference.
  • Operations as functions, no new syntax but two: map_of([(k, v), ...]) and set_of([...]) (a list written in place), put, remove, add, keys, union, inter, diff, subset, len. m[k] reads, with the proof obligation k in m; k in m and x in s are booleans.
  • forall x in s and exists x in s in contracts, over a set (for a map, keys(m)). Until now a quantifier ran over an interval a..b only.
  • sorted(s) and sorted_keys(m), the one way to walk a collection in code: a sequence in ascending order, which a while loop reads by index. No result depends on the order of insertion or of a hash. For numbers and chars the solver knows the order. An enum can be a key but is not sorted.
  • The completeness check works on maps: a contract on a map result that leaves two results possible is refused, with the two maps as the witness.
  • import maps: get_or, count_up and merge, written in Quod and proved with the program.
  • Linear loops: m = put(m, k, v) and s = add(s, x) on a local that nothing else sees change it in place, in Python and in C#.
  • Python: a dict and a frozenset. C#: IReadOnlyDictionary<K, V> and HashSet<T>; a string key is a C# string.
  • quod_run takes a map as an array of [key, value] pairs and a set as an array.
  • The search for counterexamples is bounded in work (review of 0.5.0). The check runs each function on small inputs, and tries each integer constant of the program as the value of each integer parameter; a constant such as 2147483647, written anywhere, made a loop elsewhere run for a million statements, again and again, and with a map in the loop the check lasted minutes. A run is now cut after 100,000 statements (a change to a map or a set counts for one statement in eight of its entries), the constants may spend 600,000 in all, and the other inputs 1,400,000. These are counts, not seconds: the same file gets the same verdict. A program of nine lines that took 62 s takes 2 s.
  • Two messages: a in s == true says that in does not chain, and a function of the program named like an operation on maps (put, sorted...) says that it hides the operation. A null map or set given to a C# method raises ArgumentNullException.

Known

Those of 0.4.2.

  • In C#, keys and elements are integers, booleans, strings, tuples of numbers and booleans, structs and enums. Values are integers, booleans, tuples of numbers and booleans, structs, enums, maps and sets: not strings, char or sequences. Anything else, and a struct or an enum that holds a map or a set, is refused by Quod when it generates the C#. sorted is generated for numbers, booleans, strings and tuples of numbers and booleans, not yet for structs.
  • In C#, a set is a HashSet<T>, which is changeable, and a set or a map a caller passes is used as it is, not copied: a method that keeps a HashSet of the caller's in the dictionary it returns shares it with the caller. A caller must not change a map or a set it passed, nor one it received.
  • remove(m, k) and k in m need k to be of the key type: on a map<nat, V>, a key of -1 is an error, where removing an absent key would have a meaning.
  • The size of a collection built in a loop is where proofs are hard: a counting loop whose invariant compares with a recursive occurrences(words[..i], w) did not prove within the limit. A loop that builds a map or a set with simple invariants proves in a fraction of a second.
  • The completeness of a contract that spells out the order of sorted is not decided within the limit (a warning, not an error).
  • No traversal in order of insertion, no iteration over a map other than by its sorted keys, no enum order: by design.

Measured

  • All 271 tests of the compiler pass.

  • The mutant benches, on a Release build: the 64 mutants of the reference programs give the verdicts of 0.3 (57 refuted with a counterexample, 7 survivors, all equivalent mutants), and the 31 of the quantified requires give 29 refuted, 1 rejected without a hint and 1 survivor (30 mutants and 28 refuted in 0.3). A new bench of 22 mutants of a program on maps, sets and sorted: 22 refuted with a counterexample (the slowest in 25 s). The slowest check of the reference programs took 80 s (68 s in 0.3; 126 s before the search for counterexamples was bounded in work).

  • No agent trial, and no comparison with other tools, was done for maps and sets.

  • Not run: macOS and Linux binaries (built by CI only).

Quod 0.4.2

Choose a tag to compare

@github-actions github-actions released this 11 Nov 12:57

Quod 0.4.2: a failed loop invariant is named by its text, not only by its number.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

Changed

  • The message of a failed invariant shows the invariant. A newcomer who ran max_index_bug.quod read "invariant #1 is preserved by the loop body" and had to count lines to find which one. The message is now
    invariant #1 1 <= i && i <= len(xs) is preserved by the loop body, in the verifier and in the evaluator that finds counterexamples by running the function. The number stays, so a message is still found by its start. The JSON field property carries the longer text.

Nothing else changes: the verifier, the proofs and the generated code are those of 0.4.1.

Around the release (not part of the package)

  • The README says what Quod cannot do yet and what is planned (input and output as capabilities, maps and sets), what was measured, and how to run it on each system.
  • A smoke test downloads a published release on clean Linux, macOS and Windows machines and plays the quick start. Run on 0.4.1, it passed on Ubuntu 22.04, Ubuntu 24.04, macOS 15 and Windows.
  • A form "First try" in the Discussions, for the report of a first use.

Known

Those of 0.4.1.

Quod 0.4.1

Choose a tag to compare

@github-actions github-actions released this 10 Nov 13:25

Quod 0.4.1: fixes from the review of 0.4.0. The Euclidean division in C# no longer throws where its result fits a long; a constant beyond long is refused by Quod; the limits depend less on the load of the machine, and a budget that runs out reports "not attempted", never a failed proof.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

Fixed

  • C#: / and % on int no longer throw when the result fits a long. _quod_mod(-1, long.MinValue), _quod_div(long.MinValue, 3) and _quod_div(-7, long.MinValue) raised OverflowException (an intermediate overflowed). They now use the form that does not overflow, as i32 and i64 already did; only long.MinValue / -1 throws. No wrong value was ever returned: 2009 edge cases of the review gave none.
  • C#: a constant beyond long is refused by Quod (not built: the literal 9223372036854775808 does not fit a long ...). It already failed to compile, with ulong messages of the C# compiler that did not name Quod.
  • A budget that runs out never gives a failed proof. When --budget (60 s by default through MCP) cut the limit of an obligation and the solver did not answer, the obligation was reported as not proved, a result that depended on the load. It is now counted as not attempted, and the diagnostic says the budget was used up. The wall-clock limit that follows the budget is exactly what is left of it.
  • The wall-clock limit of an obligation is 16 times its limit in solver operations, not 4 (review of 0.4.0, H3). On 2 cores, 9 of 14 builds of a published solution failed when run at once with 0.4.0. It is there only against a check that never ends. With 0.4.1, 40 builds at once of that solution on a 16-core machine all verified. With --budget 60, 20 builds at once gave the same answer each time: 117 obligations proved and 31 reported not attempted because the budget was used up, none as a failed proof.
  • The comment of the C# overload for int lists no longer says that the list is not copied.
  • The release notes of 0.4.0 said a verdict "no longer depends on the load"; it depends much less. Fixed in the repository, not on the page of that release.
  • The dead code that still emitted BigInteger fields is removed.
  • Reserves on the times of T9 and T10, and a note on T11 (its counts of BigInteger describe 0.3.2). The design note of the C# backend now describes long in checked.

Known

Those of 0.4.0.

  • The verdict can still depend on the load if a check meets the budget (--budget), which is wall time by nature: the obligations it cuts are reported not attempted, but which ones depends on the speed of the machine. The wall-clock limit of 16 times is not removed, only widened.
  • Names that compile in Quod and not in C#, each refused by the C# compiler, never silently wrong: a root type named like a module (Option and option.Option<int>), a module named system (its class hides the System namespace), an enum case named Match (it meets the helper method).
  • copy.deepcopy and pickle of Quod data in Python raise TypeError.
  • Not run: macOS and Linux binaries (built by CI only).

Quod 0.4.0

Choose a tag to compare

@github-actions github-actions released this 10 Nov 12:19

Quod 0.4.0: the generated C# no longer uses BigInteger; a verdict no longer depends on the load of the machine; two modules that would collide in C# are refused. Breaking for C# callers.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

Changed

  • C#: Quod's int and nat are a long, computed in checked. No BigInteger is left in the generated code or in its signatures. Beyond about 9.2e18 an operation raises OverflowException: never a wrong result, but the proof, which is mathematical, did not foresee it. For a guarantee, use i64 (or i32): the verifier then proves that no operation leaves the bounds. Callers that passed a BigInteger must change.
  • Limits are counts of z3 operations, not times (review of 0.3.2, H3). A published solution failed 5 builds of 5 when run at once: the verdict depended on the load. Each limit in ms is now an rlimit of 4000 operations per ms; the time limit stays 4 times wider, against a check that never ends. QUOD_RLIMIT_PER_MS sets the rate. On 106 programs, no verdict changed but one proof that is now found (T7 next_permutation, quod-mcp #1). The whole-check budget (--budget) is still wall time.
  • Two modules that would be one C# class or file are refused (review of 0.3.2, H1): a_b and aB both gave the class AB, and the code could contradict a proof.
  • The reference and the specification say what int is in C# and point to i64.

Known

Those of 0.3.2.

  • int in C# can overflow. In the billing program with a discount shared in proportion, 4 orders of 235 raise OverflowException on discount * net, from a subtotal of tens of millions of euros. With i64 the verifier refuses the product until net is bounded. A verifier warning for an int product that may exceed long is not done.
  • The claims of T9 to T11 on time are not to be read as medians that mean anything: they were measured under a wall-time limit that depended on the load.
  • Not run: macOS and Linux binaries (built by CI only).

Quod 0.3.2

Choose a tag to compare

@github-actions github-actions released this 06 Nov 14:21

Quod 0.3.2: the reference now tells an agent to keep its helpers private. Neither the verifier nor the generated code changes: only the text of the reference, which agents read through quod_reference.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

Changed

  • The reference recommends private fn for helpers. What is public is the API of the generated code, and in C# a helper over int shows a BigInteger there.

Measured

  • T9, a billing engine of about 300 lines over three modules, written by Haiku and Sonnet from a specification on 0.3.1: 12 of 12 verified and pass a separate oracle on 436 orders, 6 of 6 on 235 orders in C# on .NET Framework 4.7.2. i64 costs failed proofs (38 against 7 with int), and not money.
  • T10, the same with a discount shared in proportion, a product of variables: 12 of 12 again. The ceiling was not reached. The rules, the oracle, the tests and the compiler have one author, and one product is not a hard case.
  • T11, on this version: all 6 runs made helpers private, against none of 6 before. Public methods with a BigInteger fall from 19 to 30 down to 0 to 17, and nothing else moved.
  • All compiler tests pass. The mutant benches were not rerun: neither the verifier nor the generated code changes.

Known

Those of 0.3.1.

  • A helper called from another module must stay public: Quod has no visibility in between. The BigInteger of hidden helpers leave the API, not the generated code.

Quod 0.3.1

Choose a tag to compare

@github-actions github-actions released this 06 Nov 09:47

Quod 0.3.1: what the first agents to write 0.3 ran into. No proof changes: a program that compiled gives the same verdicts, and only the C# class of a file that holds a type of its own name changes.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

Fixed

  • C#: a type named like its file. struct Money in money.quod was proved, and its C# did not compile. The class of the file is now MoneyModule, and the type MoneyModule.Money.
  • Ok where option.Ok is meant. The message now gives the full name of a case of an imported module.
  • A literal in the cases of a match takes the bounded type its context wants, as in the branches of an if: let p: i32 = match c { Regular => 0, Staff => 30 }; needed to_i32.

Measured

  • An agent on the features of 0.3, on 0.3.0: Haiku wrote 12 small tasks 3 times each from the reference alone. 36 of 36 verified and passed hidden tests, and 33 of 36 compiled in C#. No cost of i32 against int could be seen, on tasks this small. They are easy, and the contracts were not measured: this says the features can be written, not that they hold on a real program.
  • All compiler tests pass. The mutant benches were not rerun: no proof changes.

Known

Those of 0.3.0, except the above.

  • A function whose body is made of statements cannot be used in a contract, and that includes strings.find: a contract needs a function of a single expression.
  • i32 * i32 stays i32 when an int is expected, and must fit: let q: int = x; widens first.

Quod 0.3.0

Choose a tag to compare

@github-actions github-actions released this 06 Nov 08:11

Quod 0.3: a language for business rules. Modules, strings with a library written in Quod, i32 and i64, structs, enums, match and generics.

This is a lot of new code at once, and no agent has written with it yet: treat it as a first version. A program that uses none of it gives the same diagnostics and generated code as 0.2, except where listed below.

Install

As for 0.1.0: download the package for
your system, unpack it, and run quod from that folder (z3 4.12.1 is inside). On macOS, run
xattr -d com.apple.quarantine quod z3 in the folder first. The MCP server:
claude mcp add quod -- /path/to/quod mcp, or see
docs/mcp.md. Quod.Build, attached, is a NuGet package:
see its README.

New

import strings

struct Candidate {
  value: string,
  confidence: i32,
}

enum Decision {
  Accepted(value: string),
  Rejected(reason: string),
}

fn decide(c: Candidate, keep: i32) -> Decision
  ensures match result {
    Accepted(v) => v == strings.trim(c.value) && c.confidence >= keep,
    Rejected(r) => r == "too low" && c.confidence < keep,
  }
{
  if c.confidence >= keep { Accepted(strings.trim(c.value)) } else { Rejected("too low") }
}
  • Modules. A file is a module. import name; a function of another module always has its full name; private fn. Everything imported is verified with the program, every time.
  • char and string. A string is a sequence of Unicode scalar values, the same in every backend. Nothing is normalized, and nothing depends on a locale.
  • A standard library in Quod, proved with your program: import strings and import option.
  • i32 and i64. In code, an operation that leaves the bounds is a proof not met, with a counterexample. In contracts, arithmetic is mathematical. In C#, they are int and long.
  • struct, enum, match. A match covers every case. In C#, immutable classes equal by value, with IEquatable<T>, == and a hash on what they hold, which copy the lists they are given and hand out views that cannot be cast back; an enum has a Match with one function per case, so a C# caller can be held to every case too. In Python, frozen dataclasses.
  • Generics, by copies: a generic function is checked and proved for the types it is used with. A type cannot hold itself: no recursive types yet.
  • run_by: contracts read a definition by recursion, and code runs a loop proved equal.
  • A tail call runs as a loop, in Python and in C#, in an if, a &&, a || or a match, whatever the length of the input.

The reference describes them all.

Changed

  • An expression function that ends by calling itself is generated as a loop, so its generated code changes, not its verdict. A stack overflow on a deep input no longer happens for it.
  • A C# method whose name would be that of a type gets Of, and a double underscore in a function's name keeps an underscore in its C# name.

Measured

  • All compiler tests pass.
  • Mutant bench: 57 of 64 mutants refuted, none unconfirmed or without a hint, the 7 survivors equivalent, none hung; quantified.quod 28 of 29. No verdict changed from 0.1.8, the last run of this bench before this version.
  • On the library: 39 of 40 mutants of strings.quod refuted with a counterexample, the last rejected without one, none survived.
  • On 42 programs of this repository written before these features, compared with 0.2.0: the same exit codes and generated code; 2 differ in the wording of one diagnostic, a proof given up on its time limit. This comparison came before the tail calls.
  • Python and C# on .NET Framework 4.7.2 gave the same answers on hand-written programs: accents, combining accents, emoji, lone surrogates refused, overflows at the bounds, Euclidean division, three modules, generics.
  • Three outside reviews of this version ran 4750 cases through the evaluator, Python and C# (on .NET 10) on the new types, with no difference, and tried to break the rules. The first two found false proofs and generated programs that contradicted a proof, all fixed here, with their programs as tests:
    • an assumption on lengths, reopened by a one-line lemma after a first fix, and false in Python: it is gone, and to_i32(len(xs)) now needs a requires;
    • a run_by that could require more than the function it runs for;
    • with --runtime-checks, a function proved by relying on one that was not: it is now checked too;
    • a function named like a copy of a generic, which captured its calls: two underscores in a row are now reserved;
    • in Python, a function named ord or divmod that the generated code would call, and class_ next to class;
    • a seq<nat> inside a struct, not checked when built;
    • int.MinValue % -1, which throws in .NET.
      That such faults took two sessions says how little this new code had been attacked before. What they attacked without success is listed in their reports: the axioms of sequences, the helpers of bounded division, tail calls, chars and strings.
  • The third review found no false proof in the default build. It found, all fixed here with their programs as tests:
    • in Python, a parameter or a local named like a case or a struct, which hid its class: a function proved true returned False;
    • in Python, a list read from a struct, which a caller could change under a proof: it now refuses to change;
    • with --runtime-checks, what a type promises was not checked (x * 1000 wrapped in C#, shrink(0) returned -1), and neither were the requires of a proved function called from an unproved one;
    • a generic struct did not compile in C#.
      It attacked without success: the completeness of enums and tuples, the copies of generics (requires, decreases, their use across modules), private, the state of the C# generator under MCP.

Known

  • No measure with agents. Whether an agent writes these features well, and whether i32 costs it too many proofs, is not known.
  • Copies of generics are verbose: in C#, Option.Option_int.Some, whose field is F0, and a BigInteger for Quod's int (prefer i32 and i64 in signatures); in Python, Box__int_Box for a Box<int>. In C#, two copies whose names coincide, Pair<int, seq<int>> and Pair<int_seq, int>, do not compile.
  • A C# caller is not forced to use Match: it can still test the classes itself.
  • Python: the elements of a seq<i32> parameter are checked only with --check-requires all, which its docstring says. A value's lists can still be changed with list.append(value.xs, 1), which is no longer an accident.
  • Names: in Python, a module named like a built-in one (math, sys) or a reserved word fails when imported; in C#, a struct named like its file, or a function big_integer, does not compile. Option<nat> does not work with option.value_or: the type parameter is taken as int. [] == s is refused where s == [] passes. run_by is not available in a generic.
  • A recursion that is not a tail call follows its input in depth, in the generated code: use run_by. In the library, digits_value and digits_of remain so, which their inputs make harmless.
  • A generic function is not checked at all until it is used, and a warning says so.
  • A contract that calls itself through another function, rather than directly, can still crash the compiler.
  • Completeness: when the solver answers unknown, a contract is only warned about, and it is built. A struct holding a list described by a quantifier does that: ensures result.n == k && len(result.xs) == k with forall i in 0..k: result.xs[i] >= 0 is underspecified, and gets the warning. On a plain seq<int> it is refused.
  • loose concerns its own function: ensures result == any_pos(x) determines its result, as a function of any_pos, whose freedom it inherits without saying so. No proof depends on loose.
  • MCP: path reads any file the server can read; the server is meant to run locally. Which file an import takes depends on file_name: the report now lists the modules it used.
  • Everything of 0.2 still holds: z3 is 4.12.1, and verdicts can depend on the load of the machine.
  • There may be other false proofs in this new code. They were looked for during three sessions of review: the first two found some, the third none.