Repository navigation
Closed
Description
We should demonstrate the copilot-verifier is capable of handling of specifications that make use of floating-point operations. A good first milestone is the Heater example from the copilot repo (not to be confused with copilot-verifier's own Heater example, which avoids the use of floating-point). At the moment, if you try running copilot-verifier on this Heater example, it will fail to prove these goals:
Details
=====
== Running the HeaterCelsius example...
=====
Generated "results/heaterCelsius/heaterCelsius.c"
Compiled heaterCelsius into results/heaterCelsius/crux~heaterCelsius.bc
Translated bitcode into Crucible
Generating proof state data
Computing initial state verification conditions
Proving initial state verification conditions
All obligations proved by concrete simplification
Computing step bisimulation verification conditions
Proving step bisimulation verification conditions
Proved 0 of 4 total goals
[Crux] Found counterexample for verification goal
[Crux] results/heaterCelsius/heaterCelsius.c:30:6: error: in step
[Crux] Mismatch between Copilot value and crucible value
[Crux] XFloat let -- :1:0
[Crux] v15 = floatMul RNE (bvToFloat RNE ctemperature_r0@13:bv) 0x0.969697
[Crux] in floatSub RNE v15 0x32
[Crux] FloatRepr SingleFloatRepr
[Crux]
[Crux]
[Crux] Found counterexample for verification goal
[Crux] results/heaterCelsius/heaterCelsius.c:33:6: error: in step
[Crux] Mismatch between Copilot value and crucible value
[Crux] XFloat let -- :1:0
[Crux] v15 = floatMul RNE (bvToFloat RNE ctemperature_r0@13:bv) 0x0.969697
[Crux] in floatSub RNE v15 0x32
[Crux] FloatRepr SingleFloatRepr
[Crux]
[Crux]
[Crux] Found counterexample for verification goal
[Crux] internal: error: in <>
[Crux] Trigger guard equality condition: "heaton"
[Crux] Details:
[Crux] let -- :1:0
[Crux] v15 = floatMul RNE (bvToFloat RNE ctemperature_r0@13:bv) 0x0.969697
[Crux] in not (floatLt (floatSub RNE v15 0x32) 0x12)
[Crux]
[Crux] Found counterexample for verification goal
[Crux] internal: error: in <>
[Crux] Trigger guard equality condition: "heatoff"
[Crux] Details:
[Crux] let -- :1:0
[Crux] v15 = floatMul RNE (bvToFloat RNE ctemperature_r0@13:bv) 0x0.969697
[Crux] in not (floatLt 0x15 (floatSub RNE v15 0x32))
If we get that working, we can become more ambitious and try to verify examples that use transcendental functions, such as this Trig example. That will first require incorporating GaloisInc/what4#160 into crucible-llvm and overriding the necessary functions in LLVM. I have a WIP branch for this here.
Metadata
Metadata
Assignees
Labels
No labels
Activity
robdockins commentedon Oct 15, 2021
The well-clear violation example (WCV) would also be good; it doesn't use any special functions I think, so it should be easier to get going than
Trig.Use `SymInterpretedFloat`s in `XExpr`
Use `SymInterpretedFloat`s in `XExpr`
RyanGlScott commentedon Oct 15, 2021
GaloisInc/copilot-1#1 and GaloisInc/crucible#889 are first steps in this direction. Some remaining tasks that may need to be completed before we can actually verify floating-point examples in
copilot-verifierare:copilot-theorem, there are a number of operations that convert from floating-point values to reals, perform an operation on them, then convert the result back to a floating-point value. (See UseSymInterpretedFloats inXExprGaloisInc/copilot-1#1 (comment).) With Special functions GaloisInc/what4#160 and Addpow(x^y) as aSpecialFunctionGaloisInc/what4#163, this should no longer be necessary, as we can just use special functions directly.copilotmakes use ofpowand(EDIT:logblogbisn't needed after all, see Add some examples that use floating-point operations #3 (comment)), which currently do not haveSpecialFunctionsupport inwhat4. We should add these and propagate them up intocrucibleandcopilot-theorem.copilot-theoremthat are implemented as compositions of lower-level floating-point primitives fromwhat4, such asAbs. (See UseSymInterpretedFloats inXExprGaloisInc/copilot-1#1 (comment).) We should verify that these behave as expected.Use `SymInterpretedFloat`s in `XExpr` (#1)
RyanGlScott commentedon Oct 28, 2021
On second thought, we likely don't need an override for
logb. Althoughcopilothas aLogbconstructor, it actually compiles down to thelogfunction, whichcrucible-llvmalready supports. In that case, I believe the only missing piece of functionality ispow. I've submitted the first steps towards supporting that in GaloisInc/what4#163 and GaloisInc/crucible#901.Use special FP operations rather than roundtripping through reals
Use special FP operations rather than roundtripping through reals (#2)
RyanGlScott commentedon Nov 1, 2021
The upstream
copilotrepo has recently added support for the following incopilot-c99:atan2(Copilot-Language/copilot@6c11ea0)ceil(Copilot-Language/copilot@7d0e675)floor(Copilot-Language/copilot@6a0d260)We have
what4support foratan2, but notceilorfloor. See GaloisInc/what4#165, GaloisInc/crucible#905, GaloisInc/copilot-1#3, and #8.Bring in support for ceil, floor, and atan2
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)
Bring in support for ceil, floor, and atan2
Bring in support for ceil, floor, and atan2 (#8)
3 remaining items
Use special FP operations rather than roundtripping through reals (#2)
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)
Use `SymInterpretedFloat`s in `XExpr` (#1)
Use special FP operations rather than roundtripping through reals (#2)