Vary started out Python-shaped. The early syntax borrowed def, for...in, if/elif/else, import and from...import directly. If you had written Python, the first version of Vary looked familiar.
It diverged quickly. Static types are enforced at compile time. Blocks use braces. Mutation testing is a compiler command. The test runner is built into the language. Enums carry payloads. None of this exists in Python.
If terms like ghost code, proof obligations, invariants, or exhaustive match are unfamiliar, see the Glossary.
Python showed that code can be readable without being verbose. Short keywords, minimal ceremony, no semicolons.
| Area | Python | Vary |
|---|---|---|
| Typing | Dynamic, optional hints | Static, enforced at compile time |
| Execution | Interpreted | Compiled to JVM bytecode |
| Variables | x = 42 (always mutable) | let x = 42 / mut x = 0 |
| Null handling | Anything can be None | Only T? types can be None |
| Data types | @dataclass | data keyword |
| Enums | enum.Enum | enum with payloads and exhaustive match |
| Testing | pytest, unittest | Built-in test DSL + observe |
| Mutation testing | Third-party (mutmut) | Built-in vary mutate |
For a full comparison, see Python comparison.
Eiffel pioneered Design by Contract: preconditions, postconditions, and class invariants checked at runtime. Vary's contract system (in/out/old) draws directly from Eiffel's model.
| Area | Eiffel | Vary |
|---|---|---|
| Preconditions | require block | in {} |
| Postconditions | ensure block | out (result) {} |
| Entry-state capture | old expr | old(expr) |
| Class invariants | invariant block | invariant {} on classes and data types |
| Contract enforcement | Runtime, can be disabled per build | Runtime, always on in vary mutate |
| Mutation integration | None | Contract violations are mutation kill signals |
Eiffel treats contracts as documentation and correctness aids. Vary treats them as oracle surfaces for mutation testing. A contract that fails under mutation means the program is well-constrained. A contract that no mutation can break is too weak. Contracts in Vary make vary mutate more powerful, and the same contracts can be proven for all inputs with vary prove, which Eiffel's own static verifier (AutoProof) does for Eiffel.
Two D ideas influence Vary: the pure function qualifier and built-in contract syntax.
| Area | D | Vary |
|---|---|---|
| Purity | pure qualifier, compiler-enforced | pure def, compiler-enforced |
| Contracts | in {} / out {} blocks on functions | in {} / out (result) {} |
| Contract scope | Preconditions, postconditions, invariants | Preconditions, postconditions, old(expr) |
| Mutation testing | None built in | Built-in vary mutate |
| Compilation target | Native machine code | JVM bytecode |
D enforces purity for safe parallelism and optimization. Vary enforces purity to improve mutation testing signal. A pure def guarantees no hidden state, so surviving mutants point to genuine gaps in contracts or tests rather than side-effect interference. D proved that purity enforcement is practical in a mainstream-style language. Vary applies it to a different problem.
Dafny is a verification-aware language. Programs are proved correct at compile time using an SMT solver (Boogie and Z3). Contracts written in Dafny are not run-time checks: they are static proof obligations that must hold before the compiler will emit code. Dafny is the main model for vary prove, and Vary borrowed its annotation vocabulary: invariant, decreases, ghost code, lemmas, modifies, and quantifiers.
| Area | Dafny | Vary |
|---|---|---|
| Verification | Static proof via SMT solver (Boogie and Z3) | vary prove with a bundled SMT solver (SMTInterpol), plus optional Z3 and cvc5. Contracts are also run-time checks |
| Preconditions | requires | in {} |
| Postconditions | ensures | out (result) {} and post {} |
| Pre-state capture | old(expr) | old(expr) |
| Invariants | invariant on classes and loops | invariant {} on classes, data types and loops |
| Termination | decreases clause, compiler-checked | decreases on loops and recursion, checked by the prover and at run time |
| Frame control | reads and modifies clauses | modifies, inferred when omitted, checked on every write |
| Ghost code | Ghost variables and functions, erased at compile time | ghost let, ghost mut and lemma, erased from compiled output |
| Quantifiers | forall and exists with triggers | forall and exists with {:trigger ...} hints, also executable at run time |
| Failed proof | Compile error | A reported status (refuted, unknown, unsupported). The program still compiles and runs |
| Null handling | T? for nullable types | T? for nullable types |
| Variables | var (mutable) and const (immutable) | mut (mutable) and let (immutable) |
| Compilation targets | C#, Java, JavaScript, Go, C++ | JVM bytecode |
| Mutation testing | None built in | Built-in vary mutate, which can use proofs to kill mutants |
| Testing | Specifications replace most tests | Built-in test DSL and observe |
The two approaches differ in commitment. In Dafny every method must verify, so verification is the language. In Vary a contract is a run-time check from day one, and vary prove is something you add, function by function, where a proof is worth the effort. A result that is not proven is reported as such, and the program still builds. Dafny proofs can require heavy annotation. Vary's bundled solver is weaker than Z3, so some goals that Dafny settles come back unknown until you switch solvers or add a lemma. Vary targets cheap verification of ordinary application code. Dafny targets provable correctness of everything.
Dafny also supplies the test material for the prover. Verified Dafny programs are being translated to Vary to measure how vary prove behaves on specifications that other people wrote.
SPARK is a verifiable subset of Ada. Its prover, GNATprove, generates conditions through Why3 and discharges them with several SMT solvers. It is used in avionics, rail and security-critical systems, and it is the main evidence that contract-based proof works at industrial scale.
| Area | SPARK | Vary |
|---|---|---|
| Contracts | Pre, Post, Loop_Invariant, Loop_Variant aspects | in, out, invariant, decreases |
| Contracts at run time | Can be compiled as run-time assertions | Always run-time checks, unless proven and removed by an opt-in setting |
| Removing proven checks | Supported | elide_proven_contracts |
| Subset | A defined subset of Ada. Anything outside it is excluded | Any Vary program. Unmodelled constructs are reported unsupported by name |
| Maturity | Decades of industrial use | New |
Like SPARK, Vary lets one contract serve both the run-time check and the proof. Unlike SPARK, Vary does not restrict the language to a verifiable subset. It proves what it can model and says plainly what it could not.
| Tool | Role | Relation to Vary |
|---|---|---|
| Why3 | A platform and intermediate language (WhyML) with many solver back-ends. SPARK, Frama-C and Creusot build on it | Vary has its own small pipeline and does not use an intermediate verifier |
| Frama-C (WP) | Verifies C programs with ACSL annotations in comments | The same idea on an unsafe language. The contracts are not part of the language |
| JML, OpenJML, KeY | Contract annotations for Java with static tools | Vary targets the same VM. JML lives in comments |
| Tool | Approach | Relation to Vary |
|---|---|---|
| Lean, Coq, Isabelle | Interactive proof assistants. A person writes each step and a small kernel checks it | vary prove --export-lean writes a goal the SMT solver could not settle as a Lean 4 file. A checked proof is imported back and reported as proven-external |
| F* | Dependently typed with SMT-assisted proofs and verified code extraction | More expressive and harder to learn. Vary keeps ordinary types |
| Liquid Haskell | Refinement types checked by an SMT solver | The logic lives in the type. In Vary it lives in contracts |
| Prusti, Creusot, Kani | Verifiers for Rust. Kani is a bounded model checker | Kani resembles vary prove --bounded |
| CrossHair, Nagini | Symbolic checking of Python contracts and a verified typed Python subset | Closest in spirit to bounded mode |
For the full comparison with what each tool is good at, and where vary prove is weaker, see Other verification tools.
Vary's AI features (ai using, feels, and match ... by meaning, documented in Semantic AI control flow) were designed against several existing projects. They are design precedents, not claims of equal maturity or API compatibility.
| Project | What it does | What Vary took from it | What Vary does differently |
|---|---|---|---|
| Probably | Semantic conditions, uncertainty branches, semantic routing, bounded execution and replay | Readable workflow-level syntax, visible uncertainty, replayable effects | Keeps literal match, types and Result errors, with a shared configurable budget. No random branch sampling |
| Jac byLLM | Typed function declarations delegate their implementation to a model, with semantic annotations and validated outputs | Typed operations and reusable ordinary functions, with provider setup kept away from the workflow | Input is supplied explicitly and failures are Result values. No implicit capture of object or module context and no automatic coercion |
| LMQL | Generation takes part in control flow, with constraints that guide decoding | A clear line between structural guarantees and semantic judgments | No token-decoding engine, and prompt instructions are never presented as enforced constraints |
| BAML | Functions separate typed arguments and results from prompt templates and configured model clients | Stable operation contracts and interchangeable adapters | Reuses Vary functions, data and enums. No second schema language and no required prompt-template dialect |
Two choices follow from these comparisons. The compiler knows typed AI operations but never provider URLs, model names or credentials, which live in an adapter. And every retry consumes the workflow's shared budget, so a loop can never spend without limit.