Prerequisites. Direct starred prerequisites: Chapter 134. No later core chapter depends on this route.
A semantics-preservation theorem quantifies over whole programs. Compile a component instead, and link it with a context, and the theorem is silent unless the context is the image of a source context.
Here is what that silence costs. Let a source language have a partial program that receives a boolean or a natural from its context and outputs a natural, and let the target have only naturals, with 𝗍𝗋𝗎𝖾 and 𝖿𝖺𝗅𝗌𝖾 compiled to 0 and 1. Compile 𝑃 =𝑓(𝑥 :𝖡𝗈𝗈𝗅) ↦𝑒 to 𝑃↓ = 𝑓(𝑥:𝖭𝖺𝗍)↦𝐢𝐟 𝑥<2 𝐭𝐡𝐞𝐧 𝑒↓ 𝐞𝐥𝐬𝐞 𝐢𝐟 𝑥<3 𝐭𝐡𝐞𝐧 𝑓(𝑥) 𝐞𝐥𝐬𝐞 42. On an input a source context could have produced — 0 or 1 — the compiled function runs the compiled body. On the input 2 it diverges, and on every larger input it outputs 42, whatever 𝑃 was. A whole-program correctness theorem is untouched: no whole source program ever supplies 2. A user linking 𝑃 ↓ with untrusted target code has lost every guarantee 𝑃 had.
The question this chapter answers is what a compiler must satisfy so that a property of the source component survives linking with an arbitrary target context, and how the resulting criteria are related to each other and to full abstraction. The development follows Abate, Blanco, Garg, Hriţcu, Patrignani and Thibault (2019).
The setting
A partial program 𝑃 is linked with a context 𝐶 to form a whole program 𝐶[𝑃]. Write 𝐶𝑆 for source contexts, 𝐶𝑇 for target contexts, and 𝑃 ↓ for the compilation of 𝑃. Fix a set Trace of traces, each recording the observable events of one execution, together with a set of finite prefixes ordered by 𝑚 ≤𝑡 (“𝑚 is a prefix of 𝑡”). Write 𝐶[𝑃] ⇓𝑡 when the whole program 𝐶[𝑃] can produce the trace 𝑡, and 𝐶[𝑃] ⇓𝑚 when it can produce a finite prefix 𝑚.
Referenced from 2 locations
A trace property is a set 𝜋 ⊆Trace. A hyperproperty is a set 𝐻 of sets of traces. The behaviour of a whole program is Behav(𝑊) ={𝑡 ∣𝑊 ⇓𝑡}; the program satisfies 𝐻 when Behav(𝑊) ∈𝐻.
Referenced from 2 locations
The distinction is the one that makes the chapter necessary. A trace property is satisfied or violated by one execution; a hyperproperty may require comparing two, as noninterference does.
Robust preservation of trace properties
A compilation chain satisfies RTP when for every 𝜋 ⊆Trace and every partial program 𝑃, (∀𝐶𝑆,𝑡. 𝐶𝑆[𝑃]⇓𝑡⟹𝑡∈𝜋)⟹(∀𝐶𝑇,𝑡. 𝐶𝑇[𝑃↓]⇓𝑡⟹𝑡∈𝜋).
Referenced from 5 locations
Definition 136.3 quantifies over all properties, which makes it awkward to prove for a particular compiler. It has an equivalent statement that mentions no property at all.
A compilation chain satisfies RTC when ∀𝑃,𝐶𝑇,𝑡.𝐶𝑇[𝑃↓]⇓𝑡⟹∃𝐶𝑆. 𝐶𝑆[𝑃]⇓𝑡.
Referenced from 4 locations
RTP holds if and only if RTC holds.
Referenced from 7 locations
Proof of Theorem 136.5 — RTP and RTC are equivalent
Proof. The mechanism is worth naming once, because every other equivalence in this chapter uses it: from RTP to RTC one instantiates the universally quantified property with the strongest property the source program robustly satisfies; from RTC to RTP one uses the produced source context to transport the hypothesis.
RTP ⟹ RTC. Fix 𝑃, and apply RTP to the property 𝜋0 ={𝑡 ∣∃𝐶𝑆. 𝐶𝑆[𝑃] ⇓𝑡}. Its hypothesis is ∀𝐶𝑆,𝑡. 𝐶𝑆[𝑃] ⇓𝑡 ⟹ ∃𝐶′𝑆. 𝐶′𝑆[𝑃] ⇓𝑡, which holds by taking 𝐶′𝑆 =𝐶𝑆. Its conclusion is ∀𝐶𝑇,𝑡. 𝐶𝑇[𝑃 ↓] ⇓𝑡 ⟹ 𝑡 ∈𝜋0, and 𝑡 ∈𝜋0 is by definition the existence of a source context producing 𝑡. That is RTC.
RTC ⟹ RTP. Fix 𝜋 and 𝑃 and assume ∀𝐶𝑆,𝑡. 𝐶𝑆[𝑃]⇓𝑡⟹𝑡∈𝜋. Take any 𝐶𝑇 and 𝑡 with 𝐶𝑇[𝑃 ↓] ⇓𝑡. By RTC there is 𝐶𝑆 with 𝐶𝑆[𝑃] ⇓𝑡, and (136.1) instantiated at that 𝐶𝑆 and 𝑡 gives 𝑡 ∈𝜋. ◻
Theorem 136.5 is what makes the criterion usable: to establish RTP one exhibits, for each target context, a source context that explains the same trace. Constructing that source context is called back-translation, and section 136.6 describes the two shapes it takes.
Safety, density, and their criteria
Safety={𝜋∣∀𝑡∉𝜋. ∃𝑚≤𝑡. ∀𝑡′≥𝑚. 𝑡′∉𝜋},Dense={𝜋∣every terminating 𝑡 lies in 𝜋}.
Referenced from 4 locations
A safety property is refuted by a finite prefix: once the bad prefix has occurred, no continuation repairs it. A dense property can be refuted only by an infinite trace, and plays here the role liveness plays elsewhere.
RSP and RDP are definition 136.3 with 𝜋 restricted to Safety and to Dense respectively. RSC is ∀𝑃,𝐶𝑇,𝑚. 𝐶𝑇[𝑃 ↓] ⇓𝑚 ⟹ ∃𝐶𝑆. 𝐶𝑆[𝑃] ⇓𝑚, quantifying over finite prefixes; RDC is definition 136.4 with 𝑡 restricted to infinite traces.
Referenced from 3 locations
RSP holds if and only if RSC does, and RDP holds if and only if RDC does.
Referenced from 6 locations
Proof of Theorem 136.8 — Both characterizations are equivalent to their criteria
Proof. RSP ⟹ RSC. Fix 𝑃 and a finite prefix 𝑚0 with 𝐶𝑇[𝑃 ↓] ⇓𝑚0, and suppose no source context produces 𝑚0. Put 𝜋1 ={𝑡 ∣𝑚0 ≰𝑡}. Then 𝜋1 ∈Safety: if 𝑡 ∉𝜋1 then 𝑚0 ≤𝑡, and every 𝑡′ ≥𝑚0 also fails 𝜋1, so 𝑚0 is the required bad prefix. The hypothesis of RSP at 𝜋1 holds, since a source context producing some 𝑡 ≥𝑚0 would produce the prefix 𝑚0, contrary to assumption. Its conclusion applied to the target trace extending 𝑚0 gives a trace in 𝜋1 that has 𝑚0 as a prefix, a contradiction. So some source context produces 𝑚0.
RSC ⟹ RSP. Fix 𝜋 ∈Safety, 𝑃 satisfying (136.1), a target context 𝐶𝑇 and a trace 𝑡 with 𝐶𝑇[𝑃 ↓] ⇓𝑡; suppose 𝑡 ∉𝜋. Safety gives a bad prefix 𝑚 ≤𝑡 with every extension outside 𝜋. Since 𝐶𝑇[𝑃 ↓] produces 𝑡, it produces 𝑚, so RSC gives 𝐶𝑆 with 𝐶𝑆[𝑃] ⇓𝑚. Extend: 𝐶𝑆[𝑃] produces some 𝑡′ ≥𝑚, and (136.1) puts 𝑡′ ∈𝜋, contradicting the choice of 𝑚. Hence 𝑡 ∈𝜋.
RDP ⟺ RDC. The same two moves with 𝜋0 replaced by 𝜋2 ={𝑡 ∣𝑡 terminating} ∪{𝑡 ∣∃𝐶𝑆. 𝐶𝑆[𝑃] ⇓𝑡}, which is dense by construction, and with the observation that a dense property is violated only by a non-terminating trace, so only infinite traces need explaining. ◻
Every trace property is the intersection of a safety property and a dense property.
Referenced from 7 locations
Proof of Theorem 136.9 — Decomposition
Proof. Let 𝜋 be arbitrary. Put 𝑆(𝜋) ={𝑡 ∣∀𝑚 ≤𝑡. ∃𝑡′ ≥𝑚. 𝑡′ ∈𝜋} and 𝐷(𝜋) =𝜋 ∪{𝑡 ∣𝑡 ∉𝑆(𝜋)}.
𝑆(𝜋) is safety: if 𝑡 ∉𝑆(𝜋) there is 𝑚 ≤𝑡 with no extension in 𝜋; every 𝑡′ ≥𝑚 then also has 𝑚 as a prefix with no extension in 𝜋, so 𝑡′ ∉𝑆(𝜋).
𝐷(𝜋) is dense once terminating traces are read as those with a maximal finite prefix: a terminating 𝑡 either lies in 𝜋 or has a prefix with no extension in 𝜋, and in the second case 𝑡 ∉𝑆(𝜋), so 𝑡 ∈𝐷(𝜋).
Finally 𝑆(𝜋) ∩𝐷(𝜋) =𝜋. For ⊆: if 𝑡 ∈𝑆(𝜋) and 𝑡 ∈𝐷(𝜋), the second gives 𝑡 ∈𝜋 or 𝑡 ∉𝑆(𝜋), and the first excludes the alternative. For ⊇: 𝑡 ∈𝜋 gives 𝑡 ∈𝐷(𝜋) immediately, and 𝑡 ∈𝑆(𝜋) because every prefix of 𝑡 extends to 𝑡 itself. ◻
Theorem 136.9 says that RSP and RDP together are not weaker than RTP for a fixed property — the property splits — but it does not say that the two criteria imply RTP, because the hypothesis of RTP at 𝜋 does not give the hypotheses at 𝑆(𝜋) and 𝐷(𝜋) separately.
★★☆ Exhibit 𝜋, a program 𝑃 and a source context showing that “𝑃 robustly satisfies 𝜋” does not imply “𝑃 robustly satisfies 𝑆(𝜋) and 𝑃 robustly satisfies 𝐷(𝜋)” — or prove that it does. State which direction of theorem 136.9 your answer uses.
Referenced from 2 locations
Hyperproperties
RHP holds when for every hyperproperty 𝐻 and every 𝑃, (∀𝐶𝑆. Behav(𝐶𝑆[𝑃]) ∈𝐻) ⟹ (∀𝐶𝑇. Behav(𝐶𝑇[𝑃 ↓]) ∈𝐻). Its characterization RHC is ∀𝑃,𝐶𝑇. ∃𝐶𝑆. Behav(𝐶𝑇[𝑃↓])=Behav(𝐶𝑆[𝑃]). RSCHP restricts 𝐻 to the subset-closed hyperproperties SC ={𝐻 ∣𝑏1 ⊆𝑏2 ∈𝐻 ⟹ 𝑏1 ∈𝐻}, and its characterization RSCHC replaces the equality above by ∀𝑡. 𝐶𝑇[𝑃 ↓] ⇓𝑡 ⟹ 𝐶𝑆[𝑃] ⇓𝑡.
Referenced from 4 locations
RHP ⟺ RHC and RSCHP ⟺ RSCHC.
Referenced from 6 locations
Proof of Theorem 136.11
Proof. RHP ⟹ RHC. Fix 𝑃 and apply RHP to 𝐻0 ={𝑏 ∣∃𝐶𝑆. 𝑏 =Behav(𝐶𝑆[𝑃])}, whose hypothesis holds by taking the same context. The conclusion says that every target context’s behaviour is some source context’s behaviour, which is RHC.
RHC ⟹ RHP. Given 𝐻, 𝑃 with Behav(𝐶𝑆[𝑃]) ∈𝐻 for all 𝐶𝑆, and any 𝐶𝑇, RHC supplies 𝐶𝑆 with equal behaviour, so Behav(𝐶𝑇[𝑃 ↓]) ∈𝐻.
The subset-closed pair is the same argument with 𝐻1 ={𝑏 ∣∃𝐶𝑆. 𝑏 ⊆Behav(𝐶𝑆[𝑃])}, which is subset-closed, in place of 𝐻0; the conclusion then gives an inclusion rather than an equality, and in the converse direction subset-closure of 𝐻 is what turns the inclusion supplied by RSCHC into membership. ◻
Full abstraction is a different criterion
OEP holds when 𝑃1 ≈ctx𝑃2 implies 𝑃1 ↓ ≈ctx𝑃2 ↓, where ⋅ ≈ctx ⋅ is contextual equivalence. It is the security-relevant half of full abstraction.
Referenced from 3 locations
For determinate languages contextual equivalence coincides with equality of the trace sets produced in all contexts, so OEP coincides with robust preservation of trace equivalence. How that criterion relates to the ones above it is not what one might expect, and the next theorem settles one direction.
There is a compiler between two deterministic languages that satisfies OEP and is correct — it preserves whole-program behaviour and compiles separately — and does not satisfy RSP.
Referenced from 8 locations
Proof of Theorem 136.14 — Full abstraction does not imply robust safety preservation
Proof. The compiler is the one displayed in the opening. Source partial programs take a boolean or a natural from the context and output naturals; the target has only naturals; 𝗍𝗋𝗎𝖾 and 𝖿𝖺𝗅𝗌𝖾 compile to 0 and 1; and a boolean-accepting 𝑃 =𝑓(𝑥 :𝖡𝗈𝗈𝗅) ↦𝑒 compiles to 𝑃↓=𝑓(𝑥:𝖭𝖺𝗍)↦𝐢𝐟 𝑥<2 𝐭𝐡𝐞𝐧 𝑒↓ 𝐞𝐥𝐬𝐞 𝐢𝐟 𝑥<3 𝐭𝐡𝐞𝐧 𝑓(𝑥) 𝐞𝐥𝐬𝐞 42.
Correctness. A whole source program supplies only 𝗍𝗋𝗎𝖾 or 𝖿𝖺𝗅𝗌𝖾, hence only 0 or 1, so the first branch is taken and the compiled program runs 𝑒 ↓. Compilation is compositional in the function definitions, so separate compilation holds.
OEP. Let 𝑃1 and 𝑃2 be contextually equivalent source programs. A target context can feed 𝑃1 ↓ and 𝑃2 ↓ an input below 2, where both behave as the corresponding source programs under the corresponding source context and are therefore indistinguishable; the input 2, where both diverge; or an input above 2, where both output 42. In every case the two compiled programs agree, so they are contextually equivalent.
Failure of RSP. Take 𝑃 =𝑓(𝑥 :𝖡𝗈𝗈𝗅) ↦0 and the safety property 𝜋 ={𝑡 ∣𝑡 contains no output 42}. Every source context linked with 𝑃 produces the single output 0, so 𝑃 robustly satisfies 𝜋. The target context supplying 3 makes 𝑃 ↓ output 42, violating 𝜋. Hence RSP fails. ◻
Theorem 136.14 is the reason the chapter’s criteria are not a reformulation of full abstraction. Full abstraction constrains only which programs the target can distinguish; it permits the compiled program to do anything at all, provided it does the same anything to equivalent programs.
Assume the source language is determinate and the target has a determinate, input-total small-step semantics. Then robust preservation of two-relational relaxed safety implies robust trace-equivalence preservation, and hence OEP.
Referenced from 5 locations
This is Theorem 5.1 of the frozen source, with the mechanized proof in its Coq development. It is imported at exactly those hypotheses: determinacy of both languages, input totality of the target — if the target accepts one input value it accepts every other — and the property, also proved there, that a whole program producing every finite prefix of an infinite trace produces that trace. Nothing weaker is claimed, and no direction of theorem 136.14 is affected by it.
★★☆ Show that RHC implies OEP for determinate languages, and then say precisely which step of your argument fails if one tries to run it backwards to derive RHC from OEP.
Referenced from 2 locations
★★☆ Repair the compiler of theorem 136.14 so that it satisfies RSP, and check that your repair still satisfies OEP and whole-program correctness. Then say what your repair costs at run time.
Referenced from 3 locations
Back-translation
The characterizations of section 136.2, section 136.4 all require producing a source context from a target context. Two techniques do this, and they trade strength for generality.
A universal embedding is a map from target contexts to source contexts such that the source context, linked with 𝑃, produces exactly the behaviour the target context produces with 𝑃 ↓. A compilation chain with a universal embedding satisfies RHC, and therefore every criterion below it.
Referenced from 2 locations
A trace-based back-translation maps a finite set of finite execution prefixes to a source context that reproduces them. It yields the criteria whose characterizations quantify only over finite prefixes: the criterion RSC, its 𝐾-relational strengthenings, and the relaxed-safety criterion of theorem 136.15. It therefore yields robust preservation of safety, of hypersafety, and of trace equivalence, and no criterion above those.
Referenced from 2 locations
The trade is exact. The first technique must embed an arbitrary target context, which requires knowing enough about the target language to simulate all of it; the second only has to replay a finite interaction, so it depends on the calls-and-returns interface between context and program and on nothing else. The first yields the strongest criterion; the second does not yield RHC.
★★☆ Given a trace-based back-translation for single finite prefixes, construct one for finite sets of finite prefixes, or show what extra hypothesis on the source language is needed. (Two lines if the source language has a case analysis on the first event.)
Referenced from 2 locations
Limits and seminar
The frozen source is Abate, Blanco, Garg, Hriţcu, Patrignani and Thibault (2019). Definition 136.3, Definition 136.4, Definition 136.6, Definition 136.7, Definition 136.10, Definition 136.13 and theorem 136.5, theorem 136.8, theorem 136.11, theorem 136.14, theorem 136.15 are its definitions and theorems, at their exact statements; the proofs of theorem 136.5, theorem 136.8, theorem 136.11, theorem 136.14 are written out here. Theorem 136.9 is its Theorem B.7, proved here. Theorem 136.15 is imported and not reproved.
Five boundaries. First, every criterion is a statement about a compilation chain and a fixed notion of trace; changing what an event records changes every criterion, and no result here says which events a real compiler should emit. Second, none of the criteria is a theorem about any particular compiler: this chapter proves equivalences between criteria and one separation, and exhibits no verified secure compiler. Third, the criteria say nothing about cost: a compiler can satisfy RSP by inserting arbitrary dynamic checks, and exercise 136.3 is exactly that observation. Fourth, theorem 136.14 separates full abstraction from robust safety preservation for determinate languages only; the relationship in the presence of internal nondeterminism is not settled here. Fifth, the two back-translation techniques of section 136.6 are described, not carried out: no universal embedding is constructed in this chapter.
[4]
Suggested first pass.
None of these problems is a prerequisite for a later chapter. Begin with exercise 136.5, then complete exercise 136.8.
★★☆ Order RTP, RSP, RDP, RHP and RSCHP by implication, proving each implication from the property-free characterizations and giving a counterexample chain for each non-implication you claim. State which orderings your argument leaves open.
Referenced from 3 locations
★★★ Termination-insensitive noninterference is a hyperproperty, not a trace property. Write it as a set of sets of traces for a language whose events record public outputs, show that it is subset-closed, and conclude which of the criteria of this chapter suffice to preserve it robustly. Then exhibit a compiler satisfying RSP that does not preserve it.
Referenced from 2 locations
★★★ For a source language with first-order functions over naturals and a target that adds arbitrary jumps, sketch a universal embedding of target contexts into source contexts, or identify the target feature that makes one impossible. If it is impossible, give the strongest criterion of this chapter that a trace-based back-translation still yields.
Referenced from 2 locations
★★★ Practical project.sec-criteria-checker Complete project sec-criteria-checker. For a finite model — a finite set of traces, finitely many source and target contexts, and a table giving the traces each linked program produces — implement (i) the predicates Safety and Dense of definition 136.6, (ii) the criteria RTP, RSP and RHP and the characterizations RTC, RSC and RHC by exhaustive search over the finite model, and (iii) the decomposition 𝜋 ↦(𝑆(𝜋),𝐷(𝜋)) of theorem 136.9. The invariant the implementation must maintain is that on every model in the fixture the criterion and its characterization agree, which is theorem 136.5, theorem 136.8, theorem 136.11 restricted to that model. The named cases print
rtp-iff-rtc: ok
rsp-iff-rsc: ok
rhp-iff-rhc: ok
decomposition: ok
fa-model-violates-rsp: confirmed
The checker is independent evidence on the finite models in the fixture; it does not prove theorem 136.5, theorem 136.8, theorem 136.11, theorem 136.9, which quantify over all traces and all properties, and it contains no compiler, no back-translation and no infinite traces.
Referenced from 3 locations