AI agents now write code faster than anyone can review it. The bottleneck has moved from writing to checking. Dovod is a small compiled language built around that fact: checking is not an optional step after the code is written, it is part of what makes the code valid.
Dovod (Russian довод) means "an argument, a piece of evidence". Code in it carries its own evidence.
Repo: https://github.com/helgard-orlm/dovod (MIT). The whole language is one spec file of about 9 KB, meant to be read once in a single context window.
A first look
fn clamp(x: Int, lo: Int, hi: Int) -> Int
need lo <= hi // precondition, checked on every call
give out >= lo and out <= hi // postcondition on the result
ex clamp(5, 0, 3) == 3 // examples: run at every check / build
ex clamp(-1, 0, 3) == 0
ex clamp(2, 0, 3) == 2
{
if x < lo { return lo } else if x > hi { return hi }
return x
}
fn main() uses io {
print("clamp(15, 0, 10) = " + show(clamp(15, 0, 10)))
}
It compiles to C: no garbage collector, single-owner value semantics, no references, no null, no globals. Integer overflow, out-of-bounds access and failed contracts trap instead of silently continuing.
Rule 1: no examples, no compile
A pure function with no ex lines is a compile error. Examples run on every check and every build. The only way out is an explicit excuse:
fn fast_inv_sqrt(x: Float) -> Float
assume "accurate to 1e-6 for x in 0.01..100; checked by hand against a table"
{ ... }
An assume is allowed, but it is not hidden: it shows up in the trust report together with every function that depends on it.
Rule 2: an example must be able to fail
The easy way to satisfy "every function needs an example" is an example that tests nothing. The compiler rejects that:
fn double(x: Int) -> Int
ex double(2) == double(2)
{
return x * 2
}
vac.dv:2:16: E-VACUOUS: both sides of this comparison are the same expression, so it pins down nothing
fix: compare with a concrete expected value: `ex double(...) == <value>`
Beyond the obvious cases, every example is also re-run against two mutants of its function's result. An example that passes either way pins down nothing and is rejected.
Rule 3: the compiler tells you how strong your examples are
After the examples pass, the compiler mutates each function body one small change at a time — a number +1, < to <=, == to !=, + to -, and to or, a removed assignment — and re-runs the examples. Every change that no example notices is a place where the code could be wrong while all tests stay green.
// is the shop open at this hour? (opens 9, closes 18)
fn open_at(hour: Int) -> Bool
ex open_at(12) == true
ex open_at(3) == false
{
return hour >= 9 and hour < 18
}
$ dovod weak shop.dv
shop.dv:6:18: W-WEAK: in `open_at` no example notices if `9` becomes `10`
shop.dv:6:15: W-WEAK: in `open_at` no example notices if `>=` becomes `>`
shop.dv:6:31: W-WEAK: in `open_at` no example notices if `18` becomes `19`
shop.dv:6:29: W-WEAK: in `open_at` no example notices if `<` becomes `<=`
1 of 5 small changes are noticed by the examples; 4 are not.
Two examples, both passing, and neither boundary is actually checked. Add ex open_at(9) == true and ex open_at(18) == false and the score becomes 5/5. dovod check prints the score for the whole file; dovod weak lists every surviving change with its line and column.
The compiler also reports every block that no example ever reached.
Rule 4: effects are declared — exactly
fn main() uses io, fs_read { ... }
A function that touches the console, files, the clock, randomness, command-line arguments or a module's device must declare it. An undeclared effect is an error, and so is a declared effect the function never uses. There is no other way to reach the outside world, so the effect list on main is the complete answer to "what can this program touch?".
Small slips are errors
Things that are a warning or a lint elsewhere are errors here: shadowing, unused names, an ignored result, a non-exhaustive match, implicit conversions. Labelled arguments (f(x, lo: 0)) are checked against the parameter name at that position. There is one way to do each thing.
The trust ledger
dovod trust prints a report meant for someone who will not read the code. A real one, for a small window program that compares grocery prices per kilo (trimmed):
$ dovod trust examples/prices.dv
can: read/write the console (io); show a window or page in a web browser and
read what the user does there (opens a network port) (ui)
cannot: read files; write files; read command-line arguments; read the clock;
use randomness; network; run other programs
function status examples blocks strength
per_kilo self-checked 8/8 6/6 7/7
best self-checked 5/5 5/5 6/7
view self-checked 4/4 5/5 7/7
update self-checked 16/16 12/12 14/14
main shell - - - effects: io, ui
summary: 9 self-checked, 1 shell. Unchecked shell = 18 of 266 function lines (6%).
taken on faith: nothing.
outside this ledger (no example reaches it):
- Dovod's C runtime under every program (text, lists, traps): 276 lines of C
- module `ui`: 4 native function(s), 326 lines of C
- the shell functions themselves (main): they run only in the real program
- whether the task was understood: examples by the code's author share the author's reading of it
Statuses: self-checked (all examples pass and reach every block), partial (some block never ran — the line is named), assumed, shell (the effectful outer layer), witnessed / witness-failed.
Two design choices are deliberate:
-
self-checked, not "correct". Examples written by the code's author catch slips and forgotten cases, but not a misunderstood task: the same misunderstanding goes into both. For an independent check, someone else (a person or another model) writes a witness file thatuses the code, anddovod trust FILE --witness W.dvupgrades a function towitnessedor reportswitness-failed. - The ledger says what it cannot see. Native code in the runtime and in modules is listed with its size, so "taken on faith: nothing" is never read as "everything is verified".
Built for an agent's loop
- Every diagnostic has
file:line:col, a stable code (E-NAME,E-EFFECT,E-EXAMPLE,E-VACUOUS,W-WEAK…) and usually a concretefix:line.--jsongives the same to a machine. -
dovod card FILEprints only signatures, contracts and two examples per function — the interface to hand to another agent without the bodies. -
dovod specprints the whole language;dovod spec NAMEprints a module's page.
slips.dv:18:5: E-NAME: unknown name `totl`
fix: did you mean `total`?
slips.dv:24:3: E-EFFECT: `loud` does `io` (read/write the console) but does not declare it
fix: add `uses io` to `fn loud` — or move this out of a pure function
Modules
The core stays one page; everything task-specific is a module enabled with use NAME. A module cannot add syntax, its exports carry its prefix, and only simple values cross the boundary to native code. Current modules:
-
ui— a window (or a page on the local network) with buttons, fields, sliders and tables, drawn by the user's browser and served by the program itself. The screen is a value:fn view(model) -> UiNodeandfn update(model, ev) -> Modelare pure functions with examples; the browser only renders. -
video— play media files in a window on Windows (Media Foundation).dovod build --target win64produces a single.exewith no DLLs. -
ble— listen to Bluetooth LE advertisements on Windows: address, name, signal strength, services, manufacturer. -
mcu— Arduino-family boards.dovod build FILE --target arduino --fqbn arduino:avr:leonardowrites a sketch folder and compiles it with arduino-cli. Debounce, long-press and timer-wrap logic is pure code whose examples run on the PC before anything is flashed. Thelamp.dvexample (button + light, 26 examples) is 6.9 KB of flash and 337 bytes of RAM on an ATmega32U4.
The program always owns its event loop: modules expose a pull function (video_next(), ble_next(timeout)), so the effects of main stay the whole truth.
Speed
Same code in Dovod and Python 3.13, Intel N100, one run each, with all Dovod checks (overflow, bounds, contracts) on:
| task | Dovod | Python |
|---|---|---|
| prime sieve to 5,000,000 | 25 ms | 590 ms |
| longest Collatz below 1e6 | 298 ms | 10,061 ms |
| building 2M number strings | 113 ms | 145 ms |
A single run on a low-power CPU: read it as "native code, as expected", not as a benchmark.
Try it
Needs Python 3.10+ and a C compiler (gcc or clang).
git clone https://github.com/helgard-orlm/dovod && cd dovod
bin/dovod check examples/shapes.dv # static checks + run all examples
bin/dovod weak examples/shapes.dv # which small code changes no example notices
bin/dovod run examples/wordfreq.dv README.md
bin/dovod build examples/bench.dv -o bench # native binary
bin/dovod trust examples/prices.dv # the ledger
bin/dovod card examples/wordfreq.dv # interface only
bin/dovod spec # the whole language
tests/run.sh # compiler self-test (incl. ASan/UBSan/leak check)
Status and limits
Version 0.3, experimental. Not there yet: maps, generics, closures, namespaces, network and process effects, Unicode-aware text indexing (Text is indexed by bytes). Examples are not proofs: an example can be refutable and still weak (ex f(1) != 0) — the strength score and witnesses exist to expose exactly that.
Related work that shares ideas: Vera (contracts and Z3 for LLM-written code), Hylo (mutable value semantics), Koka (effect types), and mutation testing in general. Dovod's own combination is mandatory examples, mutation strength reported by the compiler, a ledger of what is taken on faith and what is invisible, and exact effects — aimed at the case where a model writes the code and a person has to decide whether to trust it.
If you give SPEC.md to a model and let it write something, I'd like to hear how it went.
Top comments (0)