Motivation
Runtime monitoring checks a running system against a specification by inspecting its trace of events as it is produced. Policies on data, such as "every published report was approved within the last 10 days" or "each value stored in in reaches out within 5 time units", quantify over data values and constrain the time between events. Metric first-order temporal logic (MFOTL) expresses such policies: it extends first-order logic with past and future temporal operators that carry intervals of allowed time differences.
Basin, Klaedtke, Müller and Zălinescu (J. ACM 62(2), Article 15, 2015) give a monitor for MFOTL properties □Φ with Φ bounded. It allows negation and quantification over the infinite domain N without restriction, because every relation it manipulates is represented by a finite automaton: the input structures are automatic structures. The paper implements it in the prototype tool MonPoly-Reg (§6). Its correctness rests on Theorem 3.9: the monitor reports exactly the violations of Φ, at every time point.
Setting
A signature S=(C,R,ι) has finitely many constants and predicates with arities. Formulas are built from t≈t′ and r(t1,…,tι(r)) by ¬, ∨, ∃x and the temporal operators ∙I (previous), ∘I (next), SI (since) and UI (until), where I=[b,b′) is a nonempty interval of N with b′∈N∪{∞}. A formula is bounded if every UI in it has b′<∞.
A temporal structure (Dˉ,τˉ) assigns to each time point i∈N relations rDi⊆Nι(r) and a time stamp τi∈N; constants are rigid, τ0≤τ1≤⋯, and τˉ exceeds every bound. Satisfaction (Dˉ,τˉ,v,i)⊨φ is Definition 2.2; for example ψUIψ′ holds at i if ψ′ holds at some j≥i with τj−τi∈I and ψ holds at all k∈[i,j). For φ with free variables x1<⋯<xn, the satisfying set is
φ(Dˉ,τˉ,i)={dˉ∈Nn∣(Dˉ,τˉ,v[xˉ↦dˉ],i)⊨φ for some v}.
A domain representation is a regular language L over a finite alphabet with a surjection ν:L→N whose equality relation is regular. A relation A⊆Nk is regular if the words u1⊗⋯⊗uk (the letter-by-letter convolution, padded with #) with (ν(u1),…,ν(uk))∈A form a regular language.
The monitor MΦ (Fig. 2) reads (D0,τ0),(D1,τ1),… one element per loop iteration. It extends each Dj to D^j with auxiliary relations pα (and rα, sα for since and until) for every temporal subformula α, built incrementally by the constructions of §3.4 once a list Q of pending triples (α,j,S) says that enough of the future has been read. When D^i is complete it outputs the set (¬Φ^)D^i with τi, where Φ^ is Φ with each top-level temporal subformula α replaced by the atom pα(xˉ).
Formalization targets
Goal: Theorem 3.9
For every input satisfying the restrictions of §3.1 and every bounded Φ:
(i)(n,O,t) output by line 9 ⟹ O=(¬Φ)(Dˉ,τˉ,n), O regular, t=τn;
(ii)∀n∈N,n=0 or some output at index n−1 occurs,
where each output is followed by line 11 setting i to the next index. This records counter values reached inside the while loop, including values that may never appear at a loop entry. Part (ii) excludes the vacuous reading of (i).
Milestones
- Lemma 3.4: φ^D^i=φ(Dˉ,τˉ,i) once the auxiliary relations of tsub(φ) are correct, and regularity is preserved.
- Lemmas 3.5–3.8: the constructions for ∙I, ∘I, SI and bounded UI produce regular relations equal to the satisfying sets, with the stated characterizations of rα and sα.
- Observations (1)–(3) of the proof of Theorem 3.9 on the list Q and the counter i.
- The claim that line 7 can always be executed, in the form: if (α,j,∅)∈Qk then the build stores pαD^j=α(Dˉ,τˉ,j), which is regular.
Significance
Theorem 3.9 makes MΦ a sound and complete monitor for the safety fragment □Φ, Φ bounded: every violation at every time point is reported, nothing else is, and every output is a finitely represented (regular) set even though it may be infinite. It covers unrestricted negation and quantification, which finite-relation monitors (§4 of the paper) cannot handle. The incremental constructions of §3.4 are the template reused by later MFOTL monitors.
The paper gives a mathematical proof of its monitor's correctness. This mission asks for a Lean proof that checks the MFOTL semantics, automatic relations over N, and the correctness of this particular monitor, including the until construction whose printed version is defective (see Formalization scope).
Difficulty
Two parts are hard. The regularity claims need the fundamental property of automatic structures: first-order definable relations are regular, which requires closure of padded convolution languages under Boolean operations, cylindrification, permutation of tracks and projection, the last with removal of trailing padding. The arithmetic constraints of the since and until constructions additionally need successor and offset relations definable from ≺.
The scheduling argument is the other part. Correctness of a build at (α,j) requires that every input relation, at time points up to j+ℓj for until, was built before and not discarded since. Following only the syntax of α does not settle this: a needed relation for a subformula at a later time point may be built in the same iteration as α's.
Formalization scope
The domain is N, as §3.1 assumes. Relations are sets of lists of natural numbers, ordered by the sorted free variables. Interval upper bounds are in N∞; intervals carry the proof that they are nonempty. The representation (L,ν) is a single parameter shared by the hypothesis "every rDi is regular" and the regularity claims of the conclusions; it is never chosen existentially. The binary predicate ≺ interpreted as < is a hypothesis.
Two hypotheses on Φ besides boundedness are the paper's own "without loss of generality" assumptions: each temporal subformula occurs once in Φ (§3.6), and the direct subformulas of each SI, UI subformula have the same free variables (§3.4; achieved by padding with x≈x, as in §3.5). No other restriction is placed on Φ.
The printed until construction (§3.4.4) is repaired: the guard of Ur is "aˉ∈β^D^i+k for all ℓi−1≤k≤ℓi", since the printed guard empties rα in the paper's own example of §3.5; Us keeps only tuples with j′≥1, since otherwise a γ-witness at time point i−1 survives to time point i when τi=τi−1; and time-stamp equations are encoded additively. Lemma 3.8(i) reads aˉ∈Nn and adds j≤ℓi. "Effectively computable" in Theorem 3.9(i) is not formalized. Part (ii) uses the output at index n−1 as the record of the line-11 increment to n; for n=0, the counter is initialized by line 2. Loop-entry states alone can skip counter values reached within one iteration.
The monitor is a state machine whose builds and outputs are computed only from its store of relations; it never consults the satisfaction relation or satisfying sets. A formalization in which line 7 reads the semantics would turn Theorem 3.9(i) into a restatement of Lemma 3.4, and is ruled out. A build whose input is missing stores nothing, so a monitor that silently fails would violate (ii).
Contributions welcome: the theory of automatic relations (reusable beyond this mission), the semantic halves of Lemmas 3.4–3.8, and the scheduling invariants.
Selected references
- D. Basin, F. Klaedtke, S. Müller, E. Zălinescu, Monitoring metric first-order temporal properties, J. ACM 62(2), Article 15, 2015. https://doi.org/10.1145/2699444