A stateful ordered set realized by a binary search tree #
Clients see finite-set semantics and operation-dependent result types. The representation relation hides the tree's shape. Correctness transfers to every adaptive client through the common stateful calculus; node-visit costs are supplied afterwards as a separate resource certificate.
Main definitions #
Cslib.OrderedSet.spec: the shared representation-independent finite-set specification.step,Exec: concrete tree operations with their exact node-visit charge.realization: the search tree realizes the finite-set interface.
Main results #
exec_visits_le_height: every native operation visits at most the initial tree height.nodeVisitBound: a representation-independent bound by the current set cardinality.realized_client: adaptive clients have correct executions with additive node-visit bounds.
The cardinality bound is deliberately worst-case: these trees have no balancing invariant. The cost model excludes allocation, pure continuations and comparison implementation, and makes no RAM or Turing-machine time claim.
References #
Concrete operation and exact charge in the internal-node-visit model.
Instances For
A native execution records an actual tree operation and its exact node-visit charge.
Instances For
Representation includes both set semantics and strict subtree ordering.
Instances For
Empty trees represent empty sets without an initialization assumption.
Semantic correctness is independent of the later resource certificate.
Instances For
Costs depend on the actual initial tree height, even for an unsuccessful query.
Forgetting shape gives a safe linear bound, not a logarithmic claim.
Every adaptive client has the specified result and final set, together with a bound summing current-set cardinalities along the selected history. Pure continuation evaluation is uncharged.
Execute a client concretely, retaining one exact node-visit count per operation.
Instances For
The executable interpreter supplies native execution evidence rather than assuming it.
Running the concrete interpreter agrees with finite-set semantics and retains its cost bound.