On this page
Verada.Containers.Functional.Sequences
Ghost functional sequence values for contracts.
Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
Get is one-based; Add and Set return new values. <= means prefix. The package is ghost.
A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.
Import and instantiate
Place the declaration in a declarative part, with the actuals your program needs.
with Verada.Containers.Functional.Sequences;
package Instance_Name is new Verada.Containers.Functional.Sequences (Integer);import Verada.Containers.Functional.Sequences;
package Instance_Name = new Verada.Containers.Functional.Sequences<Integer>;
Vibe does not instantiate library generics; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.
Contract and lifecycle reading
A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.
API 001
Element_Type (declaration) — Generic actuals establish this instance's nominal types and declared operations. Private formals require suitable definite nonlimited actuals; capacity/comparison/float restrictions are shown below. Defaulted comparison is resolved from the actual type, not an automatic proof of ordering laws.
Declared interface:
generic
type Element_Type is private;API 002
Sequence (declaration) — Private ghost finite sequence with one-based positions, pairwise ordered equality and prefix comparison.
Declared interface:
type Sequence is private;API 003
Empty_Sequence (declaration) — Construct the empty ghost sequence.
Declared interface:
function Empty_Sequence return Sequence
with Global => null,
Post => Length (Empty_Sequence'Result) = 0;API 004
Length (declaration) — Observe the logical length/cardinality, not backing capacity or physical allocation size.
Declared interface:
function Length (Container : Sequence) return Natural
with Global => null;API 005
Get (declaration) — Read a present sequence position or map key, following the declared actual parameter type.
Declared interface:
function Get (Container : Sequence; Position : Positive) return Element_Type
with Global => null,
Pre => Position <= Length (Container);API 006
Last (declaration) — Return the final sequence position or last list cursor according to its result type; check the family's empty sentinel.
Declared interface:
function Last (Container : Sequence) return Natural is (Length (Container));API 007
Add (declaration) — Return a new ghost model with an appended/new entry, leaving the input value unchanged; absence/capacity requirements still apply.
Declared interface:
function Add (Container : Sequence; New_Item : Element_Type) return Sequence
with Global => null,
Pre => Length (Container) < Natural'Last,
Post => Length (Add'Result) = Length (Container) + 1
and then Get (Add'Result, Length (Add'Result)) = New_Item
and then (for all I in 1 .. Length (Container) => Get (Add'Result, I) = Get (Container, I));API 008
Set (declaration) — Return a new ghost model replacing a present value, or mutate an owned string to the supplied contents in that overload.
Declared interface:
function Set (Container : Sequence; Position : Positive; New_Item : Element_Type) return Sequence
with Global => null,
Pre => Position <= Length (Container),
Post => Length (Set'Result) = Length (Container)
and then Get (Set'Result, Position) = New_Item
and then (for all I in 1 .. Length (Container) => (if I /= Position then Get (Set'Result, I) = Get (Container, I)));API 009
Prepend (declaration) — Return a new ghost sequence with New_Item first and the old elements after it, one position later; the input value is unchanged.
Declared interface:
function Prepend (Container : Sequence; New_Item : Element_Type) return Sequence
with Global => null,
Pre => Length (Container) < Natural'Last,
Post => Length (Prepend'Result) = Length (Container) + 1
and then Get (Prepend'Result, 1) = New_Item
and then (for all I in 1 .. Length (Container) => Get (Prepend'Result, I + 1) = Get (Container, I));API 010
Remove_First (declaration) — Return a new ghost sequence without the first element; the others move one position earlier.
Declared interface:
function Remove_First (Container : Sequence) return Sequence
with Global => null,
Pre => Length (Container) > 0,
Post => Length (Remove_First'Result) = Length (Container) - 1
and then (for all I in 1 .. Length (Remove_First'Result) => Get (Remove_First'Result, I) = Get (Container, I + 1));API 011
Remove_Last (declaration) — Return a new ghost sequence without the last element; the others keep their positions.
Declared interface:
function Remove_Last (Container : Sequence) return Sequence
with Global => null,
Pre => Length (Container) > 0,
Post => Length (Remove_Last'Result) = Length (Container) - 1
and then (for all I in 1 .. Length (Remove_Last'Result) => Get (Remove_Last'Result, I) = Get (Container, I));API 012
"=" (declaration) — Equality in this declared value/model domain; the family defines whether sequence order, set membership, map pairs or logical text contents are compared.
Declared interface:
function "=" (Left, Right : Sequence) return Boolean
with Global => null,
Post => "="'Result = (Length (Left) = Length (Right)
and then (for all I in 1 .. Length (Left) => Get (Left, I) = Get (Right, I)));API 013
"<=" (declaration) — The declared comparison: ordinary numeric order, sequence prefix, set inclusion or map-pair inclusion according to the parameter types.
Declared interface:
function "<=" (Left, Right : Sequence) return Boolean
with Global => null,
Post => "<="'Result = (Length (Left) <= Length (Right)
and then (for all I in 1 .. Length (Left) => Get (Left, I) = Get (Right, I)));API 014
Contains (declaration) — Test the family's declared membership/search relation; it is not a mutation or a guarantee of constant-time lookup.
Declared interface:
function Contains (Container : Sequence; Item : Element_Type) return Boolean is
(for some I in 1 .. Length (Container) => Get (Container, I) = Item);API 015
Equal_Elements (declaration) — Whether two elements are the same value, by the element type's own equality: the contracts of a container whose element "=" is a generic formal (Ada.Containers') compare elements with it.
Declared interface:
function Equal_Elements (Left, Right : Element_Type) return Boolean is (Left = Right);