Compile–Trace–Filter Framework
- CTF is a framework that defines compiler correctness by relating source and target traces through configurable trace relations and filters.
- It addresses semantic mismatches such as undefined behavior, resource exhaustion, and side channels with precise filtering mechanisms.
- CTF enables systematic property preservation between source and target domains, thus supporting secure compilation through trace mapping.
The Compile–Trace–Filter (CTF) framework provides a generalized and parametric approach to compiler correctness and secure compilation for settings in which the set of traces produced by the source language and the target language differ in structure or granularity. Instead of requiring trace equality, as in classical trace-inclusion definitions, CTF makes explicit how a compiler can remain correct by relating source and target traces through an arbitrary trace relation, and by using an associated filter to connect target traces back to source trace semantics. This methodology accommodates a range of semantic mismatches, including undefined behavior, resource exhaustion, differing trace alphabets, and (computational) side-channels (Abate et al., 2019).
1. Core Components of the CTF Framework
CTF analysis is anchored in the following core elements:
- Source and Target Traces: A source language is associated with a set of traces , and the compiled target language with traces .
- Trace Relation : A relation links possible source executions with corresponding target executions, potentially permitting translations that introduce or filter events (e.g., markers for undefined behavior).
- Compiler and Semantics: The compiler is equipped with operational semantics for both languages, for the source and for the target, where , .
- Filter : For each target trace , the filter returns all source traces such that .
The CTF pipeline is therefore: .
2. Generalized Compiler Correctness via Trace Relations
Classical compiler correctness is often defined by trace inclusion: every trace of the compiled program must be a trace of the original program, which presumes that the trace sets of source and target are identical. The CTF framework generalizes this through:
Definition 1 (Trace-Relating Filter Relation):
A CTF relation is any .
Definition 2 (CTF-Correctness):
The compiler is -correct if for all source programs and for every ,
This asserts that every target trace for a compiled program corresponds, under , to a source trace for the original program.
3. Property Preservation and Transformation
CTF theory provides systematic tools for lifting properties between source and target trace domains using :
- Existential Image :
Given a property , the corresponding set of target traces is
This captures the set of traces that "come from" some source trace satisfying .
- Universal Image :
For a target property ,
This is the set of source traces all whose -related target traces lie in .
These two maps are adjoint: , forming a Galois connection with respect to set inclusion.
The filter can be viewed as the pointwise preimage of .
4. Handling Semantic Mismatches via CTF
CTF is designed to account explicitly for differences between trace alphabets. For example:
- Undefined Behavior (UB): Let be a special undefined-behavior event. Define
The filter removes everything after the first event in the source, so any arbitrary continuation after UB in the target is "dropped."
- Resource Exhaustion: For ,
Here, returns the maximal source prefix corresponding to an out-of-memory target trace.
- Side Channels: If , can specify , and simply projects away the timing information .
CTF thereby provides a rigorous mechanism for formally relating and filtering semantic artifacts that arise during compilation.
5. Concrete Example: Filtering Side-Channel Metadata
Consider a simple source language with input-output semantics. Suppose a source program produces traces and .
Suppose the compiler emits an extra secret-tag event before each output:
Define such that iff with all events deleted equals . The filter projects away the secret-ok tags, enabling property transfer even in the presence of such metadata.
6. Central Theorems and Robustness
The main theorems underpinning CTF establish the equivalence between -correctness and property preservation:
Theorem 4 (CTF-Correctness Property Preservation):
Let with Galois connection . The following are equivalent:
- a) CTF-correctness relative to
- b) Source-to-target trace-property preservation ()
- c) Target-to-source trace-property reflection ()
Moreover, corollaries transfer safety properties through safety-closure and image operators. CTF robustly generalizes to secure compilation in the presence of adversarial linking contexts.
7. Algorithmic Realization of the CTF Filter
Given a relation on events , the filter operates by searching for all source traces such that, proceeding eventwise along a target trace , the pair for all . In many cases a deterministic event-filter suffices, so that computes the source projection by dropping any -event mapped to and mapping the rest to the appropriate -event (Abate et al., 2019).
Summary Table: CTF Key Concepts
| Component | Role | Example |
|---|---|---|
| Trace Relation | Relate source and target traces | |
| Filter | Recovers source traces from a target trace | Removes UB suffixes, OOM markers, or secret tags |
| Existential Image | Lifts source properties to target trace properties | Allows secret tags without breaking output property |
| Universal Image | Reflects target properties to source preconditions | Dually computes sufficient source properties |
The CTF framework, as introduced by Abate et al., systematizes reasoning about trace-relating compiler correctness, clarifies property preservation under trace transformations, and provides robust abstractions for secure compilation in the presence of observable semantic mismatches (Abate et al., 2019).