On this page
Verada.Containers.Functional.Sets
Ghost extensional finite sets.
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
Enumeration positions have no semantic order. Add requires absent, Remove present, Choose nonempty. Union has a conservative length bound.
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.Sets;
package Instance_Name is new Verada.Containers.Functional.Sets (Integer);import Verada.Containers.Functional.Sets;
package Instance_Name = new Verada.Containers.Functional.Sets<Integer>;
A Vibe module imports this unit's names with from Verada.Containers.Functional.Sets import Name; 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
Generic formals (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.
Ghost: for contracts and ghost code, and left out of the program.
Declared interface:
generic
type Element_Type is private;API 002
Set (declaration) — Private ghost finite set with extensional membership equality; enumeration positions have no sorted or insertion-order meaning.
Ghost: for contracts and ghost code, and left out of the program.
Declared interface:
type Set is private;API 003
Length (declaration) — Observe the logical length/cardinality, not backing capacity or physical allocation size.
Ghost: for contracts and ghost code, and left out of the program.
API 004
Element (declaration) — Read an existing logical element; the required index/cursor/presence condition is distinct from the index type's capacity bound.
Before this operation, establish:
Position <= Length (Container)Ghost: for contracts and ghost code, and left out of the program.
API 005
Contains (declaration) — Test the family's declared membership/search relation; it is not a mutation or a guarantee of constant-time lookup.
Ghost: for contracts and ghost code, and left out of the program.
API 006
Is_Empty (declaration) — Test whether logical length is zero; this is safe before an element selection.
Ghost: for contracts and ghost code, and left out of the program.
API 007
Empty_Set (declaration) — Construct the empty ghost set.
On normal return the declared contract establishes:
Length (Empty_Set'Result) = 0Ghost: for contracts and ghost code, and left out of the program.
API 008
"<=" (declaration) — The declared comparison: ordinary numeric order, sequence prefix, set inclusion or map-pair inclusion according to the parameter types.
Ghost: for contracts and ghost code, and left out of the program.
API 009
"=" (declaration) — Equality in this declared value/model domain; the family defines whether sequence order, set membership, map pairs or logical text contents are compared.
Ghost: for contracts and ghost code, and left out of the program.
API 010
Included_Except (declaration) — Permit the named item as the only exception to a source subset relation.
Ghost: for contracts and ghost code, and left out of the program.
API 011
Included_In_Union (declaration) — Constrain every container member to belong to at least one source set.
Ghost: for contracts and ghost code, and left out of the program.
API 012
Includes_Intersection (declaration) — Require every common member of two source sets to occur in the destination.
Ghost: for contracts and ghost code, and left out of the program.
API 013
No_Overlap (declaration) — State that the sets have no common members.
Ghost: for contracts and ghost code, and left out of the program.
API 014
Add (declaration) — Return a new ghost model with an appended/new entry, leaving the input value unchanged; absence/capacity requirements still apply.
Before this operation, establish:
not Contains (Container, Item) and then Length (Container) < Natural'LastOn normal return the declared contract establishes:
Length (Add'Result) = Length (Container) + 1
and then Contains (Add'Result, Item)
and then Container <= Add'Result
and then Included_Except (Add'Result, Container, Item)Ghost: for contracts and ghost code, and left out of the program.
API 015
Remove (declaration) — Return/remove the selected present entry according to this family; ghost functional updates return a new value while arena mutation invalidates its handle.
Before this operation, establish:
Contains (Container, Item)On normal return the declared contract establishes:
Length (Remove'Result) = Length (Container) - 1
and then not Contains (Remove'Result, Item)
and then Remove'Result <= Container
and then Included_Except (Container, Remove'Result, Item)Ghost: for contracts and ghost code, and left out of the program.
API 016
Union (declaration) — Return a ghost set containing exactly the source union as constrained by its inclusion predicates; satisfy its conservative length guard.
Before this operation, establish:
Length (Left) <= Natural'Last - Length (Right)On normal return the declared contract establishes:
Left <= Union'Result
and then Right <= Union'Result
and then Included_In_Union (Union'Result, Left, Right)Ghost: for contracts and ghost code, and left out of the program.
API 017
Intersection (declaration) — Return a ghost set of members common to both sources.
On normal return the declared contract establishes:
Intersection'Result <= Left
and then Intersection'Result <= Right
and then Includes_Intersection (Intersection'Result, Left, Right)Ghost: for contracts and ghost code, and left out of the program.
API 018
Choose (declaration) — Return a member/key from a nonempty ghost set/map; no selection order is promised.
Before this operation, establish:
not Is_Empty (Container)On normal return the declared contract establishes:
Contains (Container, Choose'Result)Ghost: for contracts and ghost code, and left out of the program.