Papers
Topics
Authors
Recent
Search
2000 character limit reached

Compile–Trace–Filter Framework

Updated 21 January 2026
  • 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 TraceS\mathit{Trace}_S, and the compiled target language with traces TraceT\mathit{Trace}_T.
  • Trace Relation RR: A relation RTraceS×TraceTR \subseteq \mathit{Trace}_S \times \mathit{Trace}_T 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 :ProgramSProgramT\downarrow : \mathit{Program}_S \to \mathit{Program}_T is equipped with operational semantics for both languages, PSs\langle P \rangle_S \Downarrow s for the source and PTt\langle P \rangle_T \Downarrow t for the target, where sTraceSs \in \mathit{Trace}_S, tTraceTt \in \mathit{Trace}_T.
  • Filter FF: For each target trace tt, the filter FF returns all source traces ss such that (s,t)R(s, t) \in R.

The CTF pipeline is therefore: PsrcPtgtFsource trace candidatesP_{src} \xrightarrow{\downarrow} P_{tgt} \xrightarrow{F} \text{source trace candidates}.

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 RTraceS×TraceTR \subseteq \mathit{Trace}_S \times \mathit{Trace}_T.

Definition 2 (CTF-Correctness):

The compiler \downarrow is RR-correct if for all source programs PP and for every tTraceTt \in \mathit{Trace}_T,

PTt    sTraceS.(s,t)RPSs\langle \downarrow P \rangle_T \Downarrow t \implies \exists s \in \mathit{Trace}_S. (s, t) \in R \wedge \langle P \rangle_S \Downarrow s

This asserts that every target trace for a compiled program corresponds, under RR, 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 RR:

  • Existential Image τ\tau:

Given a property ΠSTraceS\Pi_S \subseteq \mathit{Trace}_S, the corresponding set of target traces is

τ(ΠS)={tTraceTsΠS.(s,t)R}\tau(\Pi_S) = \{\, t \in \mathit{Trace}_T \mid \exists s \in \Pi_S .\, (s, t) \in R \,\}

This captures the set of traces that "come from" some source trace satisfying ΠS\Pi_S.

  • Universal Image σ\sigma:

For a target property ΠTTraceT\Pi_T \subseteq \mathit{Trace}_T,

σ(ΠT)={sTraceSt.(s,t)RtΠT}\sigma(\Pi_T) = \{\, s \in \mathit{Trace}_S \mid \forall t .\, (s, t) \in R \Rightarrow t \in \Pi_T \,\}

This is the set of source traces all whose RR-related target traces lie in ΠT\Pi_T.

These two maps are adjoint: τσ\tau \dashv \sigma, forming a Galois connection with respect to set inclusion.

The filter F(t)={s(s,t)R}F(t) = \{s \mid (s, t)\in R\} can be viewed as the pointwise preimage of τ\tau.

4. Handling Semantic Mismatches via CTF

CTF is designed to account explicitly for differences between trace alphabets. For example:

  • Undefined Behavior (UB): Let UBEvtUB \in \mathit{Evt} be a special undefined-behavior event. Define

(s,t)RUBt=s or m. s=mUBmt(s, t) \in R_{UB} \Longleftrightarrow t = s \ \text{or}\ \exists m.\ s = m \cdot UB \wedge m \leq t

The filter FUB(t)F_{UB}(t) removes everything after the first UBUB event in the source, so any arbitrary continuation after UB in the target is "dropped."

  • Resource Exhaustion: For EXHEvtSEXH \notin \mathit{Evt}_S,

(s,t)REXHs=t or m. mst=mEXH(s, t) \in R_{EXH} \Longleftrightarrow s = t \ \text{or}\ \exists m.\ m \leq s \wedge t = m \cdot EXH

Here, FEXHF_{EXH} returns the maximal source prefix corresponding to an out-of-memory target trace.

  • Side Channels: If TraceT=(TraceS×N)\mathit{Trace}_T = (\mathit{Trace}_S \times \mathbb{N}), RtimeR_{time} can specify (s,(s,τ))Rtime    s=s(s, (s', \tau)) \in R_{time} \iff s = s', and FtimeF_{time} simply projects away the timing information τ\tau.

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 P=input(x);if x>0 then output(1) else output(0)P = \text{input}(x); \text{if}\ x>0\ \text{then}\ \text{output}(1)\ \text{else}\ \text{output}(0) produces traces s1=[(i,0),(o,0)]s_1 = [(i,0), (o,0)] and s2=[(i,1),(o,1)]s_2 = [(i,1), (o,1)].

Suppose the compiler emits an extra secret-tag event secret_oksecret\_ok before each output:

  • Pt1=[(i,0),(secret_ok),(o,0)]\downarrow P \Downarrow t_1 = [(i,0), (secret\_ok), (o,0)]
  • Pt2=[(i,1),(secret_ok),(o,1)]\downarrow P \Downarrow t_2 = [(i,1), (secret\_ok), (o,1)]

Define RsecretR_{secret} such that (s,t)Rsecret(s, t) \in R_{secret} iff tt with all secret_oksecret\_ok events deleted equals ss. The filter F(ti)={si}F(t_i) = \{s_i\} 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 RR-correctness and property preservation:

Theorem 4 (CTF-Correctness \Leftrightarrow Property Preservation):

Let RTraceS×TraceTR \subseteq \mathit{Trace}_S \times \mathit{Trace}_T with Galois connection (τ,σ)(\tau, \sigma). The following are equivalent:

  • a) CTF-correctness relative to RR
  • b) Source-to-target trace-property preservation (ΠS. P. PΠS    Pτ(ΠS)\forall \Pi_S.\ \forall P.\ P \models \Pi_S \implies \downarrow P \models \tau(\Pi_S))
  • c) Target-to-source trace-property reflection (ΠT. P. Pσ(ΠT)    PΠT\forall \Pi_T.\ \forall P.\ P \models \sigma(\Pi_T) \implies \downarrow P \models \Pi_T)

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 RevtEvtS×EvtTR_{evt} \subseteq \mathit{Evt}_S \times \mathit{Evt}_T, the filter FF operates by searching for all source traces ss such that, proceeding eventwise along a target trace tTt_T, the pair (s,tT[0..n])Reventwise(s, t_T[0..n]) \in R_{eventwise} for all nn. In many cases a deterministic event-filter fevt:EvtT(EvtS+)f_{evt} : \mathit{Evt}_T \to (\mathit{Evt}_S + \bot) suffices, so that s=map-while-just(fevt)(tT)s = \text{map-while-just}(f_{evt})(t_T) computes the source projection by dropping any TT-event mapped to \bot and mapping the rest to the appropriate SS-event (Abate et al., 2019).

Summary Table: CTF Key Concepts

Component Role Example
Trace Relation RR Relate source and target traces RUB,REXH,RsecretR_{UB}, R_{EXH}, R_{secret}
Filter FF Recovers source traces from a target trace Removes UB suffixes, OOM markers, or secret tags
Existential Image τ\tau Lifts source properties to target trace properties Allows secret tags without breaking output property
Universal Image σ\sigma 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).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Compile-Trace-Filter (CTF) Framework.