On this page
Vada tasking, devices and pipelines
This chapter collects advanced source forms. The shared concurrency/device reference and pipeline semantics define their meaning.
Tasks
A single task and a task type are declared at library-package scope:
task Worker;
task type Worker_Type (Id : Positive);
First_Worker : Worker_Type(1);These are alternative declaration fragments, not two bodies with the same name. A task body supplies local declarations and statements:
task body Worker is
begin
loop
Do_Work;
end loop;
end Worker;A task-type body uses the type's defining name and can refer to its discriminants. Each task object has its own runtime activity; task declarations are not ordinary sequential function calls. Supported Jorvik-style tasks are library-lifetime activities. The main program's return does not mean arbitrary active tasks are discarded.
Verada's Verada.Tasking.Stop supplies the documented shutdown behavior. Its semantics and runtime scheduling limits must be considered when designing termination. A package with tasks can still have proved sequential operations without establishing system liveness.
Task entries/rendezvous, accept, select, abort, requeue and terminate alternatives are excluded. Synchronize through supported protected objects and entries.
Protected objects and entries
A protected object groups synchronized state and operations. The type form allows several objects with distinct state:
protected type Counter (Start : Natural) with Priority => 10 is
procedure Add (N : Natural);
function Value return Natural;
entry Wait_Full (Total_Now : out Natural);
private
Total : Natural := Start;
Goal : Natural := 30;
end Counter;This declaration fragment needs a matching protected body. Its operations access private components under the object's synchronization. An entry waits for its barrier:
protected body Counter is
procedure Add (N : Natural) is
begin
Total := Total + N;
end Add;
function Value return Natural is (Total);
entry Wait_Full (Total_Now : out Natural) when Total >= Goal is
begin
Total_Now := Total;
end Wait_Full;
end Counter;The snippet illustrates syntax; the Add operation needs bounds/contracts sufficient to prove its arithmetic, and the discriminant/goal design must meet the intended API. It is not a claim that this unconstrained Add body proves for arbitrary N.
A single protected object omits type. Protected declarations separate public operations from private state. entry E(Parameters); declares an entry; the body adds when Boolean_Expression, then is, local declarations and begin statements.
The shared analyses reject data races, reachable blocking operations inside protected actions, and priority-ceiling violations. A protected function's read-only/effect restrictions are not relaxed by adding an entry barrier elsewhere.
The complete tasking corpus contains proved operations, discriminated task/protected types and the runtime setup; it is the executable context for these advanced forms.
Delays and priorities
delay D; requests a relative duration. delay until T; uses a supported absolute time value, for example from the provided real-time library. The Priority aspect on a task declares its supported priority; on a protected object/type it declares a ceiling.
These are source contracts with runtime/platform limits. They do not establish hard real-time deadlines on every operating system. Sleeping or calling a potentially blocking entry through another operation is not permitted from a protected action.
Volatile objects and external state
A package-level object shared with a device or other external agent can be declared:
Reading : Integer := 0 with Volatile, Async_Writers;The external properties are Async_Writers, Async_Readers, Effective_Reads and Effective_Writes. Their meaning affects both proof and generated accesses. Two reads of an asynchronously written object can denote different values; take one snapshot when a calculation needs a stable input.
Snapshot : constant Integer := Reading;This is a declaration fragment in an appropriate context. A function that reads externally changing/effectful state needs the supported Volatile_Function treatment, and uses can be restricted to whole-value contexts. Atomic is a recognized supported object property; do not infer arbitrary hardware atomic read-modify-write operations from a Boolean type annotation.
Abstract external state uses the supported form Abstract_State => (Port with External => Async_Writers) and is refined to appropriate objects in the body. The shared reference explains which properties apply to each access.
Addresses and overlays
An external mapped object can use an address aspect:
Status : Interfaces.Unsigned_32
with Volatile, Import,
Address => System.Storage_Elements.To_Address(16#4000_1000#);This context fragment needs the corresponding units visible. An address clause on an existing object is for Status'Address use Address_Value;. Supported expressions include constant addresses, conversions, sums and object addresses under the implementation's rules.
An addressed object must be a package object, and either Volatile or Atomic or an imported constant (read-only memory). Overlaid objects must be treated compatibly as volatile; otherwise one spelling could invalidate facts assumed through the other. Import suppresses ordinary initialization of externally provided storage. It does not prove that an arbitrary hardware address exists.
The old for X use at A; form is rejected in favor of modern address syntax. See interfacing and representation for object/ABI restrictions.
Pipelines and iterator extensions
A source plus pure value transformations and a consumer describes a fused pipeline. Vada's standard-looking forms are value-sequence aggregates, reductions and quantifiers:
[for X of Scores when X >= Mark => X]'Reduce ("+", 0)
[for I in 1 .. N => I * I]'Reduce ("+", 0)
(for all X of Scores => X <= 100)These expression fragments require source/type context and bounds sufficient for proof. when filters candidates. The mapped value follows =>. 'Reduce gives a reducer and an initial accumulator; a reducer such as "+" or an appropriate declared function combines values. The initial value determines empty-source reduction behavior.
A collection aggregate can be assigned/returned as an array or supported container. A reduction consumes the stream into a scalar/value. A pipeline is not a separately storable lazy iterator object or unrestricted closure.
Vada adds two explicit iterator extensions:
pragma Extensions_Allowed (On);Put that pragma at the head of a file using a stopping while clause or multiple sources in step. For example, inside a suitable body:
for X of A, Y of B when X > 0 while Y /= 0 loop
Consume (X, Y);
end loop;The sources advance together and end when a source runs out. when filters; while stops at the first candidate retained by the filter that fails its stopping condition. Order is observable when a filter and stop predicate coexist, so follow the shared pipeline rules rather than treating them as freely interchangeable Boolean conditions.
A while clause can also stop an iterated aggregate, a reduction or a quantified expression, in executable code and in contracts alike:
[for X of A when X > 1 while X < 4 => X * 2]'Reduce ("+", 0)
[for I in 1 .. 6 while I < 4 => I * 10]
(for all X of A while X /= 0 => X > 0)The quantified expression speaks of the values before the first zero: it is true of [3, 5, 0, -1]. Over a container, the elements are the cursors that have one, visited from First upwards by Next: an Iterable type's cursors are integers (B1004 otherwise), and where a program uses this model, in a quantified expression or a reduction over the elements, the prover proves that the type's functions follow it (B5122). The library's vectors, ordered sets, maps and dictionaries do. A reduction over a container's elements in a contract folds over its cursors in the same order.
A range can supply an enumeration counter alongside an array/container:
for I in 1 .. 10, X of Values loop
Visit (I, X);
end loop;Companion-source syntax is Name in Range or Name of Container after a comma. The primary source can have supported reverse/subtype details; companion reverse forms are not implied. Multidimensional sources walk components in the defined order and preserve their own dimension bounds.
Without Extensions_Allowed, these iterator additions receive B0502. GNAT accepts the pragma but not the extensions themselves: translate --to vada --plain-ada writes them as ordinary loops for GNAT (see translation). It does so for a loop's iterator and for a pipeline that is the whole value of a return, an assignment or an expression function; a pipeline elsewhere, such as an object's initial value, has no plain Ada form and is reported as B7005, so write it in one of those places first.
Optional search results
Verada.Optionals provides an optional value, None, Just and supported reducers. With a suitable generic instance visible, a first-match reduction can be written:
[for X of Scores when X > Mark => Just(X)]'Reduce (Keep_First, None)This is a context-dependent expression, not a built-in universal Optional type. The element type and visible reducer/constructor instance must match. Some reducers can stop early when their result cannot change; pure stages and proof invariants govern where that optimization applies.
Proof of pipelines
Generated invariants can prove common reductions. When they are insufficient, the compiler can offer an expand-to-loop fix in supported whole-return/assignment/expression-function positions. The explicit loop lets you state an invariant; it does not remove the original obligation.
Pipeline corpora and the lockstep example supply complete contexts. APL text is also available under pragma Extensions_Allowed (On).