Skip to content

Latest commit

 

History

History
378 lines (348 loc) · 24.3 KB

README.md

File metadata and controls

378 lines (348 loc) · 24.3 KB

Typed systems

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.

Interfaces, typed systems and typed converters

An interface $A = (I, X, Y, D)$ has finitely many labels, finite alphabets $X_i, Y_i$, and a domain $D$ of input histories, prefix-closed, without the empty history, of bounded length. Two domains recur: the query budget $D = \lbrace h \ne \varepsilon \mid \lvert h \rvert \le q \rbrace$ and the per-port budget $D = \lbrace h \ne \varepsilon \mid \forall i.\ \lvert h \restriction i \rvert \le q_i \rbrace$, where $h \restriction i$ keeps the inputs at the label $i$.

A typed system on $A$ is a random system on $(\Sigma_i X_i, \Sigma_i Y_i)$ over $D$, replying at the queried label. A typed converter from $A$ to $B$ is a PDC behavior from $B$'s domain (inside) to $A$'s domain (outside), and a DDC between the two domains is one. Typed converters compose by the serial composition of PDC behaviors, with the identity PDC behavior. Attachment $\alpha R$ is the attachment of the PDC behavior: the identity leaves a typed system unchanged, and a serial composition attaches its inner converter first. A DDC equal to the trimmed serial wiring of $\alpha$ (outside) and $\beta$ (inside) gives their composition as typed converters, even when its own query bound is not the product of theirs.

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, $(\alpha \otimes \beta)(R \parallel S) = \alpha R \parallel \beta S$. The finite tagged interface family, its independent system family, and its independent converter family extend these objects to heterogeneous component interfaces. A fixed function on the combined interface assembles from its component functions. Independent deterministic component presentations combine through parallelAllPDS, which presents the same typed system as the n-ary parallel behavior. General locality attaches independently sampled converters to independently sampled resources component by component:

(⨂ₘ 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.

Distance

The transcript pseudo-metric on $A$ is the transcript distance of the random systems, $d(R, S) = \Delta(R, S)$, with its laws from the supremum over compatible stopping distinguisher behaviors [1, Definition 11]. Zero distance is not equality. It is an explicit structure, not a global instance; the CC instance selects it as its metric.

Typed distinguishers

A typed distinguisher on $A$ is the decision behavior $R \mapsto \Pr[d(R) = 1]$ of a stopping distinguisher compatible with $A$'s domain: an abbreviation of the existing distinguisher behaviors, with no new carrier or equivalence. Absorbing a typed converter $\alpha : A \to B$ gives the distinguisher $d\alpha$ on $B$ with $(d\alpha)(R) = d(\alpha R)$; absorbing the identity changes nothing, and absorbing a serial composition absorbs its converters in turn, $d(\alpha\beta) = (d\alpha)\beta$. These are laws of the action only: a selected set of typed distinguishers need not be closed under absorption.

Filters, contexts, sources and functional systems

The filter admitting $D$ forwards the queries of admitted histories; it is a typed converter $(A \restriction D) \to A$ from the restricted interface. Attached to a typed system, it is the restriction of the system's random system to the restricted domain, and two filters in series act as the filter of both conditions. A constant converter ignores its inside system and exposes a fixed one, and the fixed right and left contexts run a typed system beside: attaching $\mathrm{rightContext}\ A\ S$ to $R$ gives $R \parallel S$, and so does attaching $\mathrm{leftContext}\ R\ B$ to $S$. Dually, the ordered left and right projections combine the inverse unit renamings with id and discard: projecting $R \parallel S$ returns $R$ or $S$, preserves a retained shared draw on $\mathrm{sample}(P, k \mapsto R_k \parallel S_k)$ (and on the right), and is natural with respect to parallel converters (and on the right).

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 $\omega \sim P$ give the same deterministic system for every $\omega$, then their sampled automata are equal typed systems on the interface's domain. A bisimulation for each draw thus yields an equation of typed systems, which rewrites under attachment and parallel composition. A probabilistic automaton starts from a normalized law 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, $\mathrm{sample}(f(P), R) = \mathrm{sample}(P, R \circ f)$, and attachment commutes with the single draw, $\alpha\, \mathrm{sample}(P, R) = \mathrm{sample}(P, k \mapsto \alpha R_k)$. When hidden reply components produce several internal histories for one visible transcript $h$, per-history draw relabeling (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 $P$-preserving relabeling on $\operatorname{supp} P$. Two independent initial choices can be grouped as a product or sampled in either order: the second sampling law is fixed, independently of the first value. The laws may be nonuniform and the sample types infinite; only their supports are finite. Product regrouping follows from the product-weighted sum, and reordering follows by swapping the product coordinates and applying sample_fTransform.

A fixed left system in parallel with a sampled right system retains the right-side choice:

$$R \parallel \operatorname{sample}(P,S) = \operatorname{sample}(P, k \mapsto R \parallel S_k).$$

The draw is retained for the whole interaction and used only to select $S_k$. The same left system $R$ is used for every $k$, with its own independent randomness. An environment may still adapt queries using either component's replies.

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 $f$ yield the outside functional system; later inside queries of an invocation may depend on its earlier replies. An input-dependent router can move a payload field into the inside port label; its typed attachment returns the explicitly translated inside answer at the original outside port. Writing $\operatorname{request}(u) = (j,x)$, the outside function is

$$g(u) = \operatorname{answer}\bigl(u,(j,f_j(x))\bigr).$$

The input $u$ is retained until the inside reply arrives. For outside domain $F$ and inside domain $E$, the domain guarantee follows from $F(us) \Rightarrow E(\operatorname{map}(\operatorname{request},us))$. The typed constructor routing takes precisely this certificate. It spends one inside query per outside input, including a pending invocation. For fresh replies with law $\nu_j(x)$, its memoryless attachment law pushes that law forward through $y \mapsto \operatorname{answer}(u,(j,y))$. The input-encoding and output-projection clients use this law on a restricted inside domain.

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.

Typed games

A typed game on $A$ is a typed system on the interface of $A$ with the MBO whose MBO, once set, stays set: a game in the sense of Game. A typed converter attaches to it through its MBO-forwarding lift, and its visible typed system is its visible system. A discrete game whose visible systems present a typed system $R$ presents a typed game on the interface of $R$, with visible typed system $R$. A single-label sampled function with a hidden condition presents a typed game whose random system is conditionally equivalent to that of the typed system sampling the ideal function, under the fixed-query factorization.