On this page
Vibe and Python compatibility
Vibe uses Python's syntax for a statically checked, proved, natively compiled language. Every Vibe program is valid Python, but not every Python program is Vibe: this chapter lists the helpers with compiler meaning, the Python features Vibe leaves out on purpose with the Vibe way to write each, and the places where Vibe's meaning differs from CPython's. Passing a Python type checker is not acceptance by Verada, and Verada's acceptance is not a promise that CPython would print the same.
Recognized helpers and standard imports
These names have compiler meaning in the positions the other chapters describe. The import lines keep the source valid Python and let Python tools check it; they do not load the Python module.
| Name(s) | Conventional import | Compiler meaning |
|---|---|---|
Natural, Positive |
from verada import ... |
Predefined constrained integer subtypes |
RangeInt, Modular |
from verada import ... |
Integer and modular class bases |
Array |
from verada import Array |
Array class base with index, size, shape, or rank |
Annotated, Interval, Ge, Le |
from verada import ... (or Annotated from typing) |
Named subtype constraints in a type declaration |
Final |
from verada import Final or from typing import Final |
Module constant or named number |
Owned, move, deref, copy |
from verada import ... |
Owning access values and explicit copies |
Ordered |
from verada import Ordered |
Less-than formal operation for a generic function bound |
requires, ensures, raises, old, result |
from verada import ... |
Leading subprogram contracts and their expression forms |
invariant, decreases, increases |
from verada import ... |
Loop proof annotations |
assume, terminates, ghost |
from verada import ... |
Trusted assertion, termination and ghost-function decorators |
Protected, entry, when, task, sleep, stop |
from verada import ... |
Concurrency forms |
dataclass |
from dataclasses import dataclass |
Record class declaration |
ABC, abstractmethod |
from abc import ABC, abstractmethod |
Abstract classes and methods |
Protocol |
from typing import Protocol |
Nominal interface or generic-function bound |
Enum |
from enum import Enum |
Enumeration type |
takewhile |
from itertools import takewhile |
Early-stop iterator stage with an inline one-parameter lambda |
The builtins int, float, str, repr, len, abs, round, divmod, ord, chr, min, max, sorted, list, print (with sep= and end=), range, reversed, zip, enumerate, sum, and generator all/any have the meanings and arities given in expressions and iteration; min, max, sorted, list and str.join take a generator too. Empty list(), dict() and set() construct typed locals. Python's built-in exceptions (ValueError, KeyError, IndexError and the rest, with Python's hierarchy: except LookupError handles KeyError) are Verada.Vibe's; AssertionError is a failed assert's and MemoryError is Storage_Error.
Imports from verada, typing, dataclasses, enum, abc, itertools and __future__ bring in the names above; every other import names a Verada unit (a Vibe module, or a Vada or Varc package such as ada.exceptions). See names and modules.
Supported forms
| Python-style family | Vibe |
|---|---|
| Typed module functions | Annotated parameters and results, defaults, calls by position or by name; a parameter the function assigns is its own copy; a function that prints, or is declared to raise (raises(E)), returns its result as Python's does |
| Nested functions | def inside a function, reading the names around it; nonlocal for those it assigns |
| Local inference | Scalars and other values whose type the initializer fixes; a tuple, list, dict or set display or comprehension, a slice or a copy, whose type the annotations of its parts fix (sq = [x * x for x in xs] is list[int] when xs is); statement-list scope |
| Dataclasses | Annotated fields with defaults, construction by position or keyword, methods, super(), Python's repr (Point(x=1, y=2)) |
| Plain classes | __init__ making the fields through self, methods, @property, ClassVar[T] (one variable for the class); the sharing rules are a dataclass's |
| Special methods | __str__, __repr__, __eq__, __lt__, __le__, __gt__, __ge__, __add__, __sub__, __mul__, __truediv__, __neg__, __len__, __getitem__, __setitem__, __contains__; forward annotations (other: "V") |
| Enums | Members, .name and .value, Color(3) by value, Color["RED"] by name, len(Color), for c in Color |
| Inheritance and interfaces | Tagged hierarchies, ABC, nominal Protocol |
| PEP 695 | Generic functions and classes, named bounds |
| Unions | Unions of a module's classes; Owned[T] | None |
| Lists, dicts, sets | Typed instances of Verada's container libraries |
| Tuples | Two to twelve components, typed packing, literal indexing (from the end too), unpacking that declares (a, b = 1, 2), for a, b in pairs |
| Control flow | if/elif/else, while, for over ranges (with a step too), containers, a str's characters and an Enum class's members, a loop's else, break, continue, the walrus in conditions |
| Assignment | Chained assignment, tuple unpacking, a starred target (a, *rest = xs; of a str, a list of its characters), a starred element in a list display ([*xs, 4]) |
| Matching | Discrete cases, capture patterns (case k if k < 0:), class patterns with names and literal values (Point(x=0, y=y)), of a union's classes or one dataclass, with guards |
| Exceptions | User exception classes (of Exception or of one of Python's built-in exceptions, which except of their base handles), Python's built-in exceptions, raise, try/except/else/finally, occurrence messages, raises(E) for a function that lets one out, assert with a message (shown when it fails) |
| Context managers | with a as x, b: over dataclasses with __enter__ and __exit__, which is given the exception's name and message and may suppress it |
| Slices | xs[a:b] and xs[a:b:k] (a step written as a number) of a list or a string, xs[a:b] of an array too, the bounds kept within the length as Python keeps them; a slice is a new list or string |
| Indexes | xs[-1] counts from the end of a list or a string, as Python's |
| Numbers | &, |, ^ of ints (two's complement, Python's); //, % and ** of floats; an int meeting a float is converted, as Python converts it |
| Formatting | f-strings with conversions and specs, str.format of a literal template, % of a literal template (printf's style) |
| Iterators | range, zip, enumerate, reversed, takewhile and generator expressions, consumed where written |
| Text | immutable str of code points: len counts characters, s[i] is a one-character str, +, images, f-strings; printed as UTF-8 |
| Concurrency | Tasks and protected objects |
Python features Vibe excludes
Each of these is rejected with a diagnostic (B0401 unless the row says otherwise) that says why and what to write instead; the rest of the module is still read, so one excluded form is one diagnostic. They are left out because a proved, statically typed program cannot keep their meaning; the second column is the Vibe way.
| Python feature | In Vibe |
|---|---|
Unannotated parameters and results, Any, duck typing |
Annotate every parameter and result; use a Protocol the class names as a base, or a union with match |
eval, exec, getattr/setattr, __dict__, metaclasses, monkey-patching, dynamic import |
Write the operation as an ordinary typed function; name the field itself |
isinstance, type(x), id(x) |
match on a union or a class-wide value; compare values with == |
| Decorators other than Vibe's | Functions take @terminates, @ghost, @entry, @task and @abstractmethod; classes take @dataclass |
Dataclass options (frozen=True, slots=True, order=True, ...) |
A dataclass is a record compared field by field; limited=True is its one option. A value that must not change is a Final constant or an input parameter |
| Lambdas outside iterator stages; closures stored or returned | A module function, or a generic function with a Protocol bound |
yield, generator objects, async/await, hand-written iterator classes |
Loops over ranges and containers, and generator expressions consumed by sum, all and any; tasks for concurrency |
*args, **kwargs, argument unpacking at calls (f(*xs)) |
Fixed typed parameters; pass a list or array for a variable number of values, and give optional parameters defaults |
| A nested function returned or stored (a closure that escapes) | Call it where it is defined, or define it at the module's level and pass it what it reads |
global of another module's variable |
That module's functions change its variables; global x of the function's own module's variable is Python's, and taken |
/ and * markers in a parameter list |
Every parameter can be passed by position or by name (B0401 otherwise) |
is and id except is None |
Value equality ==; is None for an owner |
async with, and __exit__ given the exception's class and traceback |
Context managers are dataclasses; __exit__ is given the exception's name and message as str | None |
del of a list's or a dict's element (del d[k]) |
del frees an owner only; x: T = xs.pop(i) takes a list's element out |
Arbitrary-precision int |
int is 64-bit and its overflow is proved absent; choose Long_Long_Long_Integer (128 bits) where needed |
A slice's step known only at run time (xs[::k]), assigning to a list's or a string's slice |
A loop over range(a, b, k); build the new list or string and assign it whole (an array's slice of the same length may be assigned) |
| A property's setter, a plain class whose fields another method makes | Assign the field, or give the class a method that sets it; make every field in __init__ |
return, break or continue in a finally |
Leave after the try statement |
bytes, a named escape \N{...} |
str (a text of code points); \N{...} is B0602, write \u or the character |
Numbers and objects
int is a 64-bit signed Integer, bool is distinct from int, and a constrained alias is enforced. Overflow and range checks must prove: there is no arbitrary-precision fallback. float is Long_Float, with rounding. / is Python's true division and gives a float (7 / 2 is 3.5); // is floor division (-7 // 2 is -4) and % takes the divisor's sign (-7 % 3 is 2), as in Python. int(real) truncates toward zero. sum of floats is compensated, as CPython's sum is.
Objects follow the value, view and ownership rules: storing a record in a container stores a copy, copy is not a recursive deepcopy, and del frees an owned object rather than unbinding a name. Where a program's result would depend on Python's sharing in a way Vibe's values cannot reproduce, Vibe rejects it (B0401) and names the explicit form to use. Classes and container instances have nominal identity.
Shared aspects and pragmas
Vibe has no general aspect or pragma syntax. The shared vocabulary appears in Vibe as follows; a wrapper or library written in Vada or Varc can carry aspects that affect its Vibe clients. The shared catalog gives each aspect's meaning.
| Shared names | In Vibe |
|---|---|
Pre, Post, Exceptional_Cases |
Leading requires, ensures, raises |
Always_Terminates |
@terminates on a procedure |
Ghost |
@ghost on a function |
Global, Depends |
Inferred from the body |
Subprogram_Variant |
decreases(e) first in a recursive function's body |
Contract_Cases, Refined_Post |
Written in a Vada or Varc declaration that Vibe imports |
Type_Invariant, Default_Initial_Condition |
__invariant__ and __initial__ in a proof enclave; otherwise imported |
Static_Predicate, Dynamic_Predicate, Predicate |
Named range aliases (type Score = Annotated[...]); other predicates imported |
Inline, Import, Export, Convention, External_Name, Link_Name |
An imported Vada or Varc interface |
Size, Object_Size, Component_Size, Alignment, Address, Pack, Independent |
An imported Vada or Varc declaration |
Volatile, Atomic, Async_Readers, Async_Writers, Effective_Reads, Effective_Writes, Volatile_Function |
An imported device declaration |
Pure, Preelaborate, Elaborate_Body, Initializes, Initial_Condition |
The shared unit and elaboration rules apply to the module |
Abstract_State, Part_Of, Refined_Global, Refined_Depends, Refined_State |
Through declared or imported APIs |
Relaxed_Initialization |
Definite initialization applies |
Finalizable, Iterable, Aggregate |
Library types provide them; __del__ in a proof enclave |
No_Return, Program_Exit, Constant_After_Elaboration, Extensions_Visible, Side_Effects |
An imported declaration |
Annotate, Unreferenced, Default_Value, Default_Component_Value |
Field defaults are the record form |
SPARK_Mode |
No per-unit switch; choose the proof policy with the tool's options |
Statement pragmas with Vibe spellings are assert, assume, invariant, decreases and increases, described under contracts.
Python execution and type checking
veradic stubs generates .pyi interfaces for Python type checkers. Stubs are signatures, not implementations; a type checker's success does not prove contracts or check inferred modes.
Verada's test suite runs selected Vibe programs under CPython and compares their output with Verada's, using a stand-in verada module (test/vibe/verada.py) in which the contract functions are plain functions. It is a test oracle, not a run time to deploy and not a prover; tasking programs cannot be compared this way. Code using PEP 695 needs Python 3.12 or later to run there, and annotations that name a class inside its own body (next: Owned[Node] | None in Node, -> Log in Log) need Python 3.14, whose annotations are evaluated only when asked for (PEP 649).
Tools
The file front end supports checking, proving, native and in-memory execution, translation to and from Vada and Varc, documentation and stub extraction. The REPL reads Vibe input as Python's REPL does: blocks end at a blank line, a bare expression prints its value, and a module-level assignment to a new name declares a session variable (veradic repl).
Embedded APL (apl("..."), @ and .T on Array matrices) has its own chapter, and so do proof enclaves. The shared compatibility and limits pages cover rules common to all syntaxes.