This folder holds the random systems and converters of RandomSystems, typed by
interfaces [3, Definitions 3.8, 3.9, 3.17], [6, §3], [7, Definitions 2.2.1–2.2.2]: interfaces and
their budgets, typed systems and typed converters, attachment, parallel composition and renaming
with their coherence laws, the transcript pseudo-metric, filters, contexts, sources, automata, memoryless and functional
systems, typed games and the typed games presented by discrete games. Its DSL folder holds the
part of the DSL below the front end: the surface syntax, the laws that components sample from,
program bodies and their typed converters, and the tactics for the generated obligations
(GRAMMAR).
Every object here is a systems-level object; the instances of the classes in
ConstructiveCryptography use them as their fields.
Citations refer to the numbered references of THEORY.md.
An interface
A typed system on
Parallel interfaces put the label sets side by side, and
parallel typed systems and parallel typed converters
are the independent parallel compositions; attachment is local,
(⨂ₘ k, α k) • (∥ k, R k) = ∥ k, (α k • R k)
The theorem applies to arbitrary stochastic components. Its
functional corollary assembles supplied
component realization equalities without revisiting their internal transcripts.
The binary bridge uses an explicit alphabet
equivalence; regrouping does not identify different interface types implicitly.
A sample shared outside the whole family remains shared, and an aggregate budget remains
an aggregate restriction rather than a separate full budget for every component.
A label-preserving
bijection of interfaces gives a renaming, which
relabels the transcripts of the typed system it is attached to;
renamings compose, and the renaming by the identity
is the identity. Regrouping three parallel typed systems
keeps the probabilities of the regrouped transcripts, the
dummy system on the interface without labels beside a typed
system keeps its probabilities, on the left and on the
right, and exchanging the two components
of a parallel composition exchanges the labels of its transcripts. The
named unit converters and their inverses retain the existing domains.
Their cancellation and naturality laws live in ConverterCoherence. The regrouping renamings are
natural for typed converters: associativity and the
left and right unit
regroupings commute with parallel typed converters, and the parallel composition of two renamings
is the renaming of their union.
The transcript pseudo-metric on
A typed distinguisher on (d\alpha)(R) = d(\alpha R)$; absorbing the identity
changes nothing, and absorbing a serial composition
absorbs its converters in turn,
The filter admitting id and discard:
projecting S$,
preserves a retained shared draw on
A source answers with fresh independent samples of a law: a
memoryless source [3, Definition 3.1] (the sources of [4, Definition 1] may have memory). An
automaton is a transition function with a sampled initial state
[4, Definition 2], and parallel automata are the automaton
running both side by side from the independent initial law prodProbDist P Q. If two
automata initialized from a common draw init and, at each admitted i(x), draws (s', y) from the normalized kernel step s i x,
retains s', and returns y at i. Its state type may be infinite; each law has finite support.
The constructor uses the existing cumulative random system on the interface's domain.
A kernel simulation preserving an input-history
invariant at admitted queries gives equality of typed systems.
Point transitions recover ofAutomaton.
A memoryless system answers each admitted query i(x)
with a fresh draw from ν i x. In TypedSystem.ofMemoryless A ν, A selects the
interface and its declared domain; it is the one-state automaton
of its reply laws, specializing to point laws for functions.
A source has a
one-state automaton presentation.
Parallel composition combines the components' reply laws.
A bounded program,
port-preserving program or
costed program attached to ofMemoryless B ν
gives ofMemoryless A κ when its one-invocation reply law is κ in every program state. Supply
inside memorylessness as an explicit typed equality. For an own source beside the inside system,
parallel certificates combine their reply laws;
the own-source contract
gives the cumulative form.
For finite independent families, the tagged port selects its
component's fresh reply law; the domain remains Interface.tensorAll of the component domains.
A keyed system retains k ∼ P and replies freshly from ν k i x.
In TypedSystem.keyed P ν, all ports share the retained key; reply draws are independent
conditional on it. keyed_snoc averages the fixed-key transcript/reply products, and
keyed_single gives the existing retained-function presentation.
An automaton retaining its key and drawing each reply from ν k i x
is equal to that keyed system. Program attachment combines
a bounded program with a probabilistic automaton, retaining both states.
Functional systems are given by reply functions, by
conditional reply laws, or by
sampling once and keeping the sample.
The sample is drawn once and shared by all queries, never redrawn: sampling a pushforward
samples once and keeps the image,
TypedSystem.sample_mass_eq_of_sum_relabel,
TypedSystem.sample_mass_eq_of_display_relabel, TypedGame.sample_visible_mass_eq_of_relabel)
equates the visible probabilities whenever each contributing internal history admits its own
sample_fTransform.
A fixed left system in parallel with a sampled right system retains the right-side choice:
The draw is retained for the whole interaction and used only to select
The finite-family collector sends one query to each tagged component
in a supplied order Fin n ≃ K, then returns a function of the dependent reply tuple. Its domain
condition checks each component's mapped outside history. The functional law collects the component
functions; the source law returns fresh independent tuples, also on repeated invocations and for
an empty family. The tuple client exhibits these contracts.
The component context exposes one selected component of a tagged family:
parallelAllContext R k • S = ∥ j, Function.update R k S j. All fixed components retain their
independent state. An explicit renaming identifies the single active interface with the family
whose other members are empty units, preserving the component domains. This equation transports
local replacements through a finite assembly; a selected observer class supplies its own closure
under the context.
For a certified direct call rule, query and return equations against a fixed inside
function
The input routing takes precisely this certificate.
It spends one inside query per outside input, including a pending invocation. For fresh replies
with law
TypedConverter.mapReplies specializes routing to unchanged queries and
reply maps f i : A.Y i → Y. Its outside interface A.withReplies (fun _ => Y) retains
A.domain and the query allowance. mapReplies_smul_ofMemoryless pushes each fresh reply law
forward by f i; mapReplies_smul_source gives source (P.map f) q on the single-port source.
For evaluation ports, Evaluation.mapReplies
provides the corresponding constructor and mapReplies_smul_memorylessSource contract.
TypedConverter.sampleReplies first draws an independent auxiliary
value k ∼ P, then forwards the current query once and returns f i k z on reply z.
The public interfaces keep allowance q i; the auxiliary source has capacity 2 * ∑ i, q i.
sampleReplies_smul_ofMemoryless gives the fresh law
(prodProbDist P (ν i x)).map (fun kz => f i kz.1 kz.2) on each invocation.
The repeated-call client distinguishes these independent
draws from one retained value shared by all calls.
To share one component among tagged callers, erase the caller tag in request and attach the
router to that single system. smul_sample preserves its retained draw. The domain certificate
checks all callers together: Interface.queryBudget_domain_map admits the mapped history when
the outside interface's aggregate bound fits the inside query budget. The
two-caller permutation test checks the sum of caller bounds and
cross-caller inverse consistency, and distinguishes independent parallel copies.
A typed game on