DEVELOPMENT EDITION · 769442725406
Programmer Guide
On this page

Daily recipes, automation and migration

These recipes are short procedures for everyday tasks in a working project. Each links to the reference page with the full details.

Add a contract to an operation

Write down which calls are valid and what the caller can observe afterwards, including what stays unchanged. Then check the declarations, prove the operation and its callers, and run the program.

A new precondition can make a caller fail even though it makes the body easier to prove; a new postcondition can reveal a bug in the body. Both are useful feedback. The stockroom's capacity precondition and frame postcondition are worked examples.

Diagnose a proof failure

Run prove and read the diagnostic: the code, the location and the notes underneath. Run veradic explain B4101 (with the code you got), or look it up in the Diagnostics Reference.

After the repair, prove the whole project and compare the output with what it was before. Keep the specification that mattered; don't settle for a weaker one because it proves.

Repair an ownership conflict

Find the earlier move, borrow or store and the later use that conflicts with it. End the borrow sooner, use the original path, make an independent copy, or pass ownership on explicitly. Then check that every exit cleans up or restores what it must. Vibe sharing covers aliases, element views, copies and changing an object after storing it.

Work in an editor

Let the language server check as you type and prove in the background; each subprogram shows its proof state above its declaration. Run prove on the whole project at milestones.

veradic format lays out Vada and Varc source canonically, keeping comments, and format --check reports files that differ, for CI. Vibe source keeps the layout you give it; use a Python formatter if you want one.

Read a quick fix as an edit to your source, especially one that changes a public contract or expands a pipeline into a loop, and prove the result.

Translate a module

veradic translate --to varc -o out/ stock.vads stock.vadb writes the units in another syntax (vada, varc or vibe), one file per unit. Translate into a separate directory, then check, prove and run the result and compare its output with the original's. Comments, file layout and some names change with the syntax. See translation.

veradic emit writes the LLVM IR, assembly, object code or Verada Core of a program, when you want to see what was generated.

Generate reference pages or Python stubs

veradic doc writes Markdown reference pages from package specifications and their comments. Add your own explanation of purpose, errors and resources alongside them; the generated pages can't supply that.

veradic stubs writes .pyi files so Python type checkers understand the verada module and the Vada and Varc packages you give it, which a Vibe module imports; stubs shows the setup. A type checker accepting the code is not a proof.

Set up project checks in CI

Automation and CI gives a complete gate and the exit codes and output streams of each command. A typical sequence:

  1. veradic format --check on Vada and Varc sources.
  2. veradic check, then veradic prove; in CI, always prove, rather than relying on run, which uses the proof cache.
  3. veradic build, then run the executable and compare its output with a reviewed file.

Keep the projects that are meant to fail separate from those that must pass, and assert their diagnostic code and exit status, not their English text. With --diagnostics json, parse the whole output of the command.

The proof cache in .verada/ makes repeated proofs fast and is safe to keep between CI runs; --no-cache proves everything again. -j N sets the number of solver processes (by default, half the processor cores; the VERADA_JOBS environment variable sets it for a machine).

Bring Ada code into Vada

Start with a small package and check it against the provable subset: write contracts as aspects (with Pre => ...), and replace shared mutable pointers, handlers that catch failed checks, and tasking outside the Jorvik profile. Ada code that compiles is not yet code that proves. Verada and standard Ada lists what to write instead of each Ada feature Verada leaves out.

Add contracts at the boundaries, then check, prove and compare the output with the original program's. GNAT can compile Vada programs too, which makes it a useful second opinion on behavior; veradic translate --to vada --plain-ada writes Verada's iterator extensions as plain Ada for it. SPARK_Mode => Off has no effect in Verada (warning B8004): every body is proved.

Bring Python code into Vibe

Start with a typed core of plain functions and values. Annotate parameters and results, choose finite integer ranges, classes and container element types, and replace dynamic features (reflection, eval, monkey-patching, unrestricted aliasing) with typed code.

Then check what differs from Python: integers are finite, a[-1] is not allowed, a value stored in a container is a copy or a move rather than a shared reference, and views of elements have lifetimes. Vibe and Python compatibility lists the rules.

A Python type checker finds annotation and API mistakes early, but its typing rules are not Verada's. Prove the program with Verada, and compare its output with CPython's where both can run it.

Deliver a native application

Prove the project, build it, and run the executable on the platform you deploy to; check its output, its error behavior and anything it needs at run time, such as C libraries. Build releases with --target-cpu baseline so the executable runs on any machine of that architecture, and with --no-assume to reject any assumption the proof would otherwise trust.

Record the compiler version (veradic --version) and the output of veradic trust with the release.