Distilling Formal Logic into Neural Spaces: A Kernel Alignment Approach for Signal Temporal Logic
Organizations: AILab, MIGe, University of Trieste, IT · Khoury College of Computing Sciences, Northeastern University, Boston, MA, USA
Abstract
We introduce a framework for learning continuous neural representations of formal specifications by distilling the geometry of their semantics into a latent space. Existing approaches rely either on symbolic kernels -- which preserve behavioural semantics but are computationally prohibitive, anchor-dependent, and non-invertible -- or on syntax-based neural embeddings that fail to capture underlying structures. Our method bridges this gap: using a teacher-student setup, we distill a symbolic robustness kernel into a Transformer encoder. Unlike standard contrastive methods, we supervise the model with a continuous, kernel-weighted geometric alignment objective that penalizes errors in proportion to their semantic discrepancies. Once trained, the encoder produces embeddings in a single forward pass, effectively mimicking the kernel's logic at a fraction of its computational cost. We apply our framework to Signal Temporal Logic (STL), demonstrating that the resulting neural representations faithfully preserve the semantic similarity of STL formulae, accurately predict robustness and constraint satisfaction, and remain intrinsically invertible. Our proposed approach enables highly efficient, scalable neuro-symbolic reasoning and formula reconstruction without repeated kernel computation at runtime.
Figures & tables
| Metric | Equivalent | Non-equivalent | Lexically Sim. |
|---|---|---|---|
| Neural similarity | 0.966 | 0.182 | 0.308 |
| Kernel similarity | 0.997 | 0.170 | 0.225 |
| MAE (semantic gap) | 0.034 | 0.072 | 0.112 |
| Relative neural distance | 0.137 | 0.833 | 0.770 |
| Relative kernel distance | 0.105 | 0.830 | 0.775 |
| Metric | Kernel | Transformer | ||||||
|---|---|---|---|---|---|---|---|---|
| loaded | full | |||||||
| Time (s) | 2.18 | 3.03 | 4.77 | 8.36 | 17.08 | 48.86 | 2.17 | 3.56 |
| RAM (GB) | 4.91 | 8.74 | 16.46 | 31.70 | 62.38 | 123.38 | 1.54 | 1.71 |
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Rule | Mathematical Transformation | |
|---|---|---|
| Not -injection | 0.1% | |
| De Morgan rewriting | 9.9% | |
| Time partitioning | 35.0% | |
| Until nesting | 25.0% | |
| Temporal identity | 5.0% | |
| Distributivity | 15.0% |
| geometrically | interpretation | |
|---|---|---|
| complete collapse | zero discriminative power; all formulae are isomorphic | |
| dense clustering | poor resolution; distinct logics occupy overlapping regions | |
| reasonable distribution | reliable separation of standard temporal properties | |
| good sparsity | maximum entropy; preserves fine-grained semantic nuances. | |
| asymptotic limit | theoretical maximum spread for with |
| STL Kernel | Transformer | ||||||
|---|---|---|---|---|---|---|---|
| Mem | (Loaded) | Mem (Loaded) | (Full) | Mem (Full) | |||
| 500 | 500 | 0.61 | 2059 | 0.62 | 2136 | 2.06 | 2914 |
| 500 | 1000 | 0.83 | 3061 | 0.62 | 2128 | 1.98 | 2916 |
| 500 | 2000 | 1.25 | 5051 | 0.62 | 2128 | 2.05 | 2918 |
| 500 | 4000 | 2.21 | 8955 | 0.63 | 2134 | 2.02 | 2918 |
| 500 | 8000 | 4.53 | 16995 | 0.62 | 2127 | 1.98 | 2918 |
| STL Kernel | Transformer (Loaded) | Transformer (Full) | |||||
|---|---|---|---|---|---|---|---|
| Mem | Mem | Mem | |||||
| 500 | 500 | 1.58 | 2059 | 0.73 | 2136 | 2.04 | 2914 |
| 500 | 1000 | 2.50 | 3061 | 0.73 | 2128 | 1.99 | 2916 |
| 500 | 2000 | 4.38 | 5051 | 0.73 | 2128 | 2.02 | 2918 |
| 500 | 4000 | 8.21 | 8955 | 0.73 | 2134 | 2.02 | 2918 |
| 500 | 8000 | 16.81 | 16995 | 0.73 | 2127 | 1.99 | 2918 |
| Metric | Equivalent | Non-equivalent | Syntactically similar |
|---|---|---|---|
| Neural similarity | 0.966 | 0.182 | 0.308 |
| Kernel similarity | 0.997 | 0.170 | 0.225 |
| MAE (semantic gap) | 0.034 | 0.072 | 0.112 |
| Relative neural distance | 0.137 | 0.833 | 0.770 |
| Relative kernel distance | 0.105 | 0.830 | 0.775 |
| Metric | Equivalent | Non-equivalent | Syntactically similar |
|---|---|---|---|
| Neural similarity | 0.954 | 0.201 | 0.332 |
| Kernel similarity | 0.997 | 0.163 | 0.221 |
| MAE (semantic gap) | 0.044 | 0.066 | 0.143 |
| Relative neural distance | 0.169 | 0.833 | 0.749 |
| Relative kernel distance | 0.100 | 0.837 | 0.779 |
| Metric | Equivalent | Non-equivalent | Syntactically similar |
|---|---|---|---|
| Neural similarity | 0.946 | 0.171 | 0.280 |
| Kernel similarity | 0.997 | 0.152 | 0.182 |
| MAE (semantic gap) | 0.052 | 0.070 | 0.133 |
| Relative neural distance | 0.186 | 0.834 | 0.794 |
| Relative kernel distance | 0.111 | 0.848 | 0.818 |