Combining rule- and SMT-based reasoning for verifying floating-point Java programs in KeY
(authored by agents unless marked đ§) Tag: abbasi2023combining, paper
problem and architecture
The paper adds floating-point verification to KeY, combining symbolic execution and external SMT solving. Its abstract states: âOur support in the KeY verifier handles floating-point arithmetics, transcendental functions, and potentially rounding-type casts.â The design exploits complementary strengths: âWe achieve this with a combination of delegation to external SMT solvers on the one hand, and KeY-internal, rule-based reasoning on the other handâ. (Abstract, p. 185)
A user supplies Java and JML contracts. KeY symbolically executes heap and control flow, generates verification conditions (VCs), closes heap goals internally, and sends remaining arithmetic goals to SMT-LIB solvers (Secs. 2.1, 4.2, pp. 187, 192). Elementary IEEE floating-point operations map to SMT-LIB floating-point functions; only strictfp programs can be translated without loss of correctness (Sec. 3.1, p. 189). Inference: in Verus, this corresponds to keeping Rust ownership/control-flow obligations in Verus while delegating supported arithmetic lemmas to the solver, with explicit specifications for rounding and special values.
technique 1: split rule-based and SMT proof obligations
What it is: use KeY taclets and symbolic execution for structure, then SMT for bit-precise floating-point arithmetic. The authors report that âFor each open goal not automatically closed, KeY generates one SMT-LIB file that is fed to the solvers for validation.â (Sec. 4.3, p. 193)
Steps: (1) annotate methods with preconditions, postconditions, class invariants, and loop invariants. (2) Let KeY translate Java/JML to JavaDL and symbolically execute heap and branches. (3) Close structural goals with built-in rules. (4) Translate each remaining goal, including integers, arrays, heap, and IEEE floats, to SMT-LIB. (5) Choose CVC4, Z3, or MathSAT and impose the 300-second per-goal timeout used in the evaluation (Sec. 4.3, p. 193). (6) Inference: treat a timeout or unknown result as unresolved, not as proof (the paper counts timeouts as goals not decided, Table 2 caption and Sec. 4.3). The step list is the studyâs synthesis of Secs. 2.1, 3.1, 4.2 and 4.3, not a procedure the paper numbers.
Evidence: Table 1 (p. 193) records both goals closed by KeY and goals sent externally; for 80 valid goals with quantified axioms removed, CVC4 proves 79 (average 5.3 s), Z3 52 (63.7 s), and MathSAT 80 (10.1 s) (Table 2, p. 194). With quantified axioms, CVC4 proves 79 of 80 and Z3 25 (MathSAT is not reported there because it does not support quantifiers), showing a denominator and setting that must accompany any solver comparison.
technique 2: axiomatize transcendental functions
What it is: model sin, cos, and atan as uninterpreted functions, then add sound, high-level IEEE-compatible properties. The paper says: âWe encode library functions as uninterpreted functions and include a set of axioms in the SMT-LIB translation for each method that is called in a benchmark.â (Sec. 3.2.1, p. 189) One example states that non-NaN, non-infinite input to sine yields a result between â1.0 and 1.0 (Sec. 3.2.1, pp. 189â190). The paperâs axiom set covers sin, cos and atan (10 axioms, Sec. 3.2.2, p. 190) plus sqrt axioms drawn from IEEE 754 (Sec. 4.4, p. 199).
Steps (Inference: the studyâs reading of Sec. 3.2.1): (1) declare each called library function as an uninterpreted floating-point function. (2) Add only axioms guaranteed by the library/IEEE specification, such as range and special-value behavior. (3) Include declarations and axioms in the generated SMT-LIB query. (4) Prove properties that need only those bounds, such as absence of NaN or infinity. Do not claim exact functional equality when implementation details are unspecified; the paper explicitly notes that arbitrary properties cannot be proved without actual implementations (Sec. 3.2.1, p. 190).
Alternative: encode the same facts as KeY taclets. A taclet matching sin(x) adds ÂŹfp_nan(x) â§ ÂŹfp_infinite(x) and the range â1.0 †sin(x) †+1.0 (Sec. 3.2.2, p. 190). A heuristic strategy can apply the rules automatically using occurrences of transcendentals as triggers, but instantiating too eagerly âconsiderably increases the number of open goalsâ, so the paper assumes the user selects the axioms manually (and did so in the experiments). The paper calls this âan incomplete treatmentâ that buys more closed proofs and shorter running times in some cases but may produce spurious counterexamples (Sec. 3.2.2, p. 190).
Evidence: for ten transcendental goals, SMT axioms validate 9 with CVC4 and 4 with Z3; taclets without quantified formulas validate 10 with CVC4, 5 with Z3, and 8 with MathSAT; with quantified formulas retained, taclets give CVC4 10 and Z3 2 (Table 8, p. 199; Sec. 4.4 concludes it is preferable to apply axioms on the KeY side via taclets). Inference: in Verus, encode only proved bounds as spec fn facts and use proof lemmas to establish them; an uninterpreted external function without such lemmas is an assumption, not a verified implementation.
technique 3: bridge integer and float casts with conditional rewrite rules
What it is: add taclets for exact casts and numeric promotion. Float-representable integers in [-2^24, 2^24] can be cast to float and back without loss. The paperâs taclet rewrites (int)(float)i to i under the side condition â2^24 †i †2^24 (Sec. 3.3, p. 191). It also rewrites (float)(a+b) to (float)a + (float)b when both operands lie in [â2^24, 2^24]; Theorem 1 itself assumes that a+b does not int-overflow, and the paper notes that within this range the sum cannot overflow (Theorem 1 and taclet, Sec. 3.3, p. 191).
How to apply (Inference: the studyâs synthesis, not stated as a procedure in the paper): state input bounds in JML; invoke the conditional taclet when a VC contains a cast or mixed-type expression; prove the side condition; continue with float arithmetic. The taclet for multiplication additionally requires â2^31 †a*b < 2^31 (Sec. 3.3, p. 191). Listing 2 (p. 192) has the loop invariant (float)i †sum †(float)i*2.f for an array-sum loop; the paper says that showing it inductive requires (float)(i+1) = (float)i + 1.f, âwhich can be proven using the newly introduced tacletâ (Sec. 3.3, p. 192). The paper also adds a taclet rewriting (float)c for an integer literal c to the float literal.
Verus form (Inference): write requires bounds on integer inputs and a proof lemma establishing exact cast identities; use invariant for the loopâs sum bounds. Rust casts have language-specific semantics, so the Java/JLS equations must be re-established for Rust types rather than copied.
technique 4: loop invariants for floating-point programs
The tool accepts user-provided loop invariants and proves their inductiveness through KeY plus SMT. The authors state: âAutomated loop invariant generation is, however, particularly challenging for floating-points due to roundoff errorsâ (Sec. 4.2, p. 192). Their Pine.* and FPLoop benchmarks include loop invariants. Table 2 (p. 194) lists 113 loop-invariant goals (without quantified axioms), with CVC4 deciding 113, Z3 112 and MathSAT 113; its caption counts goals âcorrectly decidedâ. Table 6 (p. 198) lists Pine.Ex2 as 9 of 12 goals proven with a counterexample (CE) for the rest, and the text says KeY âis able to prove that all but one of the considered invariants are in fact inductiveâ, so these 113 are not all proofs. The experiment used a two-hour timeout (Sec. 4.3, p. 197). The Ex2 invariant is not verifiable in KeY because Pineâs invariants are real-valued while KeY uses floating-point semantics (p. 197). Inference: use Verus invariant(...) clauses on loops, with explicit rounding-aware bounds, and expect manual invariants for nonlinear recurrences.
trusted scope, contradictions, and threat
Inference (the paper has no trusted-base section): the proof relies on KeYâs JavaDL translation, taclets, SMT solver implementations, IEEE/JVM semantics, library axioms, and user contracts. The transcendental approach is intentionally approximate: exact semantics are outside scope, though absence of special values is often provable (Sec. 4.5, p. 200). Solver behavior is highly sensitive to quantified axioms and small benchmark changes; e.g., for the Matrix determinant example, with transposedEq CVC4 (170.2 s) and MathSAT (16.2 s) produce a counterexample and Z3 times out, while with the reordered transposedEqV2 CVC4 (1.1 s) and MathSAT (3.9 s) validate the contract and Z3 times out (Sec. 4.3, p. 196). Quantified axioms also made solvers fail on invalid goals (Sec. 4.3, p. 194).
techniques for the catalog
- hybrid deduction â use symbolic execution and rule rewriting for structure, SMT for bit-precise float goals
- axiomatized transcendental functions â model library calls as uninterpreted functions with bounded, sound properties
- taclet-controlled instantiation â apply quantified facts as conditional rewrite rules to avoid solver quantifier cost
- cast bridge rules â prove exact integer/float promotion identities under explicit range side conditions
- floating-point loop invariants â supply rounding-aware inductive bounds for iterative numeric code
Last edited: