Formal Verification Translation: Why Compiling Successfully Does Not Mean Semantically Correct

    This article examines a critical gap in autoformalization: a formal statement can pass the proof assistant kernel's type and syntax checks while silently drifting away from the original natural language meaning. Drawing on reported evaluation data where compilation pass rates near 87.2% dropped to semantic acceptance rates around 57.7%, it explains why compilation alone cannot guarantee correctness, catalogs common semantic drift patterns, and proposes a practical four-layer validation framework, evaluation metric redesign, and engineering checklist for teams building autoformalization pipelines.

    1. A Default Assumption That Is Starting to Fail

    In the context of theorem machine verification, a long-standing default premise is rarely questioned: if formalized code passes the proof assistant kernel’s type and syntax checks, it must express what we intended. This premise is largely reliable in “automatically proving theorems” scenarios, because the target statement is given and fixed, and the verifier only needs to determine whether the proposition holds. However, in the “translating natural language into formal statements” scenario, it does not hold at all.

    The root of the problem lies in the different task structure. Autoformalization requires the model to first generate the formal proposition itself, and then supply a proof placeholder for it (a common industry practice is to leave an unfinished proof slot). At this point, the model holds the definitional authority over “what is to be proven,” so it can easily generate a proposition that is syntactically valid, type-consistent, and accepted by the kernel, yet semantically deviated from the original text. The compiler is only responsible for determining “whether this sentence is legal,” not “whether this sentence is the original one.”

    An accessible analogy: the original text is “He did not come to work yesterday because he was sick,” and the translation is a grammatically perfect “He did not come to work yesterday.” A syntax checker cannot find any fault, but the key information “because he was sick” has been silently dropped. Such errors trigger no warnings and therefore never enter routine failure-sample statistics.

    2. How Large Is the Gap: From Pass Rate to Acceptance Rate

    An enhanced agent built by a research team achieved a compilation pass rate of about 87.2% on autoformalization tasks, a figure quite impressive among comparable work. However, when the evaluation standard switched from “can it compile” to “is it semantically equivalent,” the acceptance rate plummeted to about 57.7%, a gap of nearly 30 percentage points.

    The engineering implication of these numbers is direct: among every ten samples judged as “successful,” about three are false positives. If a team uses the compilation pass rate as the sole metric to drive iteration, model optimization is effectively moving toward “more easily writing legal but off-target propositions,” decoupling metric gains from quality improvement.

    It must be emphasized that this is not an occasional defect of a particular model, but a systematic bias caused by the mismatch between task and metric. As long as the evaluation signal only covers the syntax layer, any capability improvement may be swallowed by this portion of noise.

    3. Typical Forms of Semantic Drift

    Classifying the deviations commonly found in manual review converges to a few high-frequency patterns, almost all of which pass compilation smoothly:

    • Quantifier and scope drift: writing “for any set there exists a mapping” as “there exists a mapping for any set,” or swapping the order of universal and existential quantifiers, materially changing the strength of the proposition.
    • Conditions weakened or strengthened: a necessary and sufficient condition in the original is written as a one-way implication; or an extra premise not in the original is added, making the proposition easier to prove.
    • Structural assumptions dropped: premises such as compactness, Hausdorff property, non-emptiness, and closedness are omitted, causing the proposition to hold over a broader class of objects.
    • Inconsistent handling of boundary and degenerate cases: cases such as the empty set, zero dimension, and trivial groups are implicitly excluded or implicitly included.
    • Definition substitution: replacing the original definition with a “seemingly close” definition whose equivalence is unproven, creating a semantic bait-and-switch.
    • Proof placeholders masking problems: ending with an unfinished proof slot, so the proposition itself is never truly tested.

    The common feature of these patterns is that errors occur at the “proposition layer,” while the toolchain’s checks occur at the “expression layer,” and a structural blind spot exists between the two.

    4. Why Compilation Alone Cannot Serve as a Safety Net

    The kernel of a formal assistant can be likened to an extremely strict grammar teacher: it checks spelling, types, implicit arguments, and structural legality word by word, and rejects anything non-compliant; but it does not judge whether the essay is off-topic. This division of labor is deliberate; the kernel’s trustworthiness comes precisely from its decision scope being small enough and mechanical enough.

    Three corollaries follow:

    1. Compilation passing is a necessary condition, not a sufficient one; it can only prove “this sentence is legal,” not “this sentence is correct.”
    2. Semantic equivalence is undecidable in general and cannot be replaced by a single compilation in place of a semantic comparison.
    3. Therefore, quality assurance must shift from “single-point judgment” to “multi-layer redundant validation,” decomposing semantic correctness into several proxy indicators that can be checked automatically or semi-automatically.

    5. A Practical Semantic Validation Framework

    It is advisable to split the pipeline into four layers that progressively converge risk, rather than staking all trust on the compilation result.

    Layer one, structural fingerprint comparison. Before generation, first parse the natural language into a structured intermediate representation (objects, quantifiers, premises, conclusion, constraints); after generation, extract the same structure in reverse from the formal statement and compare the difference set between the two. An illustration:

    1. Source structure: forall X, Compact X -> forall Y, Hausdorff Y ->
    2. forall f, Continuous f -> Normal (image f X)
    3. Translated structure: forall X Y, Compact X -> Hausdorff Y ->
    4. forall f, Continuous f -> Normal (image f X)
    5. Difference: quantifier nesting order inconsistent -> flagged as high risk

    Layer two, adversarial rewriting and bidirectional implication. Apply meaning-preserving rewrites (synonym substitution, word-order adjustment) and meaning-altering rewrites (dropping premises, swapping quantifiers, changing boundaries) to the source, requiring the model to produce a consistent proposition across multiple samples; then attempt to prove both “source implies translation” and “translation implies source,” treating failure in either direction as semantically suspect.

    Layer three, cross-model review and disagreement localization. Use multiple heterogeneous models to formalize independently, perform a structured diff on the propositions, converge the disagreement points to the smallest fragment (usually a single quantifier or a single premise), and then have a human or a stronger model adjudicate at that point. Where disagreements concentrate is often where errors concentrate.

    Layer four, human spot-checking and active learning. Sample for review ranked by risk score, feed review conclusions back as evaluation sets and training signals, and prioritize adding negative samples for high-frequency deviation patterns.

    6. How the Evaluation System Should Change

    Metric design needs to align with the task objective; the core is to introduce an independent measure of the semantic dimension:

    • Change the primary metric to semantic acceptance rate, and downgrade compilation pass rate to a process metric and cost metric.
    • Report the proportion of “passed but not accepted” as a direct exposure of the false-positive rate.
    • Report in layers: bucket by mathematical branch, by proposition complexity, and by number of premises to locate weak spots.
    • Build a reproducible semantic benchmark set containing minimal contrast pairs (changing only one quantifier or one premise) to precisely measure sensitivity.
    • Introduce a stability metric: the proposition consistency rate across multiple samples of the same input; a low consistency rate indicates the model has a weak grasp of semantic boundaries.

    7. Engineering Practice Checklist

    • Enforce output of the intermediate structure during generation, decoupling “understanding” from “expression” to make it easier to locate at which step the deviation occurs.
    • Perform explicit checking against the premise list, ticking off each item to avoid silent dropping.
    • When retaining proof placeholders, they must be labeled as “unverified propositions” and prohibited from entering downstream knowledge bases or training corpora.
    • Automatically escalate high-risk propositions (nested multiple quantifiers, containing boundary cases, definition-dense) to the manual review queue.
    • Record the source text, intermediate structure, generated proposition, and review conclusion across the full chain to form an auditable trail.
    • If relying on a cloud platform, container platforms can run batch validation tasks, object storage can hold evaluation datasets, message queues can smooth peak scheduling of review tasks, and logging services with monitoring alerts can track changes in the false-positive rate, automating the evaluation loop.

    8. Conclusion

    “Can compile” only shows the expression is legal; “said it right” is semantic equivalence, and a whole validation engineering effort stands between the two. Treating the compilation pass rate as the quality goal systematically skews the optimization direction; making the semantic acceptance rate the primary metric, supplemented by structural comparison, bidirectional implication, cross-model review, and human spot-checking, is what can truly drive down the nearly 30-percentage-point gap. For teams preparing to build autoformalization capabilities, fixing evaluation first and then pursuing improvement is the lowest-cost, highest-return order.