R2U2 Implementation#
Abstract Syntax Tree Architecture#
R2U2 is a stream-based runtime monitor that reevaluates MLTL and ptMLTL formulas for each time index \(i\). The Configuration Compiler for Property Organization (C2PO) [1] compiles MLTL and ptMLTL formula(s) for input into R2U2. C2PO decomposes the MLTL and ptMLTL formula(s) into subformula nodes represented in an Abstract Syntax Tree (AST) and optimizes the AST by applying Common Subexpression Elimination [1] [2] and various rewriting rules [3]. C2PO then outputs assembly-style instructions for R2U2 to reason over. The figures below illustrate an AST and the compiled instructions for \((\Box_{[0,3]}\psi)\ \mathcal{U}_{[2,4]}\ \xi\).

AST for \((\Box_{[0,3]}\psi)\ \mathcal{U}_{[2,4]}\ \xi\)#

Instructions compiled by C2PO for \((\Box_{[0,3]}\psi)\ \mathcal{U}_{[2,4]}\ \xi\). Instructions 0–3 are the computation instructions (blue), and instructions 4–9 are the configuration instructions (red)#
In the outputted assembly, there are configuration instructions and computation instructions. The configuration instructions are run once upon initialization to configure the AST in terms of sizing and metadata (e.g., the lower and upper bounds of temporal operators). The computation instructions are saved in a table and sequentially iterated over at each timestamp. The computation instructions are ordered such that R2U2 reasons over the AST by determining the evaluation of each subformula node from the bottom-up and propagating verdicts to the parent node(s).
Each node of the AST computes and stores verdict-timestamp tuples \(T_{\varphi} = (v, \tau)\) for its subformula \(\varphi\), where \(v \in \{\sf true, \sf false\}\) and \(\tau \in \mathcal{N}_0\). Each node stores the verdict-timestamp tuples in a shared connection queue (SCQ), where the SCQ is a circular buffer that overwrites verdict-timestamp tuples in a circular and aggregated manner. Fig. 1 below demonstrates an example of how R2U2 evaluates over an AST.
