A Neuro-Symbolic Pipeline for Automated Synthesis and Verification of OCL Constraints
Abstract
Authoring OCL constraints manually in Model-Driven Engineering is error-prone. While Large Language Models offer a potential solution for automated synthesis, they suffer from structural and semantic hallucinations. Current LLM-based approaches primarily target statistical translation accuracy, lacking formal guarantees of semantic correctness. We propose a neuro-symbolic synthesis pipeline that couples LLM generation with a three-layer checking mechanism and a self-correction loop. Layer 1 enforces structural compliance via JSON Schema validation, and Layer 2 performs static type checking within the UML context. Crucially, Layer 3 acts as a formal validation step: it translates the candidate OCL constraint into SMT formulas and checks its semantic equivalence against a reference specification. To ensure decidability, we define a decidable OCL subset and introduce a novel bounded SMT encoding strategy. This strategy employs a value-condition separation mechanism to handle OCL’s four-valued logic and abstracts collection algebra into counting functions with bounded quantifier elimination, reducing complex constraints to quantifier-free formulas. Evaluation on a benchmark of 137 OCL constraints demonstrates that the pipeline achieves a strict semantic equivalence rate of 98.54%, while maintaining computational tractability within standard bounded scopes.