sbv 13.6 → 14.0
raw patch · 570 files changed
+33129/−6816 lines, 570 files
Files
- CHANGES.md +149/−2
- Data/SBV.hs +22/−13
- Data/SBV/Client.hs +4/−99
- Data/SBV/Client/BaseIO.hs +2/−2
- Data/SBV/Control/Utils.hs +19/−7
- Data/SBV/Core/AlgReals.hs +2/−1
- Data/SBV/Core/Concrete.hs +13/−13
- Data/SBV/Core/Data.hs +40/−1
- Data/SBV/Core/Model.hs +4768/−3331
- Data/SBV/Core/Operations.hs +2/−2
- Data/SBV/Core/SizedFloats.hs +2/−2
- Data/SBV/Core/Symbolic.hs +156/−106
- Data/SBV/Core/TH.hs +142/−0
- Data/SBV/Either.hs +9/−2
- Data/SBV/Lambda.hs +78/−37
- Data/SBV/List.hs +182/−141
- Data/SBV/Maybe.hs +11/−1
- Data/SBV/Provers/Prover.hs +7/−5
- Data/SBV/RegExp.hs +1/−1
- Data/SBV/SCase.hs +659/−248
- Data/SBV/SMT/SMT.hs +6/−5
- Data/SBV/SMT/SMTLib2.hs +1/−1
- Data/SBV/SMT/Utils.hs +1/−2
- Data/SBV/TP.hs +5/−2
- Data/SBV/TP/Kernel.hs +86/−29
- Data/SBV/TP/TP.hs +117/−93
- Data/SBV/TP/Utils.hs +259/−85
- Data/SBV/Tools/Polynomial.hs +7/−2
- Data/SBV/Tools/WeakestPreconditions.hs +16/−16
- Data/SBV/Trans.hs +2/−2
- Data/SBV/Utils/CrackNum.hs +1/−1
- Documentation/SBV/Examples/ADT/Expr.hs +28/−23
- Documentation/SBV/Examples/ADT/Param.hs +29/−24
- Documentation/SBV/Examples/ADT/Types.hs +1/−1
- Documentation/SBV/Examples/BitPrecise/PrefixSum.hs +5/−5
- Documentation/SBV/Examples/Misc/Definitions.hs +59/−21
- Documentation/SBV/Examples/Misc/LambdaArray.hs +10/−10
- Documentation/SBV/Examples/Puzzles/SquareBirthday.hs +7/−7
- Documentation/SBV/Examples/TP/Ackermann.hs +18/−9
- Documentation/SBV/Examples/TP/Basics.hs +101/−45
- Documentation/SBV/Examples/TP/BinarySearch.hs +10/−8
- Documentation/SBV/Examples/TP/Coins.hs +18/−15
- Documentation/SBV/Examples/TP/Collatz.hs +119/−0
- Documentation/SBV/Examples/TP/ConstFold.hs +111/−75
- Documentation/SBV/Examples/TP/Countdown.hs +135/−0
- Documentation/SBV/Examples/TP/Fibonacci.hs +10/−2
- Documentation/SBV/Examples/TP/GCD.hs +123/−89
- Documentation/SBV/Examples/TP/InsertionSort.hs +24/−14
- Documentation/SBV/Examples/TP/Kadane.hs +20/−12
- Documentation/SBV/Examples/TP/Lists.hs +167/−81
- Documentation/SBV/Examples/TP/Majority.hs +7/−5
- Documentation/SBV/Examples/TP/McCarthy91.hs +17/−4
- Documentation/SBV/Examples/TP/MergeSort.hs +172/−133
- Documentation/SBV/Examples/TP/MutualCorecursion.hs +187/−0
- Documentation/SBV/Examples/TP/NatStream.hs +121/−0
- Documentation/SBV/Examples/TP/Numeric.hs +22/−2
- Documentation/SBV/Examples/TP/Peano.hs +72/−37
- Documentation/SBV/Examples/TP/PigeonHole.hs +1/−0
- Documentation/SBV/Examples/TP/PowerMod.hs +124/−373
- Documentation/SBV/Examples/TP/Primes.hs +45/−24
- Documentation/SBV/Examples/TP/QuickSort.hs +182/−128
- Documentation/SBV/Examples/TP/RevAcc.hs +7/−1
- Documentation/SBV/Examples/TP/Reverse.hs +105/−61
- Documentation/SBV/Examples/TP/SortHelpers.hs +14/−5
- Documentation/SBV/Examples/TP/StrongInduction.hs +64/−40
- Documentation/SBV/Examples/TP/SumReverse.hs +1/−0
- Documentation/SBV/Examples/TP/TautologyChecker.hs +133/−89
- Documentation/SBV/Examples/TP/UpDown.hs +13/−10
- Documentation/SBV/Examples/TP/VM.hs +27/−24
- Documentation/SBV/Examples/WeakestPreconditions/IntDiv.hs +3/−3
- Documentation/SBV/Examples/WeakestPreconditions/IntSqrt.hs +3/−3
- Documentation/SBV/Examples/WeakestPreconditions/Length.hs +3/−3
- Documentation/SBV/Examples/WeakestPreconditions/Sum.hs +7/−7
- README.md +140/−95
- SBVBenchSuite/Utils/SBVBenchFramework.hs +1/−1
- SBVTestSuite/GoldFiles/adt_expr00.gold +134/−11
- SBVTestSuite/GoldFiles/adt_expr01.gold +134/−11
- SBVTestSuite/GoldFiles/adt_expr02.gold +134/−11
- SBVTestSuite/GoldFiles/adt_expr03.gold +134/−11
- SBVTestSuite/GoldFiles/adt_gen00.gold +146/−13
- SBVTestSuite/GoldFiles/adt_lit00.gold +134/−11
- SBVTestSuite/GoldFiles/adt_lit01.gold +134/−11
- SBVTestSuite/GoldFiles/adt_lit02.gold +134/−11
- SBVTestSuite/GoldFiles/adt_lit03.gold +134/−11
- SBVTestSuite/GoldFiles/adt_lit04.gold +134/−11
- SBVTestSuite/GoldFiles/adt_lit05.gold +134/−11
- SBVTestSuite/GoldFiles/adt_nested18.gold +134/−11
- SBVTestSuite/GoldFiles/adt_nested23.gold +134/−11
- SBVTestSuite/GoldFiles/adt_nested24.gold +134/−11
- SBVTestSuite/GoldFiles/adt_nested29.gold +134/−11
- SBVTestSuite/GoldFiles/adt_pexpr00.gold +134/−11
- SBVTestSuite/GoldFiles/adt_pexpr01.gold +134/−11
- SBVTestSuite/GoldFiles/adt_pexpr02.gold +134/−11
- SBVTestSuite/GoldFiles/adt_pexpr03.gold +134/−11
- SBVTestSuite/GoldFiles/adt_pgen00.gold +172/−44
- SBVTestSuite/GoldFiles/adt_pgen01.gold +5/−5
- SBVTestSuite/GoldFiles/adt_pgen02.gold +5/−5
- SBVTestSuite/GoldFiles/adt_pgen03.gold +5/−5
- SBVTestSuite/GoldFiles/adt_pgen04.gold +5/−5
- SBVTestSuite/GoldFiles/adt_pgen05.gold +6/−6
- SBVTestSuite/GoldFiles/adt_pgen06.gold +6/−6
- SBVTestSuite/GoldFiles/adt_pgen07.gold +6/−6
- SBVTestSuite/GoldFiles/adt_pgen08.gold +7/−7
- SBVTestSuite/GoldFiles/adt_pgen09.gold +7/−7
- SBVTestSuite/GoldFiles/adt_pgen10.gold +7/−7
- SBVTestSuite/GoldFiles/adt_pgen11.gold +5/−5
- SBVTestSuite/GoldFiles/adt_pgen12.gold +5/−5
- SBVTestSuite/GoldFiles/doctest_sanity.gold +3/−3
- SBVTestSuite/GoldFiles/lambda04.gold +94/−1
- SBVTestSuite/GoldFiles/lambda05.gold +195/−0
- SBVTestSuite/GoldFiles/lambda06.gold +131/−0
- SBVTestSuite/GoldFiles/lambda07.gold +326/−0
- SBVTestSuite/GoldFiles/lambda08.gold +99/−0
- SBVTestSuite/GoldFiles/lambda09.gold +99/−0
- SBVTestSuite/GoldFiles/lambda10.gold +97/−0
- SBVTestSuite/GoldFiles/lambda11.gold +99/−0
- SBVTestSuite/GoldFiles/lambda12.gold +97/−0
- SBVTestSuite/GoldFiles/lambda13.gold +107/−0
- SBVTestSuite/GoldFiles/lambda14.gold +142/−18
- SBVTestSuite/GoldFiles/lambda15.gold +216/−0
- SBVTestSuite/GoldFiles/lambda16.gold +216/−0
- SBVTestSuite/GoldFiles/lambda17.gold +220/−0
- SBVTestSuite/GoldFiles/lambda18.gold +362/−16
- SBVTestSuite/GoldFiles/lambda19.gold +216/−0
- SBVTestSuite/GoldFiles/lambda20.gold +216/−0
- SBVTestSuite/GoldFiles/lambda21.gold +220/−0
- SBVTestSuite/GoldFiles/lambda22.gold +135/−16
- SBVTestSuite/GoldFiles/lambda23.gold +456/−16
- SBVTestSuite/GoldFiles/lambda24.gold +142/−18
- SBVTestSuite/GoldFiles/lambda25.gold +357/−18
- SBVTestSuite/GoldFiles/lambda27.gold +111/−0
- SBVTestSuite/GoldFiles/lambda28.gold +111/−0
- SBVTestSuite/GoldFiles/lambda29.gold +112/−0
- SBVTestSuite/GoldFiles/lambda30.gold +112/−0
- SBVTestSuite/GoldFiles/lambda31.gold +105/−0
- SBVTestSuite/GoldFiles/lambda32.gold +105/−0
- SBVTestSuite/GoldFiles/lambda47.gold +81/−0
- SBVTestSuite/GoldFiles/lambda48.gold +89/−0
- SBVTestSuite/GoldFiles/lambda49.gold +138/−0
- SBVTestSuite/GoldFiles/lambda50.gold +138/−0
- SBVTestSuite/GoldFiles/lambda51.gold +138/−0
- SBVTestSuite/GoldFiles/lambda52.gold +138/−0
- SBVTestSuite/GoldFiles/lambda53.gold +1/−7
- SBVTestSuite/GoldFiles/lambda54.gold +4/−0
- SBVTestSuite/GoldFiles/lambda55.gold +4/−0
- SBVTestSuite/GoldFiles/lambda56.gold +433/−27
- SBVTestSuite/GoldFiles/lambda57.gold +96/−73
- SBVTestSuite/GoldFiles/lambda57a.gold +928/−0
- SBVTestSuite/GoldFiles/lambda57b.gold +824/−0
- SBVTestSuite/GoldFiles/lambda57c.gold +225/−0
- SBVTestSuite/GoldFiles/lambda81.gold +207/−0
- SBVTestSuite/GoldFiles/lambda82.gold +121/−0
- SBVTestSuite/GoldFiles/lambda85.gold +121/−0
- SBVTestSuite/GoldFiles/lambda86.gold +121/−0
- SBVTestSuite/GoldFiles/lambda87.gold +340/−0
- SBVTestSuite/GoldFiles/listFloat2.gold +115/−2
- SBVTestSuite/GoldFiles/recursive10_mutual.gold +212/−0
- SBVTestSuite/GoldFiles/recursive11_chain.gold +299/−0
- SBVTestSuite/GoldFiles/recursive12_badMutual.gold +526/−0
- SBVTestSuite/GoldFiles/recursive13_mutualMeasure.gold +212/−0
- SBVTestSuite/GoldFiles/recursive14_badMutualMeasure.gold +294/−0
- SBVTestSuite/GoldFiles/recursive15_mixedMutualMeasure.gold +212/−0
- SBVTestSuite/GoldFiles/recursive16_badMixedMutualMeasure.gold +1135/−0
- SBVTestSuite/GoldFiles/recursive17_chainMeasure.gold +299/−0
- SBVTestSuite/GoldFiles/recursive19_selfAndMutual.gold +297/−0
- SBVTestSuite/GoldFiles/recursive1_ack.gold +1003/−0
- SBVTestSuite/GoldFiles/recursive20_mutualTP.gold +221/−0
- SBVTestSuite/GoldFiles/recursive21_allSelfBadCross.gold +613/−0
- SBVTestSuite/GoldFiles/recursive22_allSelfGoodCross.gold +376/−0
- SBVTestSuite/GoldFiles/recursive23_mutualProductive.gold +74/−0
- SBVTestSuite/GoldFiles/recursive24_badMutualProductive.gold +15/−0
- SBVTestSuite/GoldFiles/recursive25_contractMutualRejected.gold +16/−0
- SBVTestSuite/GoldFiles/recursive26_selfAndMutualProductive.gold +83/−0
- SBVTestSuite/GoldFiles/recursive27_mutualProductive3.gold +93/−0
- SBVTestSuite/GoldFiles/recursive28_noTermCheck.gold +53/−0
- SBVTestSuite/GoldFiles/recursive2_enum.gold +158/−0
- SBVTestSuite/GoldFiles/recursive3_badMeasure.gold +94/−0
- SBVTestSuite/GoldFiles/recursive4_mcCarthy91.gold +175/−0
- SBVTestSuite/GoldFiles/recursive5_badContract.gold +159/−0
- SBVTestSuite/GoldFiles/recursive6_uselessContract.gold +153/−0
- SBVTestSuite/GoldFiles/recursive7_productive.gold +54/−0
- SBVTestSuite/GoldFiles/recursive8_badProductive.gold +12/−0
- SBVTestSuite/GoldFiles/recursive9_productive2.gold +56/−0
- SBVTestSuite/GoldFiles/smtFuncUniq_captureConflict.gold +9/−0
- SBVTestSuite/GoldFiles/smtFuncUniq_captureTagged.gold +43/−0
- SBVTestSuite/GoldFiles/smtFuncUniq_conflict.gold +9/−0
- SBVTestSuite/GoldFiles/smtFuncUniq_recursiveConflict.gold +9/−0
- SBVTestSuite/GoldFiles/smtFuncUniq_recursiveOk.gold +131/−0
- SBVTestSuite/GoldFiles/smtFuncUniq_sameOk.gold +40/−0
- SBVTestSuite/GoldFiles/tpCache_alias.gold +3/−0
- SBVTestSuite/GoldFiles/tpCache_calcCollapse.gold +4/−0
- SBVTestSuite/GoldFiles/tpCache_hit.gold +2/−0
- SBVTestSuite/GoldFiles/tpCache_miss.gold +1/−0
- SBVTestSuite/GoldFiles/tpCache_nested.gold +3/−0
- SBVTestSuite/GoldFiles/tpCache_statsHit.gold +4/−0
- SBVTestSuite/GoldFiles/tpCache_statsMiss.gold +3/−0
- SBVTestSuite/GoldFiles/tpCache_statsNested.gold +4/−0
- SBVTestSuite/GoldFiles/tuple_enum.gold +1/−1
- SBVTestSuite/SBVTest.hs +4/−0
- SBVTestSuite/TestSuite/ADT/Expr.hs +6/−6
- SBVTestSuite/TestSuite/ADT/MutRec.hs +14/−12
- SBVTestSuite/TestSuite/ADT/PExpr.hs +5/−5
- SBVTestSuite/TestSuite/Basics/ArithSolver.hs +1/−1
- SBVTestSuite/TestSuite/Basics/Lambda.hs +22/−2
- SBVTestSuite/TestSuite/Basics/Recursive.hs +415/−6
- SBVTestSuite/TestSuite/Basics/SmtFunctionUnique.hs +84/−0
- SBVTestSuite/TestSuite/Basics/TPCaching.hs +138/−0
- SBVTestSuite/TestSuite/Basics/Tuple.hs +2/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase01.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase01.stderr +4/−4
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase02.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase02.stderr +4/−9
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase03.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase03.stderr +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase04.hs +4/−4
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase04.stderr +10/−6
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase05.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase05.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase06.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase06.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase07.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase07.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase08.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase08.stderr +12/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase09.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase09.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase10.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase10.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase11.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase11.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase12.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase12.stderr +30/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase13.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase13.stderr +12/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase14.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase14.stderr +30/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase15.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase15.stderr +33/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase16.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase16.stderr +35/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase17.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase17.stderr +19/−4
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase18.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase18.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase19.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase19.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase20.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase20.stderr +19/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase21.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase21.stderr +39/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase22.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase22.stderr +42/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase23.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase23.stderr +38/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase24.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase24.stderr +32/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase25.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase25.stderr +35/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase26.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase26.stderr +33/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase27.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase27.stderr +38/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase28.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase28.stderr +34/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase29.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase29.stderr +48/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase30.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase30.stderr +18/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase31.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase31.stderr +28/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase32.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase32.stderr +15/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase33.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase33.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase34.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase34.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase35.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase35.stderr +18/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase36.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase36.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase37.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase37.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase38.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase38.stderr +19/−4
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase39.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase39.stderr +28/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase40.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase40.stderr +36/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase41.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase41.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase42.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase42.stderr +33/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase43.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase43.stderr +17/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase44.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase44.stderr +48/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase45.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase45.stderr +31/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase46.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase46.stderr +34/−4
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase47.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase47.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase48.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase48.stderr +28/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase49.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase49.stderr +12/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase50.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase50.stderr +8/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase51.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase51.stderr +11/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase52.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase52.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase53.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase53.stderr +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase54.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase54.stderr +9/−5
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase55.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase55.stderr +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase56.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase56.stderr +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase57.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase57.stderr +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase58.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase58.stderr +39/−39
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase59.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase59.stderr +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase60.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase60.stderr +1/−1
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase61.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase61.stderr +11/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase62.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase62.stderr +11/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase63.hs +22/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase63.stderr +14/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase64.hs +19/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase64.stderr +8/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase65.hs +21/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase65.stderr +19/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase66.hs +23/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase66.stderr +26/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase67.hs +24/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase67.stderr +34/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase68.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase68.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase69.hs +21/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase69.stderr +19/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase70.hs +21/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase70.stderr +14/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase71.hs +21/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase71.stderr +18/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase72.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase72.stderr +11/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase73.hs +21/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase73.stderr +17/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase74.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase74.stderr +14/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase75.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase75.stderr +8/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase76.hs +21/−0
- SBVTestSuite/TestSuite/CompileTests/PCase/PCase76.stderr +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase01.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase01.stderr +4/−4
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase02.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase02.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase03.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase03.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase04.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase04.stderr +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase05.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase05.stderr +4/−9
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase06.hs +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase06.stderr +6/−7
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase07.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase07.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase08.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase08.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase09.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase09.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase10.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase10.stderr +28/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase100.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase100.stderr +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase101.hs +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase101.stderr +31/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase102.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase102.stderr +10/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase103.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase103.stderr +12/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase104.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase104.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase105.hs +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase105.stderr +34/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase106.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase106.stderr +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase11.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase11.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase12.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase12.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase13.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase13.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase14.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase14.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase15.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase15.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase16.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase16.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase17.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase17.stderr +24/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase18.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase18.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase19.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase19.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase20.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase20.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase21.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase21.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase22.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase22.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase23.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase23.stderr +16/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase24.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase24.stderr +26/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase25.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase25.stderr +26/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase26.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase27.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase28.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase28.stderr +25/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase29.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase29.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase30.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase30.stderr +12/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase31.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase32.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase33.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase33.stderr +34/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase34.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase34.stderr +32/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase35.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase35.stderr +32/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase36.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase36.stderr +27/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase37.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase37.stderr +29/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase38.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase38.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase39.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase39.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase40.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase40.stderr +29/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase41.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase41.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase42.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase42.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase43.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase43.stderr +24/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase44.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase44.stderr +29/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase45.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase45.stderr +25/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase46.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase46.stderr +32/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase47.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase47.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase48.hs +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase48.stderr +3/−3
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase49.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase49.stderr +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase50.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase50.stderr +2/−4
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase51.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase51.stderr +2/−2
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase52.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase52.stderr +2/−4
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase53.hs +1/−1
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase53.stderr +2/−4
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase54.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase54.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase55.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase55.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase56.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase56.stderr +12/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase57.hs +13/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase57.stderr +8/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase58.hs +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase58.stderr +28/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase59.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase59.stderr +27/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase60.hs +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase60.stderr +19/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase61.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase61.stderr +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase62.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase62.stderr +13/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase63.hs +13/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase63.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase64.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase64.stderr +11/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase65.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase65.stderr +13/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase66.hs +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase66.stderr +33/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase67.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase67.stderr +12/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase68.hs +13/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase68.stderr +8/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase69.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase69.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase70.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase70.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase71.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase71.stderr +11/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase72.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase72.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase73.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase73.stderr +12/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase74.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase74.stderr +10/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase75.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase75.stderr +11/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase76.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase76.stderr +10/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase77.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase77.stderr +12/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase78.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase78.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase79.hs +15/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase79.stderr +10/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase80.hs +13/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase80.stderr +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase81.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase81.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase82.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase82.stderr +10/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase83.hs +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase83.stderr +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase84.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase84.stderr +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase85.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase85.stderr +9/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase86.hs +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase86.stderr +10/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase87.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase87.stderr +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase88.hs +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase88.stderr +14/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase89.hs +19/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase89.stderr +43/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase90.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase90.stderr +16/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase91.hs +23/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase91.stderr +23/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase92.hs +22/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase92.stderr +20/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase93.hs +22/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase93.stderr +18/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase94.hs +20/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase94.stderr +18/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase95.hs +19/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase95.stderr +21/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase96.hs +21/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase96.stderr +22/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase97.hs +23/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase97.stderr +17/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase98.hs +19/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase98.stderr +19/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase99.hs +24/−0
- SBVTestSuite/TestSuite/CompileTests/SCase/SCase99.stderr +26/−0
- SBVTestSuite/Utils/SBVTestFramework.hs +19/−2
- sbv.cabal +11/−3
CHANGES.md view
@@ -1,6 +1,153 @@ * Hackage: <http://hackage.haskell.org/package/sbv> * GitHub: <http://github.com/LeventErkok/sbv> +### Version 14.0, 2026-04-01++ * [BACKWARDS COMPATIBILITY] The most important change in this release is how SBV treats+ function definitions via `smtFunction` and its variants. In prior versions, these definitions were+ directly translated to SMT-lib, without checking that they actually terminate. Starting with+ this release, SBV now requires all functions to terminate (with an escape hatch where the user+ explicitly opts out), and it proves it for all functions involved in a proof. SBV guesses+ and verifies a termination measure, and in case it can't do so will tell the user to supply+ their own version. This major departure from the old style of ignoring termination is a step+ towards incorporating a better architecture for much improved (semi-)automated theorem proving+ in SBV. See below for more details.++ * [BACKWARDS COMPATIBILITY] Major improvements to the `sCase` and `pCase` quasi-quoters:+ - Type prefix is no longer required; the type is inferred automatically+ from the patterns. Old syntax: `[sCase|Expr e of ...]`. New syntax: `[sCase| e of ...]`.++ - Wildcard-only patterns are now supported. An unguarded wildcard generates the rhs directly,+ while guarded wildcards produce an `ite`-chain (for `sCase`) or proof obligations (for `pCase`).++ - Built-in types are now supported: `Maybe`, `Either`, `List`, and `Tuple2` through `Tuple8`.+ Nested patterns across built-in types are also supported (e.g., `Just (x:_)`, `Left (a, b)`).+ For single-constructor types, the generated code omits the redundant constructor tester guard.++ - Primitive types are now supported: `Bool`, `Integer`, `Char`, and `String`. Patterns can use+ `True`/`False`, integer literals, character literals, string literals, variable bindings,+ and wildcards.++ ```haskell+ [sCase| m of [sCase| x of [sCase| xs of [sCase| c of+ Nothing -> 0 0 -> sTrue [] -> 0 'a' -> 1+ Just x -> x + 1 _ -> sFalse x : xs' -> x + f xs' 'b' -> 2+ |] |] |] _ -> 0+ |]++ [sCase| x of [sCase| x of+ _ | x .> 0 -> x 0 -> y+ | sTrue -> -x _ | x .> y -> x+ |] | sTrue -> y+ |]+ ```++ - As-patterns (`x@pat`) are now supported in both top-level and nested positions.+ The as-name is bound to the scrutinee (top-level) or accessor (nested) via a+ let-binding, which is elided when the name is unused. This works with all pattern+ types: constructors, tuples, lists, wildcards, and in combination with nested `case`+ expressions.++ ```haskell+ [sCase| xs of+ a : tl@(_ : _) -> a + case tl of+ b : _ -> b+ [] -> 0+ _ : _ -> 0+ [] -> 0+ |]+ ```++ - Plain `case` expressions inside `[sCase|...|]` and `[pCase|...|]` are now automatically+ treated as symbolic case-splits. This works around GHC's quasi-quoter nesting limitation+ (`[sCase|` cannot contain `|]`), and makes nested symbolic case expressions natural:++ ```haskell+ [sCase| e of+ Zero -> case m of+ Nothing -> 0+ Just v -> v+ Num k -> k+ Add a b -> t a m + t b m+ |]+ ```++ All `case` expressions inside `sCase` and `pCase` become symbolic; use a `let` or helper+ function for regular Haskell case expressions.++ * Improved documentation for `lambdaArray`, explaining the model-theoretic distinction+ between the pure array theory (`select`/`store`/`const`) and the richer setting where+ arrays are identified with function spaces.++ * [BACKWARDS COMPATIBILITY] `recall` and `recallWith` no longer take a `String` argument.+ A recalled proof is now automatically cached and reused if the same proposition is+ encountered again. `tpNoCache` has been removed.++ * SBV now detects conflicting `smtFunction` definitions: if two calls use the same SMT+ name but have different bodies, an error is raised. Identical re-registrations (which+ happen naturally with recursive functions) remain allowed.++ * SBV now automatically checks termination of recursive functions defined via `smtFunction`.+ A measure (a non-negative expression that strictly decreases at each recursive call) is+ guessed automatically from argument types when possible. For functions that need an explicit+ measure, use `smtFunctionWithMeasure`:++ ```haskell+ ld = smtFunctionWithMeasure "ld" (\k n -> (n - k) `smax` 0, [])+ $ \k n -> ite (n `sMod` k .== 0) k (ld (k+1) n)+ ```++ When the measure requires inductive properties to verify, supply TP proof actions as helpers+ via `measureLemma`/`measureLemmaWith`:++ ```haskell+ normalize = smtFunctionWithMeasure "normalize"+ ( \f -> tuple (ifComplexity f, ifDepth f)+ , [measureLemma ifDepthNonNeg, measureLemma ifComplexityPos]+ )+ $ \f -> ...+ ```++ * For nested recursive functions (like McCarthy's 91 function) where the termination argument+ depends on the function's return value at smaller inputs, use `smtFunctionWithContract`. This+ takes a measure and a contract (post-condition) that are verified simultaneously via well-founded+ induction:++ ```haskell+ mcCarthy91 = smtFunctionWithContract "mcCarthy91"+ ( \n -> 0 `smax` (101 - n)+ , \n r -> n .<= 100 .=> r .== 91+ , []+ )+ $ \n -> ite (n .> 100) (n - 10) (mcCarthy91 (mcCarthy91 (n + 11)))+ ```++ * Productive (corecursive) functions can now be defined via `smtProductiveFunction`. Unlike+ terminating functions, productive functions need not have a base case — they may produce+ infinite output, so long as every recursive call is guarded by a data constructor.++ * New function `smtFunctionNoTermination` for defining recursive SMT functions without any+ termination check. The function is emitted as `define-fun-rec` and the user takes+ responsibility for well-definedness. Use this for functions where termination is believed+ but cannot be proven. Any TP proof that depends on such a function will be marked as+ `[Modulo: <name> termination]` instead of `[Proven]` in its root of trust.++ * New example `Documentation.SBV.Examples.TP.Countdown`, proving properties of a+ list-building countdown function using induction.++ * New example `Documentation.SBV.Examples.TP.NatStream`, demonstrating `smtProductiveFunction`+ with the infinite stream `nats n = [n, n+1, n+2, ...]` and proofs about its head, length, and+ element access.++ * New example `Documentation.SBV.Examples.TP.MutualCorecursion`, demonstrating mutually+ corecursive productive functions. Two functions `ping` and `pong` take turns producing+ elements of a stream, and we prove elementwise equality and that the k-th element of+ `ping n` is `n + k`.++ * New example `Documentation.SBV.Examples.TP.Collatz`, using `smtFunctionNoTermination` to+ define the Collatz function (whose termination is a famous open problem) and proving that+ all powers of two reach 1.+ ### Version 13.6, 2026-03-02 * The `sCase` quasi-quoter now supports nested constructor patterns. Sub-patterns@@ -23,7 +170,7 @@ positions (and at the top level inside a constructor). For example: ```haskell- p e = [sCase|Expr e of+ p e = [sCase|Formula e of Val 0 -> 100 -- fires when the Val field equals 0 Val 1 -> 200 -- fires when the Val field equals 1 Add (Val 0) r -> eval r -- nested literal: fires when left child is Val 0@@ -99,7 +246,7 @@ * Remove Eq constraint on readArray, generalizing it to arbitrary types for array-reads. - * Addded 'freeArray', which creates an array with no constraints at all. (Compare to 'constArray'.)+ * Added 'freeArray', which creates an array with no constraints at all. (Compare to 'constArray'.) Note that this is useful for expression contexts. If you're in a symbolic context (i.e., in the Symbolic monad), you can just use 'free' or 'sArray' as usual.)
Data/SBV.hs view
@@ -238,7 +238,7 @@ , SChar, SString -- ** Symbolic lists -- $lists- , SList+ , SList, (.:) -- ** Symbolic enumerators , EnumSymbolic(..), sEnum -- ** Symbolic case-expressions@@ -304,7 +304,7 @@ -- * Symbolic Equality and Comparisons -- $distinctNote- , EqSymbolic(..), OrdSymbolic(..), Equality(..)+ , EqSymbolic(..), OrdSymbolic(..), Zero(..), MeasureOf, Equality(..) -- * Conditionals: Mergeable values , Mergeable(..), ite, iteLazy @@ -352,7 +352,14 @@ , mkSymbolic -- * Stopping unrolling: Defined functions- , SMTDefinable(..), smtHOFunction, Closure(..), registerType+ , SMTDefinable(..)+ , smtFunction+ , smtFunctionWithMeasure+ , smtFunctionWithContract+ , smtProductiveFunction+ , smtFunctionNoTermination+ , ContractOf, MeasureHelper(..)+ , smtHOFunction, smtHOFunctionWithMeasure, Closure(..), registerType -- * Special relations -- $specialRels@@ -1166,18 +1173,20 @@ eval :: SExpr -> SInteger eval = go [] where go :: SList (String, Integer) -> SExpr -> SInteger- go = smtFunction "eval" $ \env expr -> [sCase|Expr expr of- Num i -> i- Var s -> get env s- Add l r -> go env l + go env r- Mul l r -> go env l * go env r- Let s e r -> go (tuple (s, go env e) SL..: env) r- |]+ go = smtFunction "eval"+ $ \env expr -> [sCase| expr of+ Num i -> i+ Var s -> get env s+ Add l r -> go env l + go env r+ Mul l r -> go env l * go env r+ Let s e r -> go (tuple (s, go env e) SL..: env) r+ |] get :: SList (String, Integer) -> SString -> SInteger- get = smtFunction "get" $ \env s -> ite (SL.null env) 0- $ let (k, v) = untuple (SL.head env)- in ite (s .== k) v (get (SL.tail env) s)+ get = smtFunction "get"+ $ \env s -> ite (SL.null env) 0+ $ let (k, v) = untuple (SL.head env)+ in ite (s .== k) v (get (SL.tail env) s) @ which defines an interpreter for this data-type. Such definitions also come with an induction principle
Data/SBV/Client.hs view
@@ -34,6 +34,8 @@ , getConstructors ) where +import Data.SBV.Core.TH (getConstructors, bad, report)+ import Data.Generics import Control.Monad (filterM, mapAndUnzipM, zipWithM)@@ -41,8 +43,6 @@ import qualified Control.Exception as C -import Data.Maybe (fromMaybe)- import Data.Char import Data.Word import Data.Int@@ -513,7 +513,7 @@ fs <- mapM (\(nm, _) -> TH.newName ('f' : TH.nameBase nm)) cstrs res <- TH.newName "result" - let def = TH.FunD cnm [TH.Clause (map TH.VarP (se : fs)) (TH.NormalB (iteChain (zipWith (mkCase se) fs cstrs))) []]+ let def = TH.FunD cnm [TH.Clause (map TH.VarP (fs ++ [se])) (TH.NormalB (iteChain (zipWith (mkCase se) fs cstrs))) []] iteChain :: [(TH.Exp, TH.Exp)] -> TH.Exp iteChain [] = error $ unlines [ "Data.SBV.mkADT: Impossible happened!"@@ -538,7 +538,7 @@ (TH.AppT (TH.ConT ''Mergeable) (TH.VarT res) : [TH.AppT (TH.ConT ''SymVal) (TH.VarT p) | p <- params] )- (mkFun (sType : fTypes)))+ (mkFun (fTypes ++ [sType]))) addDoc ("Case analyzer for the type " ++ bnm ++ ".") cnm pure [sig, def]@@ -592,101 +592,6 @@ | True = ADTFull pure (k, args, cs)--bad :: MonadFail m => String -> [String] -> m a-bad what extras = fail $ unlines $ ("mkSymbolic: " ++ what) : map (" " ++) extras--report :: String-report = "Please report this as a feature request."---- | Collect the constructors-getConstructors :: TH.Name -> TH.Q ([TH.Name], [(TH.Name, [(Maybe TH.Name, TH.Type)])])-getConstructors typeName = do res@(_, cstrs) <- getConstructorsFromType (TH.ConT typeName)-- -- make sure accessors are unique- let noDup [] = pure ()- noDup (n:ns)- | n `elem` ns = bad "Unsupported field accessor definition."- [ "Multiply used: " ++ TH.nameBase n- , ""- , "SBV does not support cases where accessor fields are replicated."- , "Please use each accessor only once."- ]- | True = noDup ns- noDup [n | (_, fs) <- cstrs, (Just n, _) <- fs]-- pure res-- where getConstructorsFromType :: TH.Type -> TH.Q ([TH.Name], [(TH.Name, [(Maybe TH.Name, TH.Type)])])- getConstructorsFromType ty = do ty' <- expandSyns ty- case headCon ty' of- Just (n, args) -> reifyFromHead n args- Nothing -> bad "Not a type constructor"- [ "Name : " ++ show typeName- , "Type : " ++ show ty- , "Expanded: " ++ show ty'- ]-- headCon :: TH.Type -> Maybe (TH.Name, [TH.Type])- headCon = go []- where go args (TH.ConT n) = Just (n, reverse args)- go args (TH.AppT t a) = go (a:args) t- go args (TH.SigT t _) = go args t- go args (TH.ParensT t) = go args t- go _ _ = Nothing-- reifyFromHead :: TH.Name -> [TH.Type] -> TH.Q ([TH.Name], [(TH.Name, [(Maybe TH.Name, TH.Type)])])- reifyFromHead n args = do info <- TH.reify n- case info of- TH.TyConI (TH.DataD _ _ tvs _ cons _) -> (map tvName tvs,) <$> mapM (expandCon (mkSubst tvs args)) cons- TH.TyConI (TH.NewtypeD _ _ tvs _ con _) -> (map tvName tvs,) <$> mapM (expandCon (mkSubst tvs args)) [con]- TH.TyConI (TH.TySynD _ tvs rhs) -> getConstructorsFromType (applySubst (mkSubst tvs args) rhs)- _ -> bad "Unsupported kind"- [ "Type : " ++ show typeName- , "Name : " ++ show n- , "Kind : " ++ show info- ]-- onSnd f (a, b) = (a,) <$> f b-- expandCon :: [(TH.Name, TH.Type)] -> TH.Con -> TH.Q (TH.Name, [(Maybe TH.Name, TH.Type)])- expandCon sub (TH.NormalC n fields) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\( _,t) -> (Nothing, t))) fields- expandCon sub (TH.RecC n fields) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\(fn,_,t) -> (Just fn, t))) fields- expandCon sub (TH.InfixC (_, t1) n (_, t2)) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub)) [(Nothing, t1), (Nothing, t2)]- {- These don't have proper correspondences in SMTLib; so ignore.- expandCon sub (TH.ForallC _ _ c) = expandCon sub c- expandCon sub (TH.GadtC [n] fields _) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\( _,t) -> (Nothing, t))) fields- expandCon sub (TH.RecGadtC [n] fields _) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\(fn,_,t) -> (Just fn, t))) fields- -}- expandCon _ c = bad "Unsupported constructor form: "- [ "Type : " ++ show typeName- , "Constructor: " ++ show c- , ""- , report- ]-- tvName :: TH.TyVarBndr TH.BndrVis -> TH.Name- tvName (TH.PlainTV n _) = n- tvName (TH.KindedTV n _ _) = n-- -- | Make substitution from type variables to actual args- mkSubst :: [TH.TyVarBndr TH.BndrVis] -> [TH.Type] -> [(TH.Name, TH.Type)]- mkSubst tvs = zip (map tvName tvs)-- -- | Apply substitution to a Type- applySubst :: [(TH.Name, TH.Type)] -> TH.Type -> TH.Type- applySubst sub = go- where go (TH.VarT n) = fromMaybe (TH.VarT n) (n `lookup` sub)- go (TH.AppT t1 t2) = TH.AppT (go t1) (go t2)- go (TH.SigT t k) = TH.SigT (go t) k- go (TH.ParensT t) = TH.ParensT (go t)- go (TH.InfixT t1 n t2) = TH.InfixT (go t1) n (go t2)- go (TH.UInfixT t1 n t2) = TH.UInfixT (go t1) n (go t2)- go (TH.ForallT bs ctx t) = TH.ForallT bs (map goPred ctx) (go t)- go t = t-- goPred (TH.AppT t1 t2) = TH.AppT (go t1) (go t2)- goPred p = p -- | Find the SBV kind for this type toSBV :: TH.Name -> TH.Name -> TH.Type -> TH.Q Kind
Data/SBV/Client/BaseIO.hs view
@@ -34,7 +34,7 @@ import GHC.TypeLits (KnownNat) -import Data.IORef(readIORef, writeIORef)+import Data.IORef(readIORef, modifyIORef') import qualified Data.SBV.Core.Data as Trans import qualified Data.SBV.Core.Model as Trans@@ -224,7 +224,7 @@ let new = case filter (`notElem` olds) (nm : [nm ++ "_" ++ show i | i <- [(1 :: Int) ..]]) of h:_ -> h [] -> error $ "Impossible: Can't get a fresh variable from infinite list in partition." ++ show (nm, term)- writeIORef rPartitionVars (olds ++ [new])+ modifyIORef' rPartitionVars (++ [new]) pure new -- declare and constrain
Data/SBV/Control/Utils.hs view
@@ -37,7 +37,7 @@ , startOptimizer, getObjectiveValues, getModel, getModelAtIndex ) where -import Data.List (sortBy, sortOn, partition, groupBy, tails, intercalate, nub, sort, isPrefixOf, isSuffixOf)+import Data.List (sortBy, sortOn, partition, groupBy, tails, intercalate, isPrefixOf, isSuffixOf) import Data.Char (isPunctuation, isSpace, isDigit) import Data.Function (on)@@ -47,6 +47,7 @@ import qualified Data.Foldable as F (toList) import qualified Data.Map.Strict as Map+import qualified Data.Set as Set (empty, fromList, toAscList) import qualified Data.Sequence as S import qualified Data.Text as T @@ -103,8 +104,6 @@ import Data.SBV.Control.Types -import qualified Data.Set as Set (empty, fromList, toAscList)- import qualified Control.Exception as C import GHC.Stack@@ -173,7 +172,7 @@ -- update global consts to have the new ones (newConsts, allConsts) <- liftIO $ do nc <- readIORef (rNewConsts is) oc <- readIORef rGlobalConsts- let allConsts = Map.union nc oc+ let !allConsts = Map.union nc oc writeIORef rGlobalConsts allConsts pure (nc, allConsts) @@ -1305,12 +1304,11 @@ getUIs :: forall m. (MonadIO m, MonadQuery m) => m [(String, (Bool, Maybe [String], SBVType))] getUIs = do State{rUIMap, rDefns, rIncState} <- queryState -- NB. no need to worry about new-defines, because we don't allow definitions once query mode starts- defines <- do allDefs <- io $ readIORef rDefns- pure $ map fst allDefs+ defineSet <- Map.keysSet <$> io (readIORef rDefns) prior <- io $ readIORef rUIMap new <- io $ readIORef rIncState >>= readIORef . rNewUIs- return $ nub $ sort [p | p@(n, _) <- Map.toList prior ++ Map.toList new, n `notElem` defines]+ return $ Map.toList $ Map.withoutKeys (Map.union prior new) defineSet -- | Return all satisfying models. getAllSatResult :: forall m. (MonadIO m, MonadQuery m, SolverContext m) => m AllSatResult@@ -1917,6 +1915,20 @@ res <- liftIO $ extractSymbolicSimulationState st setOpts <- liftIO $ reverse <$> readIORef (rSMTOptions st)++ -- Run any registered measure checks (termination/productivity verification)+ liftIO $ do skip <- readIORef (rSkipMeasureChecks st)+ unless skip $ do+ checks <- readIORef (rMeasureChecks st)+ unless (null checks) $ do+ let nms = map (\(n, _, _) -> n) checks+ debug cfg ["[MEASURE] Verifying termination measures for: " ++ intercalate ", " nms]+ mapM_ (\(nm, isProductive, check) -> do+ debug cfg ["[MEASURE] Checking: " ++ nm]+ check cfg+ let tag = if isProductive then "productive" else "terminating"+ debug cfg ["[MEASURE] Passed (" ++ tag ++ "): " ++ nm]+ ) checks let SMTProblem{smtLibPgm} = runProofOn rm queryContext [] res cfg' = cfg { solverSetOptions = solverSetOptions cfg ++ setOpts }
Data/SBV/Core/AlgReals.hs view
@@ -9,6 +9,7 @@ -- Algebraic reals in Haskell. ----------------------------------------------------------------------------- +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}@@ -101,7 +102,7 @@ merge [] = [] merge [x] = [x] merge ((a, b):r@((c, d):xs))- | b == d = merge ((a+c, b):xs)+ | b == d = let !s = a+c in merge ((s, b):xs) | True = (a, b) : merge r instance Show AlgRealPoly where
Data/SBV/Core/Concrete.hs view
@@ -100,19 +100,19 @@ -- | A constant value. -- Note: If you add a new constructor here, make sure you add the -- corresponding equality in the instance "Eq CVal" and "Ord CVal"!-data CVal = CAlgReal !AlgReal -- ^ Algebraic real- | CInteger !Integer -- ^ Bit-vector/unbounded integer- | CFloat !Float -- ^ Float- | CDouble !Double -- ^ Double- | CFP !FP -- ^ Arbitrary float- | CRational Rational -- ^ Rational- | CChar !Char -- ^ Character- | CString !String -- ^ String- | CList ![CVal] -- ^ List- | CSet !(RCSet CVal) -- ^ Set. Can be regular or complemented.- | CADT (String, [(Kind, CVal)]) -- ^ ADT: Constructor, and fields- | CTuple ![CVal] -- ^ Tuple- | CArray !(ArrayModel CVal CVal) -- ^ Arrays are backed by look-up tables concretely+data CVal = CAlgReal !AlgReal -- ^ Algebraic real+ | CInteger !Integer -- ^ Bit-vector/unbounded integer+ | CFloat !Float -- ^ Float+ | CDouble !Double -- ^ Double+ | CFP !FP -- ^ Arbitrary float+ | CRational !Rational -- ^ Rational+ | CChar !Char -- ^ Character+ | CString !String -- ^ String+ | CList ![CVal] -- ^ List+ | CSet !(RCSet CVal) -- ^ Set. Can be regular or complemented.+ | CADT !(String, [(Kind, CVal)]) -- ^ ADT: Constructor, and fields+ | CTuple ![CVal] -- ^ Tuple+ | CArray !(ArrayModel CVal CVal) -- ^ Arrays are backed by look-up tables concretely deriving (G.Data, Generic, NFData) -- | Assign a rank to constant values, this is structural and helps with ordering
Data/SBV/Core/Data.hs view
@@ -33,7 +33,7 @@ , SFloatingPoint, SFPHalf, SFPBFloat, SFPSingle, SFPDouble, SFPQuad , SWord, SInt, WordN, IntN , SRational- , SChar, SString, SList+ , SChar, SString, SList, (.:), nil , SArray, ArrayModel(..) , STuple, STuple2, STuple3, STuple4, STuple5, STuple6, STuple7, STuple8 , RCSet(..), SSet@@ -85,6 +85,8 @@ import GHC.Generics (Generic, U1(..), M1(..), (:*:)(..), K1(..), (:+:)(..)) import qualified GHC.Generics as G +import GHC.Exts (IsList(..))+ import System.Random import Data.SBV.Core.AlgReals@@ -198,6 +200,43 @@ -- length, and internally processed as one unit as opposed to a fixed-length list of items. -- Note that lists can be nested, i.e., we do allow lists of lists of ... items. type SList a = SBV [a]++-- | Prepend an element, the traditional @cons@.+--+-- >>> 1 .: 2 .: 3 .: [4, 5, 6 :: SInteger]+-- [1,2,3,4,5,6] :: [SInteger]+infixr 5 .:+(.:) :: forall a. (SymVal a, SymVal [a]) => SBV a -> SList a -> SList a+a .: as+ | Just av <- unliteral a+ , Just asv <- unliteral as+ = literal (av : asv)+ | Just asv <- unliteral as, null asv -- singleton: skip the concat with empty+ = SBV $ SVal kl $ Right $ cache $ \st -> do+ sva <- sbvToSV st a+ newExpr st kl (SBVApp (SeqOp (SeqUnit ka)) [sva])+ | True+ = SBV $ SVal kl $ Right $ cache r+ where ka = kindOf (Proxy @a)+ kl = kindOf (Proxy @[a])+ r st = do sva <- sbvToSV st a+ svs <- newExpr st kl (SBVApp (SeqOp (SeqUnit ka)) [sva])+ svas <- sbvToSV st as+ newExpr st kl (SBVApp (SeqOp (SeqConcat kl)) [svs, svas])++-- | Empty list. This value has the property that it's the only list with length 0. If you use @OverloadedLists@ extension,+-- you can write it as the familiar @[]@.+nil :: SymVal [a] => SList a+nil = literal []++-- | 'IsList' instance allows list literals to be written compactly.+instance (SymVal a, SymVal [a]) => IsList (SList a) where+ type Item (SList a) = SBV a++ fromList = foldr (.:) nil -- Don't use [] here for nil, as this is the very definition of doing overloaded lists+ toList x = case unliteral x of+ Nothing -> error "IsList.toList used in a symbolic context"+ Just xs -> map literal xs -- | Symbolic arrays. A symbolic array is more akin to a function in SMTLib (and thus in SBV), -- as opposed to contagious-storage with a finite range as found in many programming languages.
Data/SBV/Core/Model.hs view
@@ -9,3334 +9,4771 @@ -- Instance declarations for our symbolic world ----------------------------------------------------------------------------- -{-# LANGUAGE BangPatterns #-}-{-# LANGUAGE CPP #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE DefaultSignatures #-}-{-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE NamedFieldPuns #-}-{-# LANGUAGE RankNTypes #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeApplications #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE UndecidableInstances #-}--{-# OPTIONS_GHC -Wall -Werror -fno-warn-orphans -Wno-incomplete-uni-patterns #-}--module Data.SBV.Core.Model (- Mergeable(..), Equality(..), EqSymbolic(..), OrdSymbolic(..), SDivisible(..), SMTDefinable(..), QSaturate, qSaturateSavingObservables- , Metric(..), minimize, maximize, assertWithPenalty, SIntegral, SFiniteBits(..)- , ite, iteLazy, sFromIntegral, sShiftLeft, sShiftRight, sRotateLeft, sBarrelRotateLeft, sRotateRight, sBarrelRotateRight, sSignedShiftArithRight, (.^)- , some- , oneIf, genVar, genVar_- , pbAtMost, pbAtLeast, pbExactly, pbLe, pbGe, pbEq, pbMutexed, pbStronglyMutexed- , sBool, sBool_, sBools, sWord8, sWord8_, sWord8s, sWord16, sWord16_, sWord16s, sWord32, sWord32_, sWord32s- , sWord64, sWord64_, sWord64s, sInt8, sInt8_, sInt8s, sInt16, sInt16_, sInt16s, sInt32, sInt32_, sInt32s, sInt64, sInt64_- , sInt64s, sInteger, sInteger_, sIntegers, sReal, sReal_, sReals, sFloat, sFloat_, sFloats, sDouble, sDouble_, sDoubles- , sWord, sWord_, sWords, sInt, sInt_, sInts- , sFPHalf, sFPHalf_, sFPHalfs, sFPBFloat, sFPBFloat_, sFPBFloats, sFPSingle, sFPSingle_, sFPSingles, sFPDouble, sFPDouble_, sFPDoubles, sFPQuad, sFPQuad_, sFPQuads, sArray, sArray_, sArrays- , sFloatingPoint, sFloatingPoint_, sFloatingPoints- , sRoundNearestTiesToEven, sRoundNearestTiesToAway, sRoundTowardPositive, sRoundTowardNegative, sRoundTowardZero- , sRNE, sRNA, sRTP, sRTN, sRTZ- , sChar, sChar_, sChars, sString, sString_, sStrings, sList, sList_, sLists- , sRational, sRational_, sRationals- , SymTuple, sTuple, sTuple_, sTuples- , sSet, sSet_, sSets- , sEDivMod, sEDiv, sEMod- , sDivides- , solve- , slet- , sRealToSInteger, sRealToSIntegerTruncate, label, observe, observeIf, sObserve- , sAssert- , liftQRem, liftDMod, symbolicMergeWithKind- , genLiteral, genFromCV, genMkSymVar- , zeroExtend, signExtend- , sbvQuickCheck- , readArray, writeArray, constArray, freeArray, lambdaArray, listArray- , FromSized, ToSized, FromSizedBV(..), ToSizedBV(..)- , smtHOFunction, Closure(..)- )- where--import Control.Applicative (ZipList(ZipList))-import Control.Monad (when, unless, mplus, replicateM)-import Control.Monad.IO.Class (MonadIO, liftIO)--import qualified Control.Exception as C--import GHC.Generics (M1(..), U1(..), (:*:)(..), K1(..))-import qualified GHC.Generics as G--import GHC.Stack-import GHC.TypeLits-#if MIN_VERSION_base(4,18,0)- hiding(SChar)-#endif--import Data.Array (Array, Ix, elems, bounds, rangeSize)-import qualified Data.Array as DA (listArray)--import Data.Bits (Bits(..))-import Data.Int (Int8, Int16, Int32, Int64)-import Data.Kind (Type, Constraint)-import Data.List (genericLength, genericIndex, genericTake, unzip4, unzip5, unzip6, unzip7, intercalate)-import Data.Maybe (fromMaybe, mapMaybe)-import Data.String (IsString(..))-import Data.Word (Word8, Word16, Word32, Word64)--import Data.List.NonEmpty (NonEmpty(..))-import qualified Data.List.NonEmpty as NE--import qualified Data.Set as Set--import Data.Proxy-import Data.Dynamic (fromDynamic, toDyn, Typeable)--import Test.QuickCheck (Testable(..), Arbitrary(..))-import qualified Test.QuickCheck.Test as QC (isSuccess)-import qualified Test.QuickCheck as QC (quickCheckResult, counterexample)-import qualified Test.QuickCheck.Monadic as QC (monadicIO, run, assert, pre, monitor)--import qualified Data.Foldable as F (toList)--import Data.SBV.Core.AlgReals-import Data.SBV.Core.Sized-import Data.SBV.Core.SizedFloats-import Data.SBV.Core.Data hiding (Constraint)-import Data.SBV.Core.Symbolic-import Data.SBV.Core.Operations-import Data.SBV.Core.Kind-import Data.SBV.Lambda-import Data.SBV.Utils.ExtractIO (ExtractIO)--import Data.SBV.Provers.Prover (defaultSMTCfg, SafeResult(..), defs2smt, prove)-import Data.SBV.SMT.SMT (ThmResult, showModel)--import Data.SBV.Utils.Numeric (fpIsEqualObjectH)--import Data.IORef (readIORef, writeIORef)-import Data.SBV.Utils.Lib--import Data.Char---- Symbolic-Word class instances--import Crypto.Hash.SHA512 (hash)-import qualified Data.ByteString.Base16 as B-import qualified Data.ByteString.Char8 as BC---- | Generate a variable, named-genVar :: MonadSymbolic m => VarContext -> Kind -> String -> m (SBV a)-genVar q k = mkSymSBV q k . Just---- | Generate an unnamed variable-genVar_ :: MonadSymbolic m => VarContext -> Kind -> m (SBV a)-genVar_ q k = mkSymSBV q k Nothing---- | Generate a finite constant bitvector-genLiteral :: Integral a => Kind -> a -> SBV b-genLiteral k = SBV . SVal k . Left . mkConstCV k---- | Convert a constant to an integral value-genFromCV :: Integral a => CV -> a-genFromCV (CV _ (CInteger x)) = fromInteger x-genFromCV c = error $ "genFromCV: Unsupported non-integral value: " ++ show c---- | Generalization of 'Data.SBV.genMkSymVar'-genMkSymVar :: MonadSymbolic m => Kind -> VarContext -> Maybe String -> m (SBV a)-genMkSymVar k mbq Nothing = genVar_ mbq k-genMkSymVar k mbq (Just s) = genVar mbq k s--instance SymVal Bool where- mkSymVal = genMkSymVar KBool- literal = SBV . svBool- fromCV = cvToBool--instance SymVal Word8 where- mkSymVal = genMkSymVar (KBounded False 8)- literal = genLiteral (KBounded False 8)- fromCV = genFromCV--instance SymVal Int8 where- mkSymVal = genMkSymVar (KBounded True 8)- literal = genLiteral (KBounded True 8)- fromCV = genFromCV--instance SymVal Word16 where- mkSymVal = genMkSymVar (KBounded False 16)- literal = genLiteral (KBounded False 16)- fromCV = genFromCV--instance SymVal Int16 where- mkSymVal = genMkSymVar (KBounded True 16)- literal = genLiteral (KBounded True 16)- fromCV = genFromCV--instance SymVal Word32 where- mkSymVal = genMkSymVar (KBounded False 32)- literal = genLiteral (KBounded False 32)- fromCV = genFromCV--instance SymVal Int32 where- mkSymVal = genMkSymVar (KBounded True 32)- literal = genLiteral (KBounded True 32)- fromCV = genFromCV--instance SymVal Word64 where- mkSymVal = genMkSymVar (KBounded False 64)- literal = genLiteral (KBounded False 64)- fromCV = genFromCV--instance SymVal Int64 where- mkSymVal = genMkSymVar (KBounded True 64)- literal = genLiteral (KBounded True 64)- fromCV = genFromCV--instance SymVal Integer where- mkSymVal = genMkSymVar KUnbounded- literal = SBV . SVal KUnbounded . Left . mkConstCV KUnbounded- fromCV = genFromCV- minMaxBound = Nothing--instance SymVal Rational where- mkSymVal = genMkSymVar KRational- literal = SBV . SVal KRational . Left . CV KRational . CRational- fromCV (CV _ (CRational r)) = r- fromCV c = error $ "SymVal.Rational: Unexpected non-rational value: " ++ show c- minMaxBound = Nothing--instance SymVal AlgReal where- mkSymVal = genMkSymVar KReal- literal = SBV . SVal KReal . Left . CV KReal . CAlgReal- fromCV (CV _ (CAlgReal a)) = a- fromCV c = error $ "SymVal.AlgReal: Unexpected non-real value: " ++ show c- minMaxBound = Nothing-- -- AlgReal needs its own definition of isConcretely- -- to make sure we avoid using unimplementable Haskell functions- isConcretely (SBV (SVal KReal (Left (CV KReal (CAlgReal v))))) p- | isExactRational v = p v- isConcretely _ _ = False--instance SymVal Float where- mkSymVal = genMkSymVar KFloat- literal = SBV . SVal KFloat . Left . CV KFloat . CFloat- fromCV (CV _ (CFloat a)) = a- fromCV c = error $ "SymVal.Float: Unexpected non-float value: " ++ show c- minMaxBound = Nothing-- -- For Float, we conservatively return 'False' for isConcretely. The reason is that- -- this function is used for optimizations when only one of the argument is concrete,- -- and in the presence of NaN's it would be incorrect to do any optimization- isConcretely _ _ = False--instance SymVal Double where- mkSymVal = genMkSymVar KDouble- literal = SBV . SVal KDouble . Left . CV KDouble . CDouble- fromCV (CV _ (CDouble a)) = a- fromCV c = error $ "SymVal.Double: Unexpected non-double value: " ++ show c- minMaxBound = Nothing-- -- For Double, we conservatively return 'False' for isConcretely. The reason is that- -- this function is used for optimizations when only one of the argument is concrete,- -- and in the presence of NaN's it would be incorrect to do any optimization- isConcretely _ _ = False--instance SymVal RoundingMode where- literal s = SBV $ SVal kRoundingMode $ Left $ CV kRoundingMode $ CADT (show s, [])- fromCV (CV k (CADT (s, [])))- | k == kRoundingMode- , Just mode <- s `lookup` [(show m, m) | m <- [minBound .. maxBound :: RoundingMode]]- = mode- fromCV c = error $ "SymVal.RoundingMode: Unexpected non-rounding mode value: " ++ show c---- | Symbolic variant of 'RoundNearestTiesToEven'-sRoundNearestTiesToEven :: SRoundingMode-sRoundNearestTiesToEven = literal RoundNearestTiesToEven---- | Symbolic variant of 'RoundNearestTiesToAway'-sRoundNearestTiesToAway :: SRoundingMode-sRoundNearestTiesToAway = literal RoundNearestTiesToAway---- | Symbolic variant of 'RoundTowardPositive'-sRoundTowardPositive :: SRoundingMode-sRoundTowardPositive = literal RoundTowardPositive---- | Symbolic variant of 'RoundTowardNegative'-sRoundTowardNegative :: SRoundingMode-sRoundTowardNegative = literal RoundTowardNegative---- | Symbolic variant of 'RoundTowardZero'-sRoundTowardZero :: SRoundingMode-sRoundTowardZero = literal RoundTowardZero---- | Alias for 'sRoundNearestTiesToEven'-sRNE :: SRoundingMode-sRNE = sRoundNearestTiesToEven---- | Alias for 'sRoundNearestTiesToAway'-sRNA :: SRoundingMode-sRNA = sRoundNearestTiesToAway---- | Alias for 'sRoundTowardPositive'-sRTP :: SRoundingMode-sRTP = sRoundTowardPositive---- | Alias for 'sRoundTowardNegative'-sRTN :: SRoundingMode-sRTN = sRoundTowardNegative---- | Alias for 'sRoundTowardZero'-sRTZ :: SRoundingMode-sRTZ = sRoundTowardZero---instance SymVal Char where- mkSymVal = genMkSymVar KChar- literal c = SBV . SVal KChar . Left . CV KChar $ CChar c- fromCV (CV _ (CChar a)) = a- fromCV c = error $ "SymVal.String: Unexpected non-char value: " ++ show c--instance SymVal a => SymVal [a] where- mkSymVal- | isKString @[a] undefined = genMkSymVar KString- | True = genMkSymVar (KList (kindOf (Proxy @a)))-- literal as- | isKString @[a] undefined = case fromDynamic (toDyn as) of- Just s -> SBV . SVal KString . Left . CV KString . CString $ s- Nothing -> error "SString: Cannot construct literal string!"- | True = let k = KList (kindOf (Proxy @a))- in SBV $ SVal k $ Left $ CV k $ CList $ map toCV as-- fromCV (CV _ (CString a)) = fromMaybe (error "SString: Cannot extract a literal string!")- (fromDynamic (toDyn a))- fromCV (CV _ (CList a)) = fromCV . CV (kindOf (Proxy @a)) <$> a- fromCV c = error $ "SymVal.fromCV: Unexpected non-list value: " ++ show c-- minMaxBound = Nothing--instance ValidFloat eb sb => HasKind (FloatingPoint eb sb) where- kindOf _ = KFP (intOfProxy (Proxy @eb)) (intOfProxy (Proxy @sb))--instance ValidFloat eb sb => SymVal (FloatingPoint eb sb) where- mkSymVal = genMkSymVar (KFP (intOfProxy (Proxy @eb)) (intOfProxy (Proxy @sb)))- literal (FloatingPoint r) = let k = KFP (intOfProxy (Proxy @eb)) (intOfProxy (Proxy @sb))- in SBV $ SVal k $ Left $ CV k (CFP r)- fromCV (CV _ (CFP r)) = FloatingPoint r- fromCV c = error $ "SymVal.FPR: Unexpected non-arbitrary-precision value: " ++ show c- minMaxBound = Nothing---- | 'SymVal' instance for 'WordN'-instance (KnownNat n, BVIsNonZero n) => SymVal (WordN n) where- literal x = genLiteral (kindOf x) x- mkSymVal = genMkSymVar (kindOf (undefined :: WordN n))- fromCV = genFromCV---- | 'SymVal' instance for 'IntN'-instance (KnownNat n, BVIsNonZero n) => SymVal (IntN n) where- literal x = genLiteral (kindOf x) x- mkSymVal = genMkSymVar (kindOf (undefined :: IntN n))- fromCV = genFromCV--toCV :: SymVal a => a -> CVal-toCV a = case literal a of- SBV (SVal _ (Left cv)) -> cvVal cv- _ -> error "SymVal.toCV: Impossible happened, couldn't produce a concrete value"--mkCVTup :: Int -> Kind -> [CVal] -> SBV a-mkCVTup i k@(KTuple ks) cs- | lks == lcs && lks == i- = SBV $ SVal k $ Left $ CV k $ CTuple cs- | True- = error $ "SymVal.mkCVTup: Impossible happened. Malformed tuple received: " ++ show (i, k)- where lks = length ks- lcs = length cs-mkCVTup i k _- = error $ "SymVal.mkCVTup: Impossible happened. Non-tuple received: " ++ show (i, k)--fromCVTup :: Int -> CV -> [CV]-fromCVTup i inp@(CV (KTuple ks) (CTuple cs))- | lks == lcs && lks == i- = zipWith CV ks cs- | True- = error $ "SymVal.fromCTup: Impossible happened. Malformed tuple received: " ++ show (i, inp)- where lks = length ks- lcs = length cs-fromCVTup i inp = error $ "SymVal.fromCVTup: Impossible happened. Non-tuple received: " ++ show (i, inp)--instance (HasKind a, HasKind b, SymVal a, SymVal b) => SymVal (ArrayModel a b) where- mkSymVal = genMkSymVar (KArray (kindOf (Proxy @a)) (kindOf (Proxy @b)))-- -- If the table has duplicate entries for keys, then the first one takes precedence.- -- That is, [(a, v1), (a, v2)] is equivalent to [(a, v1)]. The best way to think about- -- this is as a "stack" of writes. [(a, v1), (a, v2)] means we first "wrote" v2 at- -- a, and then wrote v1 at the same address; so the first write of v2 got overwritten.- literal (ArrayModel tbl def) = SBV . SVal knd . Left . CV knd $ CArray $ ArrayModel [(toCV k, toCV v) | (k, v) <- tbl] (toCV def)- where knd = kindOf (Proxy @(ArrayModel a b))-- fromCV (CV (KArray k1 k2) (CArray (ArrayModel assocs def))) = ArrayModel [(fromCV (CV k1 a), fromCV (CV k2 b)) | (a, b) <- assocs]- (fromCV (CV k2 def))-- fromCV bad = error $ "SymVal.fromCV (SArray): Malformed array received: " ++ show bad-- minMaxBound = Nothing--instance (Arbitrary a, Arbitrary b) => Arbitrary (ArrayModel a b) where- arbitrary = ArrayModel <$> arbitrary <*> arbitrary--instance (Ord a, SymVal a) => SymVal (RCSet a) where- mkSymVal = genMkSymVar (kindOf (Proxy @(RCSet a)))-- literal eur = SBV $ SVal k $ Left $ CV k $ CSet $ dir $ Set.map toCV s- where (dir, s) = case eur of- RegularSet x -> (RegularSet, x)- ComplementSet x -> (ComplementSet, x)- k = kindOf (Proxy @(RCSet a))-- fromCV (CV (KSet a) (CSet (RegularSet s))) = RegularSet $ Set.map (fromCV . CV a) s- fromCV (CV (KSet a) (CSet (ComplementSet s))) = ComplementSet $ Set.map (fromCV . CV a) s- fromCV bad = error $ "SymVal.fromCV (Set): Malformed set received: " ++ show bad-- minMaxBound = Nothing---- | SymVal for 0-tuple (i.e., unit)-instance SymVal () where- mkSymVal = genMkSymVar (KTuple [])- literal () = mkCVTup 0 (kindOf (Proxy @())) []- fromCV cv = fromCVTup 0 cv `seq` ()---- | SymVal for 2-tuples-instance (SymVal a, SymVal b) => SymVal (a, b) where- mkSymVal = genMkSymVar (kindOf (Proxy @(a, b)))- literal (v1, v2) = mkCVTup 2 (kindOf (Proxy @(a, b))) [toCV v1, toCV v2]- fromCV cv = let ~[v1, v2] = fromCVTup 2 cv- in (fromCV v1, fromCV v2)-- minMaxBound = Nothing---- | SymVal for 3-tuples-instance (SymVal a, SymVal b, SymVal c) => SymVal (a, b, c) where- mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c)))- literal (v1, v2, v3) = mkCVTup 3 (kindOf (Proxy @(a, b, c))) [toCV v1, toCV v2, toCV v3]- fromCV cv = let ~[v1, v2, v3] = fromCVTup 3 cv- in (fromCV v1, fromCV v2, fromCV v3)- minMaxBound = Nothing---- | SymVal for 4-tuples-instance (SymVal a, SymVal b, SymVal c, SymVal d) => SymVal (a, b, c, d) where- mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d)))- literal (v1, v2, v3, v4) = mkCVTup 4 (kindOf (Proxy @(a, b, c, d))) [toCV v1, toCV v2, toCV v3, toCV v4]- fromCV cv = let ~[v1, v2, v3, v4] = fromCVTup 4 cv- in (fromCV v1, fromCV v2, fromCV v3, fromCV v4)- minMaxBound = Nothing---- | SymVal for 5-tuples-instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e) => SymVal (a, b, c, d, e) where- mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e)))- literal (v1, v2, v3, v4, v5) = mkCVTup 5 (kindOf (Proxy @(a, b, c, d, e))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5]- fromCV cv = let ~[v1, v2, v3, v4, v5] = fromCVTup 5 cv- in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5)- minMaxBound = Nothing---- | SymVal for 6-tuples-instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f) => SymVal (a, b, c, d, e, f) where- mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e, f)))- literal (v1, v2, v3, v4, v5, v6) = mkCVTup 6 (kindOf (Proxy @(a, b, c, d, e, f))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5, toCV v6]- fromCV cv = let ~[v1, v2, v3, v4, v5, v6] = fromCVTup 6 cv- in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5, fromCV v6)- minMaxBound = Nothing---- | SymVal for 7-tuples-instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g) => SymVal (a, b, c, d, e, f, g) where- mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e, f, g)))- literal (v1, v2, v3, v4, v5, v6, v7) = mkCVTup 7 (kindOf (Proxy @(a, b, c, d, e, f, g))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5, toCV v6, toCV v7]- fromCV cv = let ~[v1, v2, v3, v4, v5, v6, v7] = fromCVTup 7 cv- in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5, fromCV v6, fromCV v7)- minMaxBound = Nothing---- | SymVal for 8-tuples-instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, SymVal h) => SymVal (a, b, c, d, e, f, g, h) where- mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e, f, g, h)))- literal (v1, v2, v3, v4, v5, v6, v7, v8) = mkCVTup 8 (kindOf (Proxy @(a, b, c, d, e, f, g, h))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5, toCV v6, toCV v7, toCV v8]- fromCV cv = let ~[v1, v2, v3, v4, v5, v6, v7, v8] = fromCVTup 8 cv- in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5, fromCV v6, fromCV v7, fromCV v8)- minMaxBound = Nothing--instance IsString SString where- fromString = literal----------------------------------------------------------------------------------------- * Smart constructors for creating symbolic values. These are not strictly--- necessary, as they are mere aliases for 'symbolic' and 'symbolics', but--- they nonetheless make programming easier.----------------------------------------------------------------------------------------- | Generalization of 'Data.SBV.sBool'-sBool :: MonadSymbolic m => String -> m SBool-sBool = symbolic---- | Generalization of 'Data.SBV.sBool_'-sBool_ :: MonadSymbolic m => m SBool-sBool_ = free_---- | Generalization of 'Data.SBV.sBools'-sBools :: MonadSymbolic m => [String] -> m [SBool]-sBools = symbolics---- | Generalization of 'Data.SBV.sWord8'-sWord8 :: MonadSymbolic m => String -> m SWord8-sWord8 = symbolic---- | Generalization of 'Data.SBV.sWord8_'-sWord8_ :: MonadSymbolic m => m SWord8-sWord8_ = free_---- | Generalization of 'Data.SBV.sWord8s'-sWord8s :: MonadSymbolic m => [String] -> m [SWord8]-sWord8s = symbolics---- | Generalization of 'Data.SBV.sWord16'-sWord16 :: MonadSymbolic m => String -> m SWord16-sWord16 = symbolic---- | Generalization of 'Data.SBV.sWord16_'-sWord16_ :: MonadSymbolic m => m SWord16-sWord16_ = free_---- | Generalization of 'Data.SBV.sWord16s'-sWord16s :: MonadSymbolic m => [String] -> m [SWord16]-sWord16s = symbolics---- | Generalization of 'Data.SBV.sWord32'-sWord32 :: MonadSymbolic m => String -> m SWord32-sWord32 = symbolic---- | Generalization of 'Data.SBV.sWord32_'-sWord32_ :: MonadSymbolic m => m SWord32-sWord32_ = free_---- | Generalization of 'Data.SBV.sWord32s'-sWord32s :: MonadSymbolic m => [String] -> m [SWord32]-sWord32s = symbolics---- | Generalization of 'Data.SBV.sWord64'-sWord64 :: MonadSymbolic m => String -> m SWord64-sWord64 = symbolic---- | Generalization of 'Data.SBV.sWord64_'-sWord64_ :: MonadSymbolic m => m SWord64-sWord64_ = free_---- | Generalization of 'Data.SBV.sWord64s'-sWord64s :: MonadSymbolic m => [String] -> m [SWord64]-sWord64s = symbolics---- | Generalization of 'Data.SBV.sInt8'-sInt8 :: MonadSymbolic m => String -> m SInt8-sInt8 = symbolic---- | Generalization of 'Data.SBV.sInt8_'-sInt8_ :: MonadSymbolic m => m SInt8-sInt8_ = free_---- | Generalization of 'Data.SBV.sInt8s'-sInt8s :: MonadSymbolic m => [String] -> m [SInt8]-sInt8s = symbolics---- | Generalization of 'Data.SBV.sInt16'-sInt16 :: MonadSymbolic m => String -> m SInt16-sInt16 = symbolic---- | Generalization of 'Data.SBV.sInt16_'-sInt16_ :: MonadSymbolic m => m SInt16-sInt16_ = free_---- | Generalization of 'Data.SBV.sInt16s'-sInt16s :: MonadSymbolic m => [String] -> m [SInt16]-sInt16s = symbolics---- | Generalization of 'Data.SBV.sInt32'-sInt32 :: MonadSymbolic m => String -> m SInt32-sInt32 = symbolic---- | Generalization of 'Data.SBV.sInt32_'-sInt32_ :: MonadSymbolic m => m SInt32-sInt32_ = free_---- | Generalization of 'Data.SBV.sInt32s'-sInt32s :: MonadSymbolic m => [String] -> m [SInt32]-sInt32s = symbolics---- | Generalization of 'Data.SBV.sInt64'-sInt64 :: MonadSymbolic m => String -> m SInt64-sInt64 = symbolic---- | Generalization of 'Data.SBV.sInt64_'-sInt64_ :: MonadSymbolic m => m SInt64-sInt64_ = free_---- | Generalization of 'Data.SBV.sInt64s'-sInt64s :: MonadSymbolic m => [String] -> m [SInt64]-sInt64s = symbolics---- | Generalization of 'Data.SBV.sInteger'-sInteger:: MonadSymbolic m => String -> m SInteger-sInteger = symbolic---- | Generalization of 'Data.SBV.sInteger_'-sInteger_:: MonadSymbolic m => m SInteger-sInteger_ = free_---- | Generalization of 'Data.SBV.sIntegers'-sIntegers :: MonadSymbolic m => [String] -> m [SInteger]-sIntegers = symbolics---- | Generalization of 'Data.SBV.sReal'-sReal:: MonadSymbolic m => String -> m SReal-sReal = symbolic---- | Generalization of 'Data.SBV.sReal_'-sReal_:: MonadSymbolic m => m SReal-sReal_ = free_---- | Generalization of 'Data.SBV.sReals'-sReals :: MonadSymbolic m => [String] -> m [SReal]-sReals = symbolics---- | Generalization of 'Data.SBV.sFloat'-sFloat :: MonadSymbolic m => String -> m SFloat-sFloat = symbolic---- | Generalization of 'Data.SBV.sFloat_'-sFloat_ :: MonadSymbolic m => m SFloat-sFloat_ = free_---- | Generalization of 'Data.SBV.sFloats'-sFloats :: MonadSymbolic m => [String] -> m [SFloat]-sFloats = symbolics---- | Generalization of 'Data.SBV.sDouble'-sDouble :: MonadSymbolic m => String -> m SDouble-sDouble = symbolic---- | Generalization of 'Data.SBV.sDouble_'-sDouble_ :: MonadSymbolic m => m SDouble-sDouble_ = free_---- | Generalization of 'Data.SBV.sDoubles'-sDoubles :: MonadSymbolic m => [String] -> m [SDouble]-sDoubles = symbolics---- | Generalization of 'Data.SBV.sFPHalf'-sFPHalf :: String -> Symbolic SFPHalf-sFPHalf = symbolic---- | Generalization of 'Data.SBV.sFPHalf_'-sFPHalf_ :: Symbolic SFPHalf-sFPHalf_ = free_---- | Generalization of 'Data.SBV.sFPHalfs'-sFPHalfs :: [String] -> Symbolic [SFPHalf]-sFPHalfs = symbolics---- | Generalization of 'Data.SBV.sFPBFloat'-sFPBFloat :: String -> Symbolic SFPBFloat-sFPBFloat = symbolic---- | Generalization of 'Data.SBV.sFPBFloat_'-sFPBFloat_ :: Symbolic SFPBFloat-sFPBFloat_ = free_---- | Generalization of 'Data.SBV.sFPBFloats'-sFPBFloats :: [String] -> Symbolic [SFPBFloat]-sFPBFloats = symbolics---- | Generalization of 'Data.SBV.sFPSingle'-sFPSingle :: String -> Symbolic SFPSingle-sFPSingle = symbolic---- | Generalization of 'Data.SBV.sFPSingle_'-sFPSingle_ :: Symbolic SFPSingle-sFPSingle_ = free_---- | Generalization of 'Data.SBV.sFPSingles'-sFPSingles :: [String] -> Symbolic [SFPSingle]-sFPSingles = symbolics---- | Generalization of 'Data.SBV.sFPDouble'-sFPDouble :: String -> Symbolic SFPDouble-sFPDouble = symbolic---- | Generalization of 'Data.SBV.sFPDouble_'-sFPDouble_ :: Symbolic SFPDouble-sFPDouble_ = free_---- | Generalization of 'Data.SBV.sFPDoubles'-sFPDoubles :: [String] -> Symbolic [SFPDouble]-sFPDoubles = symbolics---- | Generalization of 'Data.SBV.sFPQuad'-sFPQuad :: String -> Symbolic SFPQuad-sFPQuad = symbolic---- | Generalization of 'Data.SBV.sFPQuad_'-sFPQuad_ :: Symbolic SFPQuad-sFPQuad_ = free_---- | Generalization of 'Data.SBV.sFPQuads'-sFPQuads :: [String] -> Symbolic [SFPQuad]-sFPQuads = symbolics---- | Generalization of 'Data.SBV.sFloatingPoint'-sFloatingPoint :: ValidFloat eb sb => String -> Symbolic (SFloatingPoint eb sb)-sFloatingPoint = symbolic---- | Generalization of 'Data.SBV.sFloatingPoint_'-sFloatingPoint_ :: ValidFloat eb sb => Symbolic (SFloatingPoint eb sb)-sFloatingPoint_ = free_---- | Generalization of 'Data.SBV.sFloatingPoints'-sFloatingPoints :: ValidFloat eb sb => [String] -> Symbolic [SFloatingPoint eb sb]-sFloatingPoints = symbolics---- | Generalization of 'Data.SBV.sWord'-sWord :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => String -> m (SWord n)-sWord = symbolic---- | Generalization of 'Data.SBV.sWord_'-sWord_ :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => m (SWord n)-sWord_ = free_---- | Generalization of 'Data.SBV.sWord64s'-sWords :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => [String] -> m [SWord n]-sWords = symbolics---- | Generalization of 'Data.SBV.sInt'-sInt :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => String -> m (SInt n)-sInt = symbolic---- | Generalization of 'Data.SBV.sInt_'-sInt_ :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => m (SInt n)-sInt_ = free_---- | Generalization of 'Data.SBV.sInts'-sInts :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => [String] -> m [SInt n]-sInts = symbolics---- | Generalization of 'Data.SBV.sChar'-sChar :: MonadSymbolic m => String -> m SChar-sChar = symbolic---- | Generalization of 'Data.SBV.sChar_'-sChar_ :: MonadSymbolic m => m SChar-sChar_ = free_---- | Generalization of 'Data.SBV.sChars'-sChars :: MonadSymbolic m => [String] -> m [SChar]-sChars = symbolics---- | Generalization of 'Data.SBV.sString'-sString :: MonadSymbolic m => String -> m SString-sString = symbolic---- | Generalization of 'Data.SBV.sString_'-sString_ :: MonadSymbolic m => m SString-sString_ = free_---- | Generalization of 'Data.SBV.sStrings'-sStrings :: MonadSymbolic m => [String] -> m [SString]-sStrings = symbolics---- | Generalization of 'Data.SBV.sList'-sList :: (SymVal a, MonadSymbolic m) => String -> m (SList a)-sList = symbolic---- | Generalization of 'Data.SBV.sList_'-sList_ :: (SymVal a, MonadSymbolic m) => m (SList a)-sList_ = free_---- | Generalization of 'Data.SBV.sLists'-sLists :: (SymVal a, MonadSymbolic m) => [String] -> m [SList a]-sLists = symbolics---- | Generalization of 'Data.SBV.sAray'-sArray :: (SymVal a, SymVal b, MonadSymbolic m) => String -> m (SArray a b)-sArray = symbolic---- | Generalization of 'Data.SBV.sList_'-sArray_ :: (SymVal a, SymVal b, MonadSymbolic m) => m (SArray a b)-sArray_ = free_---- | Generalization of 'Data.SBV.sLists'-sArrays :: (SymVal a, SymVal b, MonadSymbolic m) => [String] -> m [SArray a b]-sArrays = symbolics---- | Identify tuple like things. Note that there are no methods, just instances to control type inference-class SymTuple a-instance SymTuple ()-instance SymTuple (a, b)-instance SymTuple (a, b, c)-instance SymTuple (a, b, c, d)-instance SymTuple (a, b, c, d, e)-instance SymTuple (a, b, c, d, e, f)-instance SymTuple (a, b, c, d, e, f, g)-instance SymTuple (a, b, c, d, e, f, g, h)---- | Generalization of 'Data.SBV.sTuple'-sTuple :: (SymTuple tup, SymVal tup, MonadSymbolic m) => String -> m (SBV tup)-sTuple = symbolic---- | Generalization of 'Data.SBV.sTuple_'-sTuple_ :: (SymTuple tup, SymVal tup, MonadSymbolic m) => m (SBV tup)-sTuple_ = free_---- | Generalization of 'Data.SBV.sTuples'-sTuples :: (SymTuple tup, SymVal tup, MonadSymbolic m) => [String] -> m [SBV tup]-sTuples = symbolics---- | Generalization of 'Data.SBV.sRational'-sRational :: MonadSymbolic m => String -> m SRational-sRational = symbolic---- | Generalization of 'Data.SBV.sRational_'-sRational_ :: MonadSymbolic m => m SRational-sRational_ = free_---- | Generalization of 'Data.SBV.sRationals'-sRationals :: MonadSymbolic m => [String] -> m [SRational]-sRationals = symbolics---- | Generalization of 'Data.SBV.sSet'-sSet :: (Ord a, SymVal a, MonadSymbolic m) => String -> m (SSet a)-sSet = symbolic---- | Generalization of 'Data.SBV.sMaybe_'-sSet_ :: (Ord a, SymVal a, MonadSymbolic m) => m (SSet a)-sSet_ = free_---- | Generalization of 'Data.SBV.sMaybes'-sSets :: (Ord a, SymVal a, MonadSymbolic m) => [String] -> m [SSet a]-sSets = symbolics---- | Generalization of 'Data.SBV.solve'-solve :: MonadSymbolic m => [SBool] -> m SBool-solve = return . sAnd---- | Convert an SReal to an SInteger. That is, it computes the--- largest integer @n@ that satisfies @sIntegerToSReal n <= r@--- essentially giving us the @floor@.------ For instance, @1.3@ will be @1@, but @-1.3@ will be @-2@.-sRealToSInteger :: SReal -> SInteger-sRealToSInteger x- | Just i <- unliteral x, isExactRational i- = literal $ floor (toRational i)- | True- = SBV (SVal KUnbounded (Right (cache y)))- where y st = do xsv <- sbvToSV st x- newExpr st KUnbounded (SBVApp (KindCast KReal KUnbounded) [xsv])---- | Convert an SReal to an SInteger, truncating version.-sRealToSIntegerTruncate :: SReal -> SInteger-sRealToSIntegerTruncate x = ite (x .< 0) (sRealToSInteger x) (- (sRealToSInteger (- x)))---- | label: Label the result of an expression. This is essentially a no-op, but useful as it generates a comment in the generated C/SMT-Lib code.--- Note that if the argument is a constant, then the label is dropped completely, per the usual constant folding strategy. Compare this to 'observe'--- which is good for printing counter-examples.-label :: SymVal a => String -> SBV a -> SBV a-label m x- | Just _ <- unliteral x = x- | True = SBV $ SVal k $ Right $ cache r- where k = kindOf x- r st = do xsv <- sbvToSV st x- newExpr st k (SBVApp (Label m) [xsv])----- | Observe the value of an expression, if the given condition holds. Such values are useful in model construction, as they are printed part of a satisfying model, or a--- counter-example. The same works for quick-check as well. Useful when we want to see intermediate values, or expected/obtained--- pairs in a particular run. Note that an observed expression is always symbolic, i.e., it won't be constant folded. Compare this to 'label'--- which is used for putting a label in the generated SMTLib-C code.------ NB. If the observed expression happens under a SBV-lambda expression, then it is silently ignored; since--- there's no way to access the value of such a value.-observeIf :: SymVal a => (a -> Bool) -> String -> SBV a -> SBV a-observeIf cond m x- | Just bad <- checkObservableName m- = error bad- | True- = SBV $ SVal k $ Right $ cache r- where k = kindOf x- r st = do xsv <- sbvToSV st (label ("Observing: " ++ m) x)- recordObservable st m (cond . fromCV) xsv- return xsv---- | Observe the value of an expression, unconditionally. See 'observeIf' for a generalized version.-observe :: SymVal a => String -> SBV a -> SBV a-observe = observeIf (const True)---- | Symbolic Comparisons. Similar to 'Eq', we cannot implement Haskell's 'Ord' class--- since there is no way to return an 'Ordering' value from a symbolic comparison.--- Furthermore, 'OrdSymbolic' requires 'Mergeable' to implement if-then-else, for the--- benefit of implementing symbolic versions of 'max' and 'min' functions.-infix 4 .<, .<=, .>, .>=-class (Mergeable a, EqSymbolic a) => OrdSymbolic a where- -- | Symbolic less than.- (.<) :: a -> a -> SBool- -- | Symbolic less than or equal to.- (.<=) :: a -> a -> SBool- -- | Symbolic greater than.- (.>) :: a -> a -> SBool- -- | Symbolic greater than or equal to.- (.>=) :: a -> a -> SBool- -- | Symbolic minimum.- smin :: a -> a -> a- -- | Symbolic maximum.- smax :: a -> a -> a- -- | Is the value within the allowed /inclusive/ range?- inRange :: a -> (a, a) -> SBool-- {-# MINIMAL (.<) #-}-- a .<= b = a .< b .|| a .== b- a .> b = b .< a- a .>= b = b .<= a-- a `smin` b = ite (a .<= b) a b- a `smax` b = ite (a .<= b) b a-- inRange x (y, z) = x .>= y .&& x .<= z---{- We can't have a generic instance of the form:--instance Eq a => EqSymbolic a where- x .== y = if x == y then true else sFalse--even if we're willing to allow Flexible/undecidable instances..-This is because if we allow this it would imply EqSymbolic (SBV a);-since (SBV a) has to be Eq as it must be a Num. But this wouldn't be-the right choice obviously; as the Eq instance is bogus for SBV-for natural reasons..--}---- It is tempting to put in an @Eq a@ superclass here. But doing so--- is complicated, as it requires all underlying types to have equality,--- which is at best shaky for algebraic reals and sets. So, leave it out.-instance (HasKind a, SymVal a) => EqSymbolic (SBV a) where- SBV x .== SBV y = SBV (svEqual x y)- SBV x ./= SBV y = SBV (svNotEqual x y)-- SBV x .=== SBV y = SBV (svStrongEqual x y)-- -- Custom version of distinct that generates better code for base types- distinct [] = sTrue- distinct [_] = sTrue- distinct xs | all isConc xs = checkDiff xs- | [SBV a, SBV b] <- xs, a `is` svBool True = SBV $ svNot b- | [SBV a, SBV b] <- xs, b `is` svBool True = SBV $ svNot a- | [SBV a, SBV b] <- xs, a `is` svBool False = SBV b- | [SBV a, SBV b] <- xs, b `is` svBool False = SBV a- -- 3 booleans can't be distinct!- | (x : _ : _ : _) <- xs, isBool x = sFalse- | True = SBV (SVal KBool (Right (cache r)))- where r st = do xsv <- mapM (sbvToSV st) xs- newExpr st KBool (SBVApp NotEqual xsv)-- -- We call this in case all are concrete, which will- -- reduce to a constant and generate no code at all!- -- Note that this is essentially the same as the default- -- definition, which unfortunately we can no longer call!- checkDiff [] = sTrue- checkDiff (a:as) = sAll (a ./=) as .&& checkDiff as-- -- Sigh, we can't use isConcrete since that requires SymVal- -- constraint that we don't have here. (To support SBools.)- isConc (SBV (SVal _ (Left _))) = True- isConc _ = False-- -- Likewise here; need to go lower.- SVal k1 (Left c1) `is` SVal k2 (Left c2) = (k1, c1) == (k2, c2)- _ `is` _ = False-- isBool (SBV (SVal KBool _)) = True- isBool _ = False-- -- Custom version of distinctExcept that generates better code for base types- distinctExcept [] _ = sTrue- distinctExcept [_] _ = sTrue- distinctExcept es ignored- | all isConc (es ++ ignored)- = distinct (filter ignoreConc es)- | True- = SBV (SVal KBool (Right (cache r)))- where ignoreConc x = case x `sElem` ignored of- SBV (SVal KBool (Left cv)) -> cvToBool cv- _ -> error $ "distinctExcept: Impossible happened, concrete sElem failed: " ++ show (es, ignored, x)-- r st = do let incr x table = ite (x `sElem` ignored) (0 :: SInteger) (1 + readArrayNoEq table x)-- initArray :: SArray a Integer- initArray = constArray 0-- finalArray = foldl (\table x -> writeArrayNoKnd table x (incr x table)) initArray es-- sbvToSV st $ sAll (\e -> readArrayNoEq finalArray e .<= (1 :: SInteger)) es-- -- Sigh, we can't use isConcrete since that requires SymVal- -- constraint that we don't have here. (To support SBools.)- isConc (SBV (SVal _ (Left _))) = True- isConc _ = False-- -- Version of readArray that doesn't have the Eq constraint, since we don't have it here- readArrayNoEq array key = SBV . SVal KUnbounded . Right $ cache g- where g st = do f <- sbvToSV st array- k <- sbvToSV st key- newExpr st KUnbounded (SBVApp ReadArray [f, k])-- writeArrayNoKnd :: forall key. HasKind key => SArray key Integer -> SBV key -> SInteger -> SArray key Integer- writeArrayNoKnd array key value = SBV . SVal k . Right $ cache g- where k = KArray (kindOf (Proxy @key)) KUnbounded-- g st = do arr <- sbvToSV st array- keyVal <- sbvToSV st key- val <- sbvToSV st value- newExpr st k (SBVApp WriteArray [arr, keyVal, val])---- We don't want to do a generic OrdSymbolic (SBV a) instance; since that would be dangerous, like the case--- for Num. So, we explicitly define for each type we care about.--#define MKSORD(CSTR, TYPE) \-instance CSTR => OrdSymbolic TYPE where { \- a@(SBV x) .< b@(SBV y) | smtComparable "<" a b = SBV (svLessThan x y) \- | True = SBV (svStructuralLessThan x y); \- \- a@(SBV x) .<= b@(SBV y) | smtComparable ".<=" a b = SBV (svLessEq x y) \- | True = a .< b .|| a .== b; \- \- a@(SBV x) .> b@(SBV y) | smtComparable ">" a b = SBV (svGreaterThan x y) \- | True = b .< a; \- \- a@(SBV x) .>= b@(SBV y) | smtComparable ">=" a b = SBV (svGreaterEq x y) \- | True = b .<= a; \-} \---- Derive basic instances we need. NB. We don't give the SRational instance here. It's handled--- in Data/SBV/Rational due to representation issues.-MKSORD((), SInteger)-MKSORD((), SWord8)-MKSORD((), SWord16)-MKSORD((), SWord32)-MKSORD((), SWord64)-MKSORD((), SInt8)-MKSORD((), SInt16)-MKSORD((), SInt32)-MKSORD((), SInt64)-MKSORD((), SFloat)-MKSORD((), SChar)-MKSORD((SymVal a), (SList a))-MKSORD((), SDouble)-MKSORD((), SReal)-MKSORD((KnownNat n, BVIsNonZero n), (SWord n))-MKSORD((KnownNat n, BVIsNonZero n), (SInt n))-MKSORD((ValidFloat eb sb), (SFloatingPoint eb sb))---- Tuples-MKSORD((SymVal a, SymVal b), (SBV (a, b)))-MKSORD((SymVal a, SymVal b, SymVal c), (SBV (a, b, c)))-MKSORD((SymVal a, SymVal b, SymVal c, SymVal d), (SBV (a, b, c, d)))-MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e), (SBV (a, b, c, d, e)))-MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f), (SBV (a, b, c, d, e, f)))-MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g), (SBV (a, b, c, d, e, f, g)))-MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, SymVal h), (SBV (a, b, c, d, e, f, g, h)))-#undef MKSORD---- Is this a type that's comparable by underlying translation to SMTLib?--- Note that we allow concrete versions to go through unless the type is a set, as there's really no reason not to.-smtComparable :: (SymVal a, HasKind a) => String -> SBV a -> SBV a -> Bool-smtComparable op x y- | isConcrete x && isConcrete y && not (isSet k)- = True- | True- = case k of- KVar {} -> False- KBool -> True- KBounded {} -> True- KUnbounded {} -> True- KReal {} -> True- KApp {} -> True- KADT {} -> True- KFloat -> True- KDouble -> True- KRational {} -> True- KFP {} -> True- KChar -> True- KString -> True- KList {} -> nope -- Unfortunately, no way for us to desugar this- KSet {} -> nope -- Ditto here..- KTuple {} -> False- KArray {} -> True- where k = kindOf x- nope = error $ "Data.SBV.OrdSymbolic: SMTLib does not support " ++ op ++ " for " ++ show k---- Bool-instance EqSymbolic Bool where- x .== y = fromBool $ x == y---- Lists-instance EqSymbolic a => EqSymbolic [a] where- [] .== [] = sTrue- (x:xs) .== (y:ys) = x .== y .&& xs .== ys- _ .== _ = sFalse-- [] .=== [] = sTrue- (x:xs) .=== (y:ys) = x .=== y .&& xs .=== ys- _ .=== _ = sFalse--instance OrdSymbolic a => OrdSymbolic [a] where- [] .< [] = sFalse- [] .< _ = sTrue- _ .< [] = sFalse- (x:xs) .< (y:ys) = x .< y .|| (x .== y .&& xs .< ys)---- NonEmpty-instance EqSymbolic a => EqSymbolic (NonEmpty a) where- (x :| xs) .== (y :| ys) = x : xs .== y : ys- (x :| xs) .=== (y :| ys) = x : xs .=== y : ys--instance OrdSymbolic a => OrdSymbolic (NonEmpty a) where- (x :| xs) .< (y :| ys) = x : xs .< y : ys---- Maybe-instance EqSymbolic a => EqSymbolic (Maybe a) where- Nothing .== Nothing = sTrue- Just a .== Just b = a .== b- _ .== _ = sFalse--instance OrdSymbolic a => OrdSymbolic (Maybe a) where- Nothing .< Nothing = sFalse- Nothing .< _ = sTrue- Just _ .< Nothing = sFalse- Just a .< Just b = a .< b---- Either-instance (EqSymbolic a, EqSymbolic b) => EqSymbolic (Either a b) where- Left a .== Left b = a .== b- Right a .== Right b = a .== b- _ .== _ = sFalse-- Left a .=== Left b = a .=== b- Right a .=== Right b = a .=== b- _ .=== _ = sFalse--instance (OrdSymbolic a, OrdSymbolic b) => OrdSymbolic (Either a b) where- Left a .< Left b = a .< b- Left _ .< Right _ = sTrue- Right _ .< Left _ = sFalse- Right a .< Right b = a .< b---- 2-Tuple-instance (EqSymbolic a, EqSymbolic b) => EqSymbolic (a, b) where- (a0, b0) .== (a1, b1) = a0 .== a1 .&& b0 .== b1- (a0, b0) .=== (a1, b1) = a0 .=== a1 .&& b0 .=== b1--instance (OrdSymbolic a, OrdSymbolic b) => OrdSymbolic (a, b) where- (a0, b0) .< (a1, b1) = a0 .< a1 .|| (a0 .== a1 .&& b0 .< b1)---- 3-Tuple-instance (EqSymbolic a, EqSymbolic b, EqSymbolic c) => EqSymbolic (a, b, c) where- (a0, b0, c0) .== (a1, b1, c1) = (a0, b0) .== (a1, b1) .&& c0 .== c1- (a0, b0, c0) .=== (a1, b1, c1) = (a0, b0) .=== (a1, b1) .&& c0 .=== c1--instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c) => OrdSymbolic (a, b, c) where- (a0, b0, c0) .< (a1, b1, c1) = (a0, b0) .< (a1, b1) .|| ((a0, b0) .== (a1, b1) .&& c0 .< c1)---- 4-Tuple-instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d) => EqSymbolic (a, b, c, d) where- (a0, b0, c0, d0) .== (a1, b1, c1, d1) = (a0, b0, c0) .== (a1, b1, c1) .&& d0 .== d1- (a0, b0, c0, d0) .=== (a1, b1, c1, d1) = (a0, b0, c0) .=== (a1, b1, c1) .&& d0 .=== d1--instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d) => OrdSymbolic (a, b, c, d) where- (a0, b0, c0, d0) .< (a1, b1, c1, d1) = (a0, b0, c0) .< (a1, b1, c1) .|| ((a0, b0, c0) .== (a1, b1, c1) .&& d0 .< d1)---- 5-Tuple-instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e) => EqSymbolic (a, b, c, d, e) where- (a0, b0, c0, d0, e0) .== (a1, b1, c1, d1, e1) = (a0, b0, c0, d0) .== (a1, b1, c1, d1) .&& e0 .== e1- (a0, b0, c0, d0, e0) .=== (a1, b1, c1, d1, e1) = (a0, b0, c0, d0) .=== (a1, b1, c1, d1) .&& e0 .=== e1--instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e) => OrdSymbolic (a, b, c, d, e) where- (a0, b0, c0, d0, e0) .< (a1, b1, c1, d1, e1) = (a0, b0, c0, d0) .< (a1, b1, c1, d1) .|| ((a0, b0, c0, d0) .== (a1, b1, c1, d1) .&& e0 .< e1)---- 6-Tuple-instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e, EqSymbolic f) => EqSymbolic (a, b, c, d, e, f) where- (a0, b0, c0, d0, e0, f0) .== (a1, b1, c1, d1, e1, f1) = (a0, b0, c0, d0, e0) .== (a1, b1, c1, d1, e1) .&& f0 .== f1- (a0, b0, c0, d0, e0, f0) .=== (a1, b1, c1, d1, e1, f1) = (a0, b0, c0, d0, e0) .=== (a1, b1, c1, d1, e1) .&& f0 .=== f1--instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e, OrdSymbolic f) => OrdSymbolic (a, b, c, d, e, f) where- (a0, b0, c0, d0, e0, f0) .< (a1, b1, c1, d1, e1, f1) = (a0, b0, c0, d0, e0) .< (a1, b1, c1, d1, e1)- .|| ((a0, b0, c0, d0, e0) .== (a1, b1, c1, d1, e1) .&& f0 .< f1)---- 7-Tuple-instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e, EqSymbolic f, EqSymbolic g) => EqSymbolic (a, b, c, d, e, f, g) where- (a0, b0, c0, d0, e0, f0, g0) .== (a1, b1, c1, d1, e1, f1, g1) = (a0, b0, c0, d0, e0, f0) .== (a1, b1, c1, d1, e1, f1) .&& g0 .== g1- (a0, b0, c0, d0, e0, f0, g0) .=== (a1, b1, c1, d1, e1, f1, g1) = (a0, b0, c0, d0, e0, f0) .=== (a1, b1, c1, d1, e1, f1) .&& g0 .=== g1--instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e, OrdSymbolic f, OrdSymbolic g) => OrdSymbolic (a, b, c, d, e, f, g) where- (a0, b0, c0, d0, e0, f0, g0) .< (a1, b1, c1, d1, e1, f1, g1) = (a0, b0, c0, d0, e0, f0) .< (a1, b1, c1, d1, e1, f1)- .|| ((a0, b0, c0, d0, e0, f0) .== (a1, b1, c1, d1, e1, f1) .&& g0 .< g1)---- | Regular expressions can be compared for equality. Note that we diverge here from the equality--- in the concrete sense; i.e., the Eq instance does not match the symbolic case. This is a bit unfortunate,--- but unavoidable with the current design of how we "distinguish" operators. Hopefully shouldn't be a big deal,--- though one should be careful.-instance EqSymbolic RegExp where- r1 .== r2 = SBV $ SVal KBool $ Right $ cache r- where r st = newExpr st KBool $ SBVApp (RegExOp (RegExEq r1 r2)) []-- r1 ./= r2 = SBV $ SVal KBool $ Right $ cache r- where r st = newExpr st KBool $ SBVApp (RegExOp (RegExNEq r1 r2)) []---- | Symbolic Numbers. This is a simple class that simply incorporates all number like--- base types together, simplifying writing polymorphic type-signatures that work for all--- symbolic numbers, such as 'SWord8', 'SInt8' etc. For instance, we can write a generic--- list-minimum function as follows:------ @--- mm :: SIntegral a => [SBV a] -> SBV a--- mm = foldr1 (\a b -> ite (a .<= b) a b)--- @------ It is similar to the standard 'Integral' class, except ranging over symbolic instances.-class (SymVal a, Num a, Num (SBV a), Bits a, Integral a) => SIntegral a---- 'SIntegral' Instances, skips Real/Float/Bool-instance SIntegral Word8-instance SIntegral Word16-instance SIntegral Word32-instance SIntegral Word64-instance SIntegral Int8-instance SIntegral Int16-instance SIntegral Int32-instance SIntegral Int64-instance SIntegral Integer-instance (KnownNat n, BVIsNonZero n) => SIntegral (WordN n)-instance (KnownNat n, BVIsNonZero n) => SIntegral (IntN n)---- | Zero extend a bit-vector.-zeroExtend :: forall n m bv. ( KnownNat n, BVIsNonZero n, SymVal (bv n)- , KnownNat m, BVIsNonZero m, SymVal (bv m)- , n + 1 <= m- , SIntegral (bv (m - n))- , BVIsNonZero (m - n)- ) => SBV (bv n) -- ^ Input, of size @n@- -> SBV (bv m) -- ^ Output, of size @m@. @n < m@ must hold-zeroExtend n = SBV $ svZeroExtend i (unSBV n)- where nv = intOfProxy (Proxy @n)- mv = intOfProxy (Proxy @m)- i = fromIntegral (mv - nv)---- | Sign extend a bit-vector.-signExtend :: forall n m bv. ( KnownNat n, BVIsNonZero n, SymVal (bv n)- , KnownNat m, BVIsNonZero m, SymVal (bv m)- , n + 1 <= m- , SFiniteBits (bv n)- , SIntegral (bv (m - n))- , BVIsNonZero (m - n)- ) => SBV (bv n) -- ^ Input, of size @n@- -> SBV (bv m) -- ^ Output, of size @m@. @n < m@ must hold-signExtend n = SBV $ svSignExtend i (unSBV n)- where nv = intOfProxy (Proxy @n)- mv = intOfProxy (Proxy @m)- i = fromIntegral (mv - nv)----- | Finite bit-length symbolic values. Essentially the same as 'SIntegral', but further leaves out 'Integer'. Loosely--- based on Haskell's @FiniteBits@ class, but with more methods defined and structured differently to fit into the--- symbolic world view. Minimal complete definition: 'sFiniteBitSize'.-class (Ord a, SymVal a, Num a, Num (SBV a), OrdSymbolic (SBV a), Bits a) => SFiniteBits a where- -- | Bit size.- sFiniteBitSize :: SBV a -> Int- -- | Least significant bit of a word, always stored at index 0.- lsb :: SBV a -> SBool- -- | Most significant bit of a word, always stored at the last position.- msb :: SBV a -> SBool- -- | Big-endian blasting of a word into its bits.- blastBE :: SBV a -> [SBool]- -- | Little-endian blasting of a word into its bits.- blastLE :: SBV a -> [SBool]- -- | Reconstruct from given bits, given in little-endian.- fromBitsBE :: [SBool] -> SBV a- -- | Reconstruct from given bits, given in little-endian.- fromBitsLE :: [SBool] -> SBV a- -- | Replacement for 'testBit', returning 'SBool' instead of 'Bool'.- sTestBit :: SBV a -> Int -> SBool- -- | Variant of 'sTestBit', where we want to extract multiple bit positions.- sExtractBits :: SBV a -> [Int] -> [SBool]- -- | Variant of 'popCount', returning a symbolic value.- sPopCount :: SBV a -> SWord8- -- | A combo of 'setBit' and 'clearBit', when the bit to be set is symbolic.- setBitTo :: SBV a -> Int -> SBool -> SBV a- -- | Variant of 'setBitTo' when the index is symbolic. If the index it out-of-bounds,- -- then the result is underspecified.- sSetBitTo :: Integral a => SBV a -> SBV a -> SBool -> SBV a- -- | Full adder, returns carry-out from the addition. Only for unsigned quantities.- fullAdder :: SBV a -> SBV a -> (SBool, SBV a)- -- | Full multiplier, returns both high and low-order bits. Only for unsigned quantities.- fullMultiplier :: SBV a -> SBV a -> (SBV a, SBV a)- -- | Count leading zeros in a word, big-endian interpretation.- sCountLeadingZeros :: SBV a -> SWord8- -- | Count trailing zeros in a word, big-endian interpretation.- sCountTrailingZeros :: SBV a -> SWord8-- {-# MINIMAL sFiniteBitSize #-}-- -- Default implementations- lsb (SBV v) = SBV (svTestBit v 0)- msb x = sTestBit x (sFiniteBitSize x - 1)-- blastBE = reverse . blastLE- blastLE x = map (sTestBit x) [0 .. intSizeOf x - 1]-- fromBitsBE = fromBitsLE . reverse- fromBitsLE bs- | length bs /= w- = error $ "SBV.SFiniteBits.fromBitsLE/BE: Expected: " ++ show w ++ " bits, received: " ++ show (length bs)- | True- = result- where w = sFiniteBitSize result- result = go 0 0 bs-- go !acc _ [] = acc- go !acc !i (x:xs) = go (ite x (setBit acc i) acc) (i+1) xs-- sTestBit (SBV x) i = SBV (svTestBit x i)- sExtractBits x = map (sTestBit x)-- -- NB. 'sPopCount' returns an 'SWord8', which can overflow when used on quantities that have- -- more than 255 bits. For the regular interface, this suffices for all types we support.- -- For the Dynamic interface, if we ever implement this, this will fail for bit-vectors- -- larger than that many bits. The alternative would be to return SInteger here, but that- -- seems a total overkill for most use cases. If such is required, users are encouraged- -- to define their own variants, which is rather easy.- sPopCount x- | Just v <- unliteral x = go 0 v- | True = sum [ite b 1 0 | b <- blastLE x]- where -- concrete case- go !c 0 = c- go !c w = go (c+1) (w .&. (w-1))-- setBitTo x i b = ite b (setBit x i) (clearBit x i)-- sSetBitTo x idx b- | Just i <- unliteral idx, Just index <- safe i- = setBitTo x index b- | True- = go x [0 .. sFiniteBitSize x - 1]- where -- paranoia check: make sure index can fit in an int- safe i = let asInteger = toInteger i- asInt = fromIntegral asInteger- backInteger = toInteger asInt- in if backInteger == asInteger- then Just asInt- else Nothing-- go v [] = v- go v (i:is) = go (ite (idx .== literal (fromIntegral i)) (setBitTo v (fromIntegral i) b) v) is-- fullAdder a b- | isSigned a = error "fullAdder: only works on unsigned numbers"- | True = (a .> s .|| b .> s, s)- where s = a + b-- -- N.B. The higher-order bits are determined using a simple shift-add multiplier,- -- thus involving bit-blasting. It'd be naive to expect SMT solvers to deal efficiently- -- with properties involving this function, at least with the current state of the art.- fullMultiplier a b- | isSigned a = error "fullMultiplier: only works on unsigned numbers"- | True = (go (sFiniteBitSize a) 0 a, a*b)- where go 0 p _ = p- go n p x = let (c, p') = ite (lsb x) (fullAdder p b) (sFalse, p)- (o, p'') = shiftIn c p'- (_, x') = shiftIn o x- in go (n-1) p'' x'- shiftIn k v = (lsb v, mask .|. (v `shiftR` 1))- where mask = ite k (bit (sFiniteBitSize v - 1)) 0-- -- See the note for 'sPopCount' for a comment on why we return 'SWord8'- sCountLeadingZeros x = fromIntegral m - go m- where m = sFiniteBitSize x - 1-- -- NB. When i is 0 below, which happens when x is 0 as we count all the way down,- -- we return -1, which is equal to 2^n-1, giving us: n-1-(2^n-1) = n-2^n = n, as required, i.e., the bit-size.- go :: Int -> SWord8- go i | i < 0 = i8- | True = ite (sTestBit x i) i8 (go (i-1))- where i8 = literal (fromIntegral i :: Word8)-- -- See the note for 'sPopCount' for a comment on why we return 'SWord8'- sCountTrailingZeros x = go 0- where m = sFiniteBitSize x-- go :: Int -> SWord8- go i | i >= m = i8- | True = ite (sTestBit x i) i8 (go (i+1))- where i8 = literal (fromIntegral i :: Word8)---- 'SFiniteBits' Instances, skips Real/Float/Bool/Integer-instance SFiniteBits Word8 where sFiniteBitSize _ = 8-instance SFiniteBits Word16 where sFiniteBitSize _ = 16-instance SFiniteBits Word32 where sFiniteBitSize _ = 32-instance SFiniteBits Word64 where sFiniteBitSize _ = 64-instance SFiniteBits Int8 where sFiniteBitSize _ = 8-instance SFiniteBits Int16 where sFiniteBitSize _ = 16-instance SFiniteBits Int32 where sFiniteBitSize _ = 32-instance SFiniteBits Int64 where sFiniteBitSize _ = 64-instance (KnownNat n, BVIsNonZero n) => SFiniteBits (WordN n) where sFiniteBitSize _ = intOfProxy (Proxy @n)-instance (KnownNat n, BVIsNonZero n) => SFiniteBits (IntN n) where sFiniteBitSize _ = intOfProxy (Proxy @n)---- | Returns 1 if the boolean is 'sTrue', otherwise 0.-oneIf :: (Ord a, Num (SBV a), SymVal a) => SBool -> SBV a-oneIf t = ite t 1 0---- | Lift a pseudo-boolean op, performing checks-liftPB :: String -> PBOp -> [SBool] -> SBool-liftPB w o xs- | Just e <- check o- = error $ "SBV." ++ w ++ ": " ++ e- | True- = result- where check (PB_AtMost k) = pos k- check (PB_AtLeast k) = pos k- check (PB_Exactly k) = pos k- check (PB_Le cs k) = pos k `mplus` match cs- check (PB_Ge cs k) = pos k `mplus` match cs- check (PB_Eq cs k) = pos k `mplus` match cs-- pos k- | k < 0 = Just $ "comparison value must be positive, received: " ++ show k- | True = Nothing-- match cs- | any (< 0) cs = Just $ "coefficients must be non-negative. Received: " ++ show cs- | lxs /= lcs = Just $ "coefficient length must match number of arguments. Received: " ++ show (lcs, lxs)- | True = Nothing- where lxs = length xs- lcs = length cs-- result = SBV (SVal KBool (Right (cache r)))- r st = do xsv <- mapM (sbvToSV st) xs- -- PseudoBoolean's implicitly require support for integers, so make sure to register that kind!- registerKind st KUnbounded- newExpr st KBool (SBVApp (PseudoBoolean o) xsv)---- | 'sTrue' if at most @k@ of the input arguments are 'sTrue'-pbAtMost :: [SBool] -> Int -> SBool-pbAtMost xs k- | k < 0 = error $ "SBV.pbAtMost: Non-negative value required, received: " ++ show k- | all isConcrete xs = literal $ sum (map (pbToInteger "pbAtMost" 1) xs) <= fromIntegral k- | True = liftPB "pbAtMost" (PB_AtMost k) xs---- | 'sTrue' if at least @k@ of the input arguments are 'sTrue'-pbAtLeast :: [SBool] -> Int -> SBool-pbAtLeast xs k- | k < 0 = error $ "SBV.pbAtLeast: Non-negative value required, received: " ++ show k- | all isConcrete xs = literal $ sum (map (pbToInteger "pbAtLeast" 1) xs) >= fromIntegral k- | True = liftPB "pbAtLeast" (PB_AtLeast k) xs---- | 'sTrue' if exactly @k@ of the input arguments are 'sTrue'-pbExactly :: [SBool] -> Int -> SBool-pbExactly xs k- | k < 0 = error $ "SBV.pbExactly: Non-negative value required, received: " ++ show k- | all isConcrete xs = literal $ sum (map (pbToInteger "pbExactly" 1) xs) == fromIntegral k- | True = liftPB "pbExactly" (PB_Exactly k) xs---- | 'sTrue' if the sum of coefficients for 'sTrue' elements is at most @k@. Generalizes 'pbAtMost'.-pbLe :: [(Int, SBool)] -> Int -> SBool-pbLe xs k- | k < 0 = error $ "SBV.pbLe: Non-negative value required, received: " ++ show k- | all (isConcrete . snd) xs = literal $ sum [pbToInteger "pbLe" c b | (c, b) <- xs] <= fromIntegral k- | True = liftPB "pbLe" (PB_Le (map fst xs) k) (map snd xs)---- | 'sTrue' if the sum of coefficients for 'sTrue' elements is at least @k@. Generalizes 'pbAtLeast'.-pbGe :: [(Int, SBool)] -> Int -> SBool-pbGe xs k- | k < 0 = error $ "SBV.pbGe: Non-negative value required, received: " ++ show k- | all (isConcrete . snd) xs = literal $ sum [pbToInteger "pbGe" c b | (c, b) <- xs] >= fromIntegral k- | True = liftPB "pbGe" (PB_Ge (map fst xs) k) (map snd xs)---- | 'sTrue' if the sum of coefficients for 'sTrue' elements is exactly least @k@. Useful for coding--- /exactly K-of-N/ constraints, and in particular mutex constraints.-pbEq :: [(Int, SBool)] -> Int -> SBool-pbEq xs k- | k < 0 = error $ "SBV.pbEq: Non-negative value required, received: " ++ show k- | all (isConcrete . snd) xs = literal $ sum [pbToInteger "pbEq" c b | (c, b) <- xs] == fromIntegral k- | True = liftPB "pbEq" (PB_Eq (map fst xs) k) (map snd xs)---- | 'sTrue' if there is at most one set bit-pbMutexed :: [SBool] -> SBool-pbMutexed xs = pbAtMost xs 1---- | 'sTrue' if there is exactly one set bit-pbStronglyMutexed :: [SBool] -> SBool-pbStronglyMutexed xs = pbExactly xs 1---- | Convert a concrete pseudo-boolean to given int; converting to integer-pbToInteger :: String -> Int -> SBool -> Integer-pbToInteger w c b- | c < 0 = error $ "SBV." ++ w ++ ": Non-negative coefficient required, received: " ++ show c- | Just v <- unliteral b = if v then fromIntegral c else 0- | True = error $ "SBV.pbToInteger: Received a symbolic boolean: " ++ show (c, b)---- | Predicate for optimizing word operations like (+) and (*).-isConcreteZero :: SBV a -> Bool-isConcreteZero (SBV (SVal _ (Left (CV _ (CInteger n))))) = n == 0-isConcreteZero (SBV (SVal KReal (Left (CV KReal (CAlgReal v))))) = isExactRational v && v == 0-isConcreteZero _ = False---- | Predicate for optimizing word operations like (+) and (*).-isConcreteOne :: SBV a -> Bool-isConcreteOne (SBV (SVal _ (Left (CV _ (CInteger 1))))) = True-isConcreteOne (SBV (SVal KReal (Left (CV KReal (CAlgReal v))))) = isExactRational v && v == 1-isConcreteOne _ = False---- | Symbolic exponentiation using bit blasting and repeated squaring.------ N.B. The exponent must be unsigned/bounded if symbolic. Signed exponents will be rejected.-(.^) :: (Mergeable b, Num b, SIntegral e) => b -> SBV e -> b-b .^ e- | isConcrete e, Just (x :: Integer) <- unliteral (sFromIntegral e)- = if x >= 0 then let go n v- | n == 0 = 1- | even n = go (n `div` 2) (v * v)- | True = v * go (n `div` 2) (v * v)- in go x b- else error $ "(.^): exponentiation: negative exponent: " ++ show x- | not (isBounded e) || isSigned e- = error $ "(.^): exponentiation only works with unsigned bounded symbolic exponents, kind: " ++ show (kindOf e)- | True- = -- NB. We can't simply use sTestBit and blastLE since they have SFiniteBit requirement- -- but we want to have SIntegral here only.- let SBV expt = e- expBit i = SBV (svTestBit expt i)- blasted = map expBit [0 .. intSizeOf e - 1]- in product $ zipWith (\use n -> ite use n 1)- blasted- (iterate (\x -> x*x) b)-infixr 8 .^--instance (Ord a, Num (SBV a), SymVal a, Fractional a) => Fractional (SBV a) where- fromRational = literal . fromRational- SBV x / sy@(SBV y) | div0 = ite (sy .== 0) 0 res- | True = res- where res = SBV (svDivide x y)- -- Identify those kinds where we have a div-0 equals 0 exception- div0 = case kindOf sy of- KVar{} -> error $ "Unexpected Fractional case for: " ++ show (kindOf sy)- KFloat -> False- KDouble -> False- KFP{} -> False- KReal -> True- KRational -> True- -- Following cases should not happen since these types should *not* be instances of Fractional- k@KBounded{} -> error $ "Unexpected Fractional case for: " ++ show k- k@KUnbounded -> error $ "Unexpected Fractional case for: " ++ show k- k@KBool -> error $ "Unexpected Fractional case for: " ++ show k- k@KString -> error $ "Unexpected Fractional case for: " ++ show k- k@KChar -> error $ "Unexpected Fractional case for: " ++ show k- k@KList{} -> error $ "Unexpected Fractional case for: " ++ show k- k@KSet{} -> error $ "Unexpected Fractional case for: " ++ show k- k@KApp{} -> error $ "Unexpected Fractional case for: " ++ show k- k@KADT{} -> error $ "Unexpected Fractional case for: " ++ show k- k@KTuple{} -> error $ "Unexpected Fractional case for: " ++ show k- k@KArray{} -> error $ "Unexpected Fractional case for: " ++ show k---- | Define Floating instance on SBV's; only for base types that are already floating; i.e., 'SFloat', 'SDouble', and 'SReal'.--- (See the separate definition below for 'SFloatingPoint'.) Note that unless you use delta-sat via 'Data.SBV.Provers.dReal' on 'SReal', most--- of the fields are "undefined" for symbolic values. We will add methods as they are supported by SMTLib. Currently, the--- only symbolically available function in this class is 'sqrt' for 'SFloat', 'SDouble' and 'SFloatingPoint'.-instance (Ord a, Num (SBV a), SymVal a, Fractional a, Floating a) => Floating (SBV a) where- pi = fromRational . toRational $ (pi :: Double)- exp = lift1FNS "exp" exp- log = lift1FNS "log" log- sqrt = lift1F FP_Sqrt sqrt- sin = lift1FNS "sin" sin- cos = lift1FNS "cos" cos- tan = lift1FNS "tan" tan- asin = lift1FNS "asin" asin- acos = lift1FNS "acos" acos- atan = lift1FNS "atan" atan- sinh = lift1FNS "sinh" sinh- cosh = lift1FNS "cosh" cosh- tanh = lift1FNS "tanh" tanh- asinh = lift1FNS "asinh" asinh- acosh = lift1FNS "acosh" acosh- atanh = lift1FNS "atanh" atanh- (**) = lift2FNS "**" (**)- logBase = lift2FNS "logBase" logBase--unsupported :: String -> a-unsupported w = error $ "Data.SBV.FloatingPoint: Unsupported operation: " ++ w ++ ". Please request this as a feature!"---- | We give a specific instance for 'SFloatingPoint', because the underlying floating-point type doesn't support--- fromRational directly. The overlap with the above instance is unfortunate.-instance {-# OVERLAPPING #-} ValidFloat eb sb => Floating (SFloatingPoint eb sb) where- -- Try from double; if there's enough precision this'll work, otherwise will bail out.- pi- | ei > 11 || si > 53 = unsupported $ "Floating.SFloatingPoint.pi (not-enough-precision for " ++ show (ei, si) ++ ")"- | True = literal $ FloatingPoint $ fpFromRational ei si (toRational (pi :: Double))- where ei = intOfProxy (Proxy @eb)- si = intOfProxy (Proxy @sb)-- -- Likewise, exponentiation is again limited to precision of double- exp i- | ei > 11 || si > 53 = unsupported $ "Floating.SFloatingPoint.exp (not-enough-precision for " ++ show (ei, si) ++ ")"- | True = literal e ** i- where ei = intOfProxy (Proxy @eb)- si = intOfProxy (Proxy @sb)- e = FloatingPoint $ fpFromRational ei si (toRational (exp 1 :: Double))-- log = lift1FNS "log" log- sqrt = lift1F FP_Sqrt sqrt- sin = lift1FNS "sin" sin- cos = lift1FNS "cos" cos- tan = lift1FNS "tan" tan- asin = lift1FNS "asin" asin- acos = lift1FNS "acos" acos- atan = lift1FNS "atan" atan- sinh = lift1FNS "sinh" sinh- cosh = lift1FNS "cosh" cosh- tanh = lift1FNS "tanh" tanh- asinh = lift1FNS "asinh" asinh- acosh = lift1FNS "acosh" acosh- atanh = lift1FNS "atanh" atanh- (**) = lift2FNS "**" (**)- logBase = lift2FNS "logBase" logBase---- | Lift a 1 arg FP-op, using sRNE default-lift1F :: SymVal a => FPOp -> (a -> a) -> SBV a -> SBV a-lift1F w op a- | Just v <- unliteral a- = literal $ op v- | True- = SBV $ SVal k $ Right $ cache r- where k = kindOf a- r st = do swa <- sbvToSV st a- swm <- sbvToSV st sRNE- newExpr st k (SBVApp (IEEEFP w) [swm, swa])---- | Lift a float/double unary function, only over constants-lift1FNS :: (SymVal a, Floating a) => String -> (a -> a) -> SBV a -> SBV a-lift1FNS nm f sv- | Just v <- unliteral sv = literal $ f v- | True = error $ "SBV." ++ nm ++ ": not supported for symbolic values of type " ++ show (kindOf sv)---- | Lift a float/double binary function, only over constants-lift2FNS :: (SymVal a, Floating a) => String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a-lift2FNS nm f sv1 sv2- | Just v1 <- unliteral sv1- , Just v2 <- unliteral sv2 = literal $ f v1 v2- | True = error $ "SBV." ++ nm ++ ": not supported for symbolic values of type " ++ show (kindOf sv1)---- | SReal Floating instance, used in conjunction with the dReal solver for delta-satisfiability. Note that--- we do not constant fold these values (except for pi), as Haskell doesn't really have any means of computing--- them for arbitrary rationals.-instance {-# OVERLAPPING #-} Floating SReal where- pi = fromRational . toRational $ (pi :: Double) -- Perhaps not good enough?- exp = lift1SReal NR_Exp- log = lift1SReal NR_Log- sqrt = lift1SReal NR_Sqrt- sin = lift1SReal NR_Sin- cos = lift1SReal NR_Cos- tan = lift1SReal NR_Tan- asin = lift1SReal NR_ASin- acos = lift1SReal NR_ACos- atan = lift1SReal NR_ATan- sinh = lift1SReal NR_Sinh- cosh = lift1SReal NR_Cosh- tanh = lift1SReal NR_Tanh- asinh = error "Data.SBV.SReal: asinh is currently not supported. Please request this as a feature!"- acosh = error "Data.SBV.SReal: acosh is currently not supported. Please request this as a feature!"- atanh = error "Data.SBV.SReal: atanh is currently not supported. Please request this as a feature!"- (**) = lift2SReal NR_Pow-- logBase x y = log y / log x---- | Lift an sreal unary function-lift1SReal :: NROp -> SReal -> SReal-lift1SReal w a = SBV $ SVal k $ Right $ cache r- where k = kindOf a- r st = do swa <- sbvToSV st a- newExpr st k (SBVApp (NonLinear w) [swa])---- | Lift an sreal binary function-lift2SReal :: NROp -> SReal -> SReal -> SReal-lift2SReal w a b = SBV $ SVal k $ Right $ cache r- where k = kindOf a- r st = do swa <- sbvToSV st a- swb <- sbvToSV st b- newExpr st k (SBVApp (NonLinear w) [swa, swb])---- Bail out nicely.-noEquals :: String -> String -> (String, String) -> a-noEquals o n (l, r) = error $ unlines [ ""- , "*** Data.SBV: Comparing symbolic values using Haskell's Eq class!"- , "***"- , "*** Received: (" ++ l ++ ") " ++ o ++ " (" ++ r ++ ")"- , "*** Instead use: (" ++ l ++ ") " ++ n ++ " (" ++ r ++ ")"- , "***"- , "*** The Eq instance for symbolic values are necessiated only because"- , "*** of the Bits class requirement. You must use symbolic equality"- , "*** operators instead. (And complain to Haskell folks that they"- , "*** remove the 'Eq' superclass from 'Bits'!.)"- ]---- | This instance is only defined so that we can define an instance for--- 'Data.Bits.Bits'. '==' and '/=' simply throw an error. Use--- 'Data.SBV.EqSymbolic' instead.-instance SymVal a => Eq (SBV a) where- a == b = fromMaybe (noEquals "==" ".==" (show a, show b)) (unliteral (a .== b))- a /= b = fromMaybe (noEquals "/=" "./=" (show a, show b)) (unliteral (a ./= b))---- NB. In the optimizations below, use of -1 is valid as--- -1 has all bits set to True for both signed and unsigned values--- | Using 'popCount' or 'testBit' on non-concrete values will result in an--- error. Use 'sPopCount' or 'sTestBit' instead.-instance (Ord a, Num (SBV a), Num a, Bits a, SymVal a) => Bits (SBV a) where- SBV x .&. SBV y = SBV (svAnd x y)- SBV x .|. SBV y = SBV (svOr x y)- SBV x `xor` SBV y = SBV (svXOr x y)- complement (SBV x) = SBV (svNot x)- bitSize x = intSizeOf x- bitSizeMaybe x = Just $ intSizeOf x- isSigned x = hasSign x- bit i = 1 `shiftL` i- setBit x i = x .|. genLiteral (kindOf x) (bit i :: Integer)- clearBit x i = x .&. genLiteral (kindOf x) (complement (bit i) :: Integer)- complementBit x i = x `xor` genLiteral (kindOf x) (bit i :: Integer)- shiftL (SBV x) i = SBV (svShl x i)- shiftR (SBV x) i = SBV (svShr x i)- rotateL (SBV x) i = SBV (svRol x i)- rotateR (SBV x) i = SBV (svRor x i)- -- NB. testBit is *not* implementable on non-concrete symbolic words- x `testBit` i- | SBV (SVal _ (Left (CV _ (CInteger n)))) <- x- = testBit n i- | True- = error $ "SBV.testBit: Called on symbolic value: " ++ show x ++ ". Use sTestBit instead."- -- NB. popCount is *not* implementable on non-concrete symbolic words- popCount x- | SBV (SVal _ (Left (CV (KBounded _ w) (CInteger n)))) <- x- = popCount (n .&. (bit w - 1))- | True- = error $ "SBV.popCount: Called on symbolic value: " ++ show x ++ ". Use sPopCount instead."---- | Conversion between integral-symbolic values, akin to Haskell's `fromIntegral`-sFromIntegral :: forall a b. (Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b, SymVal b) => SBV a -> SBV b-sFromIntegral x- | kFrom == kTo- = SBV (unSBV x)- | isReal x- = error "SBV.sFromIntegral: Called on a real value" -- can't really happen due to types, but being overcautious- | Just v <- unliteral x- = literal (fromIntegral v)- | True- = result- where result = SBV (SVal kTo (Right (cache y)))- kFrom = kindOf x- kTo = kindOf (Proxy @b)- y st = do xsv <- sbvToSV st x- newExpr st kTo (SBVApp (KindCast kFrom kTo) [xsv])---- | Lift a binary operation thru its dynamic counterpart. Note that--- we still want the actual functions here as differ in their type--- compared to their dynamic counterparts, but the implementations--- are the same.-liftViaSVal :: (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c-liftViaSVal f (SBV a) (SBV b) = SBV $ f a b---- | Generalization of 'shiftL', when the shift-amount is symbolic. Since Haskell's--- 'shiftL' only takes an 'Int' as the shift amount, it cannot be used when we have--- a symbolic amount to shift with.-sShiftLeft :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a-sShiftLeft = liftViaSVal svShiftLeft---- | Generalization of 'shiftR', when the shift-amount is symbolic. Since Haskell's--- 'shiftR' only takes an 'Int' as the shift amount, it cannot be used when we have--- a symbolic amount to shift with.------ NB. If the shiftee is signed, then this is an arithmetic shift; otherwise it's logical,--- following the usual Haskell convention. See 'sSignedShiftArithRight' for a variant--- that explicitly uses the msb as the sign bit, even for unsigned underlying types.-sShiftRight :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a-sShiftRight = liftViaSVal svShiftRight---- | Arithmetic shift-right with a symbolic unsigned shift amount. This is equivalent--- to 'sShiftRight' when the argument is signed. However, if the argument is unsigned,--- then it explicitly treats its msb as a sign-bit, and uses it as the bit that--- gets shifted in. Useful when using the underlying unsigned bit representation to implement--- custom signed operations. Note that there is no direct Haskell analogue of this function.-sSignedShiftArithRight:: (SFiniteBits a, SIntegral b) => SBV a -> SBV b -> SBV a-sSignedShiftArithRight x i- | isSigned i = error "sSignedShiftArithRight: shift amount should be unsigned"- | isSigned x = ssa x i- | True = ite (msb x)- (complement (ssa (complement x) i))- (ssa x i)- where ssa = liftViaSVal svShiftRight---- | Generalization of 'rotateL', when the shift-amount is symbolic. Since Haskell's--- 'rotateL' only takes an 'Int' as the shift amount, it cannot be used when we have--- a symbolic amount to shift with. The first argument should be a bounded quantity.-sRotateLeft :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a-sRotateLeft = liftViaSVal svRotateLeft---- | An implementation of rotate-left, using a barrel shifter like design. Only works when both--- arguments are finite bit-vectors, and furthermore when the second argument is unsigned.--- The first condition is enforced by the type, but the second is dynamically checked.--- We provide this implementation as an alternative to `sRotateLeft` since SMTLib logic--- does not support variable argument rotates (as opposed to shifts), and thus this--- implementation can produce better code for verification compared to `sRotateLeft`.-sBarrelRotateLeft :: (SFiniteBits a, SFiniteBits b) => SBV a -> SBV b -> SBV a-sBarrelRotateLeft = liftViaSVal svBarrelRotateLeft---- | Generalization of 'rotateR', when the shift-amount is symbolic. Since Haskell's--- 'rotateR' only takes an 'Int' as the shift amount, it cannot be used when we have--- a symbolic amount to shift with. The first argument should be a bounded quantity.-sRotateRight :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a-sRotateRight = liftViaSVal svRotateRight---- | An implementation of rotate-right, using a barrel shifter like design. See comments--- for `sBarrelRotateLeft` for details.-sBarrelRotateRight :: (SFiniteBits a, SFiniteBits b) => SBV a -> SBV b -> SBV a-sBarrelRotateRight = liftViaSVal svBarrelRotateRight---- | Capturing non-matching instances for better error messages, conversions from sized-type FromSizedErr (arg :: Type) = 'Text "fromSized: Cannot convert from type: " ':<>: 'ShowType arg- ':$$: 'Text " Source type must be one of SInt N, SWord N, IntN N, WordN N"- ':$$: 'Text " where N is 8, 16, 32, or 64."---- | Capturing non-matching instances for better error messages, conversions to sized-type ToSizedErr (arg :: Type) = 'Text "toSized: Cannot convert from type: " ':<>: 'ShowType arg- ':$$: 'Text " Source type must be one of Int8/16/32/64"- ':$$: 'Text " OR Word8/16/32/64"- ':$$: 'Text " OR their symbolic variants."---- | Capture the correspondence between sized and fixed-sized BVs-type family FromSized (t :: Type) :: Type where- FromSized (WordN 8) = Word8- FromSized (WordN 16) = Word16- FromSized (WordN 32) = Word32- FromSized (WordN 64) = Word64- FromSized (IntN 8) = Int8- FromSized (IntN 16) = Int16- FromSized (IntN 32) = Int32- FromSized (IntN 64) = Int64- FromSized (SWord 8) = SWord8- FromSized (SWord 16) = SWord16- FromSized (SWord 32) = SWord32- FromSized (SWord 64) = SWord64- FromSized (SInt 8) = SInt8- FromSized (SInt 16) = SInt16- FromSized (SInt 32) = SInt32- FromSized (SInt 64) = SInt64---- | Capture the correspondence, in terms of a constraint-type family FromSizedCstr (t :: Type) :: Constraint where- FromSizedCstr (WordN 8) = ()- FromSizedCstr (WordN 16) = ()- FromSizedCstr (WordN 32) = ()- FromSizedCstr (WordN 64) = ()- FromSizedCstr (IntN 8) = ()- FromSizedCstr (IntN 16) = ()- FromSizedCstr (IntN 32) = ()- FromSizedCstr (IntN 64) = ()- FromSizedCstr (SWord 8) = ()- FromSizedCstr (SWord 16) = ()- FromSizedCstr (SWord 32) = ()- FromSizedCstr (SWord 64) = ()- FromSizedCstr (SInt 8) = ()- FromSizedCstr (SInt 16) = ()- FromSizedCstr (SInt 32) = ()- FromSizedCstr (SInt 64) = ()- FromSizedCstr arg = TypeError (FromSizedErr arg)---- | Conversion from a sized BV to a fixed-sized bit-vector.-class FromSizedBV a where- -- | Convert a sized bit-vector to the corresponding fixed-sized bit-vector,- -- for instance 'SWord 16' to 'SWord16'. See also 'toSized'.- fromSized :: a -> FromSized a-- default fromSized :: (Num (FromSized a), Integral a) => a -> FromSized a- fromSized = fromIntegral--instance {-# OVERLAPPING #-} FromSizedBV (WordN 8)-instance {-# OVERLAPPING #-} FromSizedBV (WordN 16)-instance {-# OVERLAPPING #-} FromSizedBV (WordN 32)-instance {-# OVERLAPPING #-} FromSizedBV (WordN 64)-instance {-# OVERLAPPING #-} FromSizedBV (IntN 8)-instance {-# OVERLAPPING #-} FromSizedBV (IntN 16)-instance {-# OVERLAPPING #-} FromSizedBV (IntN 32)-instance {-# OVERLAPPING #-} FromSizedBV (IntN 64)-instance {-# OVERLAPPING #-} FromSizedBV (SWord 8) where fromSized = sFromIntegral-instance {-# OVERLAPPING #-} FromSizedBV (SWord 16) where fromSized = sFromIntegral-instance {-# OVERLAPPING #-} FromSizedBV (SWord 32) where fromSized = sFromIntegral-instance {-# OVERLAPPING #-} FromSizedBV (SWord 64) where fromSized = sFromIntegral-instance {-# OVERLAPPING #-} FromSizedBV (SInt 8) where fromSized = sFromIntegral-instance {-# OVERLAPPING #-} FromSizedBV (SInt 16) where fromSized = sFromIntegral-instance {-# OVERLAPPING #-} FromSizedBV (SInt 32) where fromSized = sFromIntegral-instance {-# OVERLAPPING #-} FromSizedBV (SInt 64) where fromSized = sFromIntegral-instance {-# OVERLAPPABLE #-} FromSizedCstr arg => FromSizedBV arg where fromSized = error "unreachable"---- | Capture the correspondence between fixed-sized and sized BVs-type family ToSized (t :: Type) :: Type where- ToSized Word8 = WordN 8- ToSized Word16 = WordN 16- ToSized Word32 = WordN 32- ToSized Word64 = WordN 64- ToSized Int8 = IntN 8- ToSized Int16 = IntN 16- ToSized Int32 = IntN 32- ToSized Int64 = IntN 64- ToSized SWord8 = SWord 8- ToSized SWord16 = SWord 16- ToSized SWord32 = SWord 32- ToSized SWord64 = SWord 64- ToSized SInt8 = SInt 8- ToSized SInt16 = SInt 16- ToSized SInt32 = SInt 32- ToSized SInt64 = SInt 64---- | Capture the correspondence in terms of a constraint-type family ToSizedCstr (t :: Type) :: Constraint where- ToSizedCstr Word8 = ()- ToSizedCstr Word16 = ()- ToSizedCstr Word32 = ()- ToSizedCstr Word64 = ()- ToSizedCstr Int8 = ()- ToSizedCstr Int16 = ()- ToSizedCstr Int32 = ()- ToSizedCstr Int64 = ()- ToSizedCstr SWord8 = ()- ToSizedCstr SWord16 = ()- ToSizedCstr SWord32 = ()- ToSizedCstr SWord64 = ()- ToSizedCstr SInt8 = ()- ToSizedCstr SInt16 = ()- ToSizedCstr SInt32 = ()- ToSizedCstr SInt64 = ()- ToSizedCstr arg = TypeError (ToSizedErr arg)---- | Conversion from a fixed-sized BV to a sized bit-vector.-class ToSizedBV a where- -- | Convert a fixed-sized bit-vector to the corresponding sized bit-vector,- -- for instance 'SWord16' to 'SWord 16'. See also 'fromSized'.- toSized :: a -> ToSized a-- default toSized :: (Num (ToSized a), Integral a) => (a -> ToSized a)- toSized = fromIntegral--instance {-# OVERLAPPING #-} ToSizedBV Word8-instance {-# OVERLAPPING #-} ToSizedBV Word16-instance {-# OVERLAPPING #-} ToSizedBV Word32-instance {-# OVERLAPPING #-} ToSizedBV Word64-instance {-# OVERLAPPING #-} ToSizedBV Int8-instance {-# OVERLAPPING #-} ToSizedBV Int16-instance {-# OVERLAPPING #-} ToSizedBV Int32-instance {-# OVERLAPPING #-} ToSizedBV Int64-instance {-# OVERLAPPING #-} ToSizedBV SWord8 where toSized = sFromIntegral-instance {-# OVERLAPPING #-} ToSizedBV SWord16 where toSized = sFromIntegral-instance {-# OVERLAPPING #-} ToSizedBV SWord32 where toSized = sFromIntegral-instance {-# OVERLAPPING #-} ToSizedBV SWord64 where toSized = sFromIntegral-instance {-# OVERLAPPING #-} ToSizedBV SInt8 where toSized = sFromIntegral-instance {-# OVERLAPPING #-} ToSizedBV SInt16 where toSized = sFromIntegral-instance {-# OVERLAPPING #-} ToSizedBV SInt32 where toSized = sFromIntegral-instance {-# OVERLAPPING #-} ToSizedBV SInt64 where toSized = sFromIntegral-instance {-# OVERLAPPABLE #-} ToSizedCstr arg => ToSizedBV arg where toSized = error "unreachable"---- | The 'SDivisible' class captures the essence of division.--- Unfortunately we cannot use Haskell's 'Integral' class since the 'Real'--- and 'Enum' superclasses are not implementable for symbolic bit-vectors.--- However, 'quotRem' and 'divMod' both make perfect sense, and the 'SDivisible' class captures--- this operation. One issue is how division by 0 behaves. The verification--- technology requires total functions, and there are several design choices--- here. We follow Isabelle/HOL approach of assigning the value 0 for division--- by 0. Therefore, we impose the following pair of laws:------ @--- x `sQuotRem` 0 = (0, x)--- x `sDivMod` 0 = (0, x)--- @------ Note that our instances implement this law even when @x@ is @0@ itself.------ NB. 'quot' truncates toward zero, while 'div' truncates toward negative infinity.------ === C code generation of division operations------ In the case of division or modulo of a minimal signed value (e.g. @-128@ for--- 'SInt8') by @-1@, SMTLIB and Haskell agree on what the result should be.--- Unfortunately the result in C code depends on CPU architecture and compiler--- settings, as this is undefined behaviour in C. **SBV does not guarantee**--- what will happen in generated C code in this corner case.-class SDivisible a where- sQuotRem :: a -> a -> (a, a)- sDivMod :: a -> a -> (a, a)- sQuot :: a -> a -> a- sRem :: a -> a -> a- sDiv :: a -> a -> a- sMod :: a -> a -> a-- {-# MINIMAL sQuotRem, sDivMod #-}-- x `sQuot` y = fst $ x `sQuotRem` y- x `sRem` y = snd $ x `sQuotRem` y- x `sDiv` y = fst $ x `sDivMod` y- x `sMod` y = snd $ x `sDivMod` y--instance SDivisible Word64 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Int64 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Word32 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Int32 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Word16 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Int16 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Word8 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Int8 where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible Integer where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y--instance SDivisible CV where- sQuotRem a b- | CInteger x <- cvVal a, CInteger y <- cvVal b- = let (r1, r2) = sQuotRem x y in (normCV a{ cvVal = CInteger r1 }, normCV b{ cvVal = CInteger r2 })- sQuotRem a b = error $ "SBV.sQuotRem: impossible, unexpected args received: " ++ show (a, b)- sDivMod a b- | CInteger x <- cvVal a, CInteger y <- cvVal b- = let (r1, r2) = sDivMod x y in (normCV a{ cvVal = CInteger r1 }, normCV b{ cvVal = CInteger r2 })- sDivMod a b = error $ "SBV.sDivMod: impossible, unexpected args received: " ++ show (a, b)--instance SDivisible SWord64 where {sQuotRem = liftQRem; sDivMod = liftDMod}-instance SDivisible SWord32 where {sQuotRem = liftQRem; sDivMod = liftDMod}-instance SDivisible SWord16 where {sQuotRem = liftQRem; sDivMod = liftDMod}-instance SDivisible SWord8 where {sQuotRem = liftQRem; sDivMod = liftDMod}-instance SDivisible SInt64 where {sQuotRem = liftQRem; sDivMod = liftDMod}-instance SDivisible SInt32 where {sQuotRem = liftQRem; sDivMod = liftDMod}-instance SDivisible SInt16 where {sQuotRem = liftQRem; sDivMod = liftDMod}-instance SDivisible SInt8 where {sQuotRem = liftQRem; sDivMod = liftDMod}---- | 'SDivisible' instance for 'WordN'-instance (KnownNat n, BVIsNonZero n) => SDivisible (WordN n) where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y---- | 'SDivisible' instance for 'IntN'-instance (KnownNat n, BVIsNonZero n) => SDivisible (IntN n) where- sQuotRem x 0 = (0, x)- sQuotRem x y = x `quotRem` y- sDivMod x 0 = (0, x)- sDivMod x y = x `divMod` y---- | 'SDivisible' instance for 'SWord'-instance (KnownNat n, BVIsNonZero n) => SDivisible (SWord n) where- sQuotRem = liftQRem- sDivMod = liftDMod---- | 'SDivisible' instance for 'SInt'-instance (KnownNat n, BVIsNonZero n) => SDivisible (SInt n) where- sQuotRem = liftQRem- sDivMod = liftDMod---- | Does the concrete positive number n divide the given integer?-sDivides :: Integer -> SInteger -> SBool-sDivides n v- | n < 0- = error $ "svDivides: First argument must be a strictly positive integer. Received: " ++ show n- | Just x <- unliteral v- = if x `mod` n == 0 then sTrue else sFalse- | True- = SBV $ svDivides n (unSBV v)---- | Lift 'quotRem' to symbolic words. Division by 0 is defined s.t. @x/0 = 0@; which--- holds even when @x@ is @0@ itself.-liftQRem :: (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)-liftQRem x y- | isConcreteZero x- = (x, x)- | isConcreteOne y- = (x, z)-{-------------------------------- - N.B. The seemingly innocuous variant when y == -1 only holds if the type is signed;- - and also is problematic around the minBound.. So, we refrain from that optimization- | isConcreteOnes y- = (-x, z)---------------------------------}- | True- = ite (y .== z) (z, x) (qr x y)- where qr (SBV (SVal sgnsz (Left a))) (SBV (SVal _ (Left b))) = let (q, r) = sQuotRem a b in (SBV (SVal sgnsz (Left q)), SBV (SVal sgnsz (Left r)))- qr a@(SBV (SVal sgnsz _)) b = (SBV (SVal sgnsz (Right (cache (mk Quot)))), SBV (SVal sgnsz (Right (cache (mk Rem)))))- where mk o st = do sw1 <- sbvToSV st a- sw2 <- sbvToSV st b- mkSymOp o st sgnsz sw1 sw2- z = genLiteral (kindOf x) (0::Integer)---- | Lift 'divMod' to symbolic words. Division by 0 is defined s.t. @x/0 = 0@; which--- holds even when @x@ is @0@ itself. Essentially, this is conversion from quotRem--- (truncate to 0) to divMod (truncate towards negative infinity)-liftDMod :: (Ord a, SymVal a, Num a, Num (SBV a), SDivisible (SBV a)) => SBV a -> SBV a -> (SBV a, SBV a)-liftDMod x y- | isConcreteZero x- = (x, x)- | isConcreteOne y- = (x, z)-{-------------------------------- - N.B. The seemingly innocuous variant when y == -1 only holds if the type is signed;- - and also is problematic around the minBound.. So, we refrain from that optimization- | isConcreteOnes y- = (-x, z)---------------------------------}- | True- = ite (y .== z) (z, x) $ ite (signum r .== negate (signum y)) (q-i, r+y) qr- where qr@(q, r) = x `sQuotRem` y- z = genLiteral (kindOf x) (0::Integer)- i = genLiteral (kindOf x) (1::Integer)---- SInteger instance for quotRem/divMod are tricky!--- SMT-Lib only has Euclidean operations, but Haskell--- uses "truncate to 0" for quotRem, and "truncate to negative infinity" for divMod.--- So, we cannot just use the above liftings directly.-instance SDivisible SInteger where- sDivMod x y = ite (y .> 0) (sEDivMod x y) (liftDMod x y)- sQuotRem x y- | not (isSymbolic x || isSymbolic y)- = liftQRem x y- | True- = ite (y .== 0) (0, x) (qE+i, rE-i*y)- where (qE, rE) = liftQRem x y -- for integers, this is euclidean due to SMTLib semantics- i = ite (x .>= 0 .|| rE .== 0) 0- $ ite (y .> 0) 1 (-1)---- | Euclidian division and modulus.-sEDivMod :: SInteger -> SInteger -> (SInteger, SInteger)-sEDivMod a b = (a `sEDiv` b, a `sEMod` b)---- | Euclidian division. Note that unlike regular division, Euclidian division by @0@--- is unconstrained. i.e., it can take any value whatsoever.-sEDiv :: SInteger -> SInteger -> SInteger-sEDiv (SBV a) (SBV b) = SBV $ a `svQuot` b---- | Euclidian modulus. Note that unlike regular modulus, Euclidian division by @0@--- is unconstrained. i.e., it can take any value whatsoever.-sEMod :: SInteger -> SInteger -> SInteger-sEMod (SBV a) (SBV b) = SBV $ a `svRem` b---- Quickcheck interface-instance (SymVal a, Arbitrary a) => Arbitrary (SBV a) where- arbitrary = literal `fmap` arbitrary---- | Symbolic conditionals are modeled by the 'Mergeable' class, describing--- how to merge the results of an if-then-else call with a symbolic test. SBV--- provides all basic types as instances of this class, so users only need--- to declare instances for custom data-types of their programs as needed.------ A 'Mergeable' instance may be automatically derived for a custom data-type--- with a single constructor where the type of each field is an instance of--- 'Mergeable', such as a record of symbolic values. Users only need to add--- 'G.Generic' and 'Mergeable' to the @deriving@ clause for the data-type. See--- 'Documentation.SBV.Examples.Puzzles.U2Bridge.Status' for an example and an--- illustration of what the instance would look like if written by hand.------ The function 'select' is a total-indexing function out of a list of choices--- with a default value, simulating array/list indexing. It's an n-way generalization--- of the 'ite' function.------ Minimal complete definition: None, if the type is instance of @Generic@. Otherwise--- 'symbolicMerge'. Note that most types subject to merging are likely to be--- trivial instances of @Generic@.-class Mergeable a where- -- | Merge two values based on the condition. The first argument states- -- whether we force the then-and-else branches before the merging, at the- -- word level. This is an efficiency concern; one that we'd rather not- -- make but unfortunately necessary for getting symbolic simulation- -- working efficiently.- symbolicMerge :: Bool -> SBool -> a -> a -> a-- -- | Total indexing operation. @select xs default index@ is intuitively- -- the same as @xs !! index@, except it evaluates to @default@ if @index@- -- underflows/overflows.- select :: (Ord b, SymVal b, Num b, Num (SBV b), OrdSymbolic (SBV b)) => [a] -> a -> SBV b -> a-- -- NB. Earlier implementation of select used the binary-search trick- -- on the index to chop down the search space. While that is a good trick- -- in general, it doesn't work for SBV since we do not have any notion of- -- "concrete" subwords: If an index is symbolic, then all its bits are- -- symbolic as well. So, the binary search only pays off only if the indexed- -- list is really humongous, which is not very common in general. (Also,- -- for the case when the list is bit-vectors, we use SMT tables anyhow.)- select xs err ind- | isReal ind = bad "real"- | isFloat ind = bad "float"- | isDouble ind = bad "double"- | hasSign ind = ite (ind .< 0) err (walk xs ind err)- | True = walk xs ind err- where bad w = error $ "SBV.select: unsupported " ++ w ++ " valued select/index expression"- walk [] _ acc = acc- walk (e:es) i acc = walk es (i-1) (ite (i .== 0) e acc)-- -- Default implementation for 'symbolicMerge' if the type is 'Generic'- default symbolicMerge :: (G.Generic a, GMergeable (G.Rep a)) => Bool -> SBool -> a -> a -> a- symbolicMerge = symbolicMergeDefault---- | If-then-else. This is by definition 'symbolicMerge' with both--- branches forced. This is typically the desired behavior, but also--- see 'iteLazy' should you need more laziness.-ite :: Mergeable a => SBool -> a -> a -> a-ite t a b- | Just r <- unliteral t = if r then a else b- | True = symbolicMerge True t a b---- | A Lazy version of ite, which does not force its arguments. This might--- cause issues for symbolic simulation with large thunks around, so use with--- care.-iteLazy :: Mergeable a => SBool -> a -> a -> a-iteLazy t a b- | Just r <- unliteral t = if r then a else b- | True = symbolicMerge False t a b---- | Symbolic assert. Check that the given boolean condition is always 'sTrue' in the given path. The--- optional first argument can be used to provide call-stack info via GHC's location facilities.-sAssert :: HasKind a => Maybe CallStack -> String -> SBool -> SBV a -> SBV a-sAssert cs msg cond x- | Just mustHold <- unliteral cond- = if mustHold- then x- else error $ show $ SafeResult ((locInfo . getCallStack) `fmap` cs, msg, Satisfiable defaultSMTCfg (SMTModel [] Nothing [] []))- | True- = SBV $ SVal k $ Right $ cache r- where k = kindOf x- r st = do xsv <- sbvToSV st x- let pc = getPathCondition st- -- We're checking if there are any cases where the path-condition holds, but not the condition- -- Any violations of this, should be signaled, i.e., whenever the following formula is satisfiable- mustNeverHappen = pc .&& sNot cond- cnd <- sbvToSV st mustNeverHappen- addAssertion st cs msg cnd- return xsv-- locInfo ps = intercalate ",\n " (map loc ps)- where loc (f, sl) = concat [srcLocFile sl, ":", show (srcLocStartLine sl), ":", show (srcLocStartCol sl), ":", f]---- | Merge two symbolic values, at kind @k@, possibly @force@'ing the branches to make--- sure they do not evaluate to the same result. This should only be used for internal purposes;--- as default definitions provided should suffice in many cases. (i.e., End users should--- only need to define 'symbolicMerge' when needed; which should be rare to start with.)-symbolicMergeWithKind :: Kind -> Bool -> SBool -> SBV a -> SBV a -> SBV a-symbolicMergeWithKind k force (SBV t) (SBV a) (SBV b) = SBV (svSymbolicMerge k force t a b)--instance SymVal a => Mergeable (SBV a) where- symbolicMerge force t x y- -- Carefully use the kindOf instance to avoid strictness issues.- | force = symbolicMergeWithKind (kindOf x) True t x y- | True = symbolicMergeWithKind (kindOf (Proxy @a)) False t x y- -- Custom version of select that translates to SMT-Lib tables at the base type of words- select xs err ind- | SBV (SVal _ (Left c)) <- ind = case cvVal c of- CInteger i -> if i < 0 || i >= genericLength xs- then err- else xs `genericIndex` i- _ -> error $ "SBV.select: unsupported " ++ show (kindOf ind) ++ " valued select/index expression"- select xsOrig err ind = xs `seq` SBV (SVal kElt (Right (cache r)))- where kInd = kindOf ind- kElt = kindOf err- -- Based on the index size, we need to limit the elements. For instance if the index is 8 bits, but there- -- are 257 elements, that last element will never be used and we can chop it of..- xs = case kindOf ind of- KBounded False i -> genericTake ((2::Integer) ^ (fromIntegral i :: Integer)) xsOrig- KBounded True i -> genericTake ((2::Integer) ^ (fromIntegral (i-1) :: Integer)) xsOrig- KUnbounded -> xsOrig- _ -> error $ "SBV.select: unsupported " ++ show (kindOf ind) ++ " valued select/index expression"- r st = do sws <- mapM (sbvToSV st) xs- swe <- sbvToSV st err- if all (== swe) sws -- off-chance that all elts are the same. Note that this also correctly covers the case when list is empty.- then return swe- else do idx <- getTableIndex st kInd kElt sws- swi <- sbvToSV st ind- let len = length xs- -- NB. No need to worry here that the index might be < 0; as the SMTLib translation takes care of that automatically- newExpr st kElt (SBVApp (LkUp (idx, kInd, kElt, len) swi swe) [])---- | Construct a useful error message if we hit an unmergeable case.-cannotMerge :: String -> String -> String -> a-cannotMerge typ why hint = error $ unlines [ ""- , "*** Data.SBV.Mergeable: Cannot merge instances of " ++ typ ++ "."- , "*** While trying to do a symbolic if-then-else with incompatible branch results."- , "***"- , "*** " ++ why- , "*** "- , "*** Hint: " ++ hint- ]---- | Merge concrete values that can be checked for equality-concreteMerge :: Show a => String -> String -> (a -> a -> Bool) -> a -> a -> a-concreteMerge t st eq x y- | x `eq` y = x- | True = cannotMerge t- ("Concrete values can only be merged when equal. Got: " ++ show x ++ " vs. " ++ show y)- ("Use an " ++ st ++ " field if the values can differ.")---- Mergeable instances for List/Maybe/Either/Array are useful, but can--- throw exceptions if there is no structural matching of the results--- It's a question whether we should really keep them..---- Lists-instance Mergeable a => Mergeable [a] where- symbolicMerge f t xs ys- | lxs == lys = zipWith (symbolicMerge f t) xs ys- | True = cannotMerge "lists"- ("Branches produce different sizes: " ++ show lxs ++ " vs " ++ show lys ++ ". Must have the same length.")- "Use the 'SList' type (and Data.SBV.List routines) to model fully symbolic lists."- where (lxs, lys) = (length xs, length ys)---- NonEmpty-instance Mergeable a => Mergeable (NonEmpty a) where- symbolicMerge f t xs ys- | lxs == lys = NE.zipWith (symbolicMerge f t) xs ys- | True = cannotMerge "non-empty lists"- ("Branches produce different sizes: " ++ show lxs ++ " vs " ++ show lys ++ ". Must have the same length.")- "Use the 'SList' type (and Data.SBV.List routines) to model fully symbolic lists."- where (lxs, lys) = (length xs, length ys)---- ZipList-instance Mergeable a => Mergeable (ZipList a) where- symbolicMerge force test (ZipList xs) (ZipList ys)- = ZipList (symbolicMerge force test xs ys)---- Maybe-instance Mergeable a => Mergeable (Maybe a) where- symbolicMerge _ _ Nothing Nothing = Nothing- symbolicMerge f t (Just a) (Just b) = Just $ symbolicMerge f t a b- symbolicMerge _ _ a b = cannotMerge "'Maybe' values"- ("Branches produce different constructors: " ++ show (k a, k b))- "Instead of an option type, try using a valid bit to indicate when a result is valid."- where k Nothing = "Nothing"- k _ = "Just"---- Either-instance (Mergeable a, Mergeable b) => Mergeable (Either a b) where- symbolicMerge f t (Left a) (Left b) = Left $ symbolicMerge f t a b- symbolicMerge f t (Right a) (Right b) = Right $ symbolicMerge f t a b- symbolicMerge _ _ a b = cannotMerge "'Either' values"- ("Branches produce different constructors: " ++ show (k a, k b))- "Consider using a product type by a tag instead."- where k (Left _) = "Left"- k (Right _) = "Right"---- Arrays-instance (Ix a, Mergeable b) => Mergeable (Array a b) where- symbolicMerge f t a b- | ba == bb = DA.listArray ba (zipWith (symbolicMerge f t) (elems a) (elems b))- | True = cannotMerge "'Array' values"- ("Branches produce different ranges: " ++ show (k ba, k bb))- "Consider using SBV's native 'SArray' abstraction."- where [ba, bb] = map bounds [a, b]- k = rangeSize---- Functions-instance Mergeable b => Mergeable (a -> b) where- symbolicMerge f t g h x = symbolicMerge f t (g x) (h x)- {- Following definition, while correct, is utterly inefficient. Since the- application is delayed, this hangs on to the inner list and all the- impending merges, even when ind is concrete. Thus, it's much better to- simply use the default definition for the function case.- -}- -- select xs err ind = \x -> select (map ($ x) xs) (err x) ind---- 2-Tuple-instance (Mergeable a, Mergeable b) => Mergeable (a, b) where- symbolicMerge f t (i0, i1) (j0, j1) = ( symbolicMerge f t i0 j0- , symbolicMerge f t i1 j1- )-- select xs (err1, err2) ind = ( select as err1 ind- , select bs err2 ind- )- where (as, bs) = unzip xs---- 3-Tuple-instance (Mergeable a, Mergeable b, Mergeable c) => Mergeable (a, b, c) where- symbolicMerge f t (i0, i1, i2) (j0, j1, j2) = ( symbolicMerge f t i0 j0- , symbolicMerge f t i1 j1- , symbolicMerge f t i2 j2- )-- select xs (err1, err2, err3) ind = ( select as err1 ind- , select bs err2 ind- , select cs err3 ind- )-- where (as, bs, cs) = unzip3 xs---- 4-Tuple-instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d) => Mergeable (a, b, c, d) where- symbolicMerge f t (i0, i1, i2, i3) (j0, j1, j2, j3) = ( symbolicMerge f t i0 j0- , symbolicMerge f t i1 j1- , symbolicMerge f t i2 j2- , symbolicMerge f t i3 j3- )-- select xs (err1, err2, err3, err4) ind = ( select as err1 ind- , select bs err2 ind- , select cs err3 ind- , select ds err4 ind- )- where (as, bs, cs, ds) = unzip4 xs---- 5-Tuple-instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e) => Mergeable (a, b, c, d, e) where- symbolicMerge f t (i0, i1, i2, i3, i4) (j0, j1, j2, j3, j4) = ( symbolicMerge f t i0 j0- , symbolicMerge f t i1 j1- , symbolicMerge f t i2 j2- , symbolicMerge f t i3 j3- , symbolicMerge f t i4 j4- )-- select xs (err1, err2, err3, err4, err5) ind = ( select as err1 ind- , select bs err2 ind- , select cs err3 ind- , select ds err4 ind- , select es err5 ind- )- where (as, bs, cs, ds, es) = unzip5 xs---- 6-Tuple-instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f) => Mergeable (a, b, c, d, e, f) where- symbolicMerge f t (i0, i1, i2, i3, i4, i5) (j0, j1, j2, j3, j4, j5) = ( symbolicMerge f t i0 j0- , symbolicMerge f t i1 j1- , symbolicMerge f t i2 j2- , symbolicMerge f t i3 j3- , symbolicMerge f t i4 j4- , symbolicMerge f t i5 j5- )-- select xs (err1, err2, err3, err4, err5, err6) ind = ( select as err1 ind- , select bs err2 ind- , select cs err3 ind- , select ds err4 ind- , select es err5 ind- , select fs err6 ind- )- where (as, bs, cs, ds, es, fs) = unzip6 xs---- 7-Tuple-instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f, Mergeable g) => Mergeable (a, b, c, d, e, f, g) where- symbolicMerge f t (i0, i1, i2, i3, i4, i5, i6) (j0, j1, j2, j3, j4, j5, j6) = ( symbolicMerge f t i0 j0- , symbolicMerge f t i1 j1- , symbolicMerge f t i2 j2- , symbolicMerge f t i3 j3- , symbolicMerge f t i4 j4- , symbolicMerge f t i5 j5- , symbolicMerge f t i6 j6- )-- select xs (err1, err2, err3, err4, err5, err6, err7) ind = ( select as err1 ind- , select bs err2 ind- , select cs err3 ind- , select ds err4 ind- , select es err5 ind- , select fs err6 ind- , select gs err7 ind- )- where (as, bs, cs, ds, es, fs, gs) = unzip7 xs---- Base types are mergeable so long as they are equal-instance Mergeable () where symbolicMerge _ _ = concreteMerge "()" "()" (==)-instance Mergeable Integer where symbolicMerge _ _ = concreteMerge "Integer" "SInteger" (==)-instance Mergeable Bool where symbolicMerge _ _ = concreteMerge "Bool" "SBool" (==)-instance Mergeable Char where symbolicMerge _ _ = concreteMerge "Char" "SChar" (==)-instance Mergeable Float where symbolicMerge _ _ = concreteMerge "Float" "SFloat" fpIsEqualObjectH-instance Mergeable Double where symbolicMerge _ _ = concreteMerge "Double" "SDouble" fpIsEqualObjectH-instance Mergeable Word8 where symbolicMerge _ _ = concreteMerge "Word8" "SWord8" (==)-instance Mergeable Word16 where symbolicMerge _ _ = concreteMerge "Word16" "SWord16" (==)-instance Mergeable Word32 where symbolicMerge _ _ = concreteMerge "Word32" "SWord32" (==)-instance Mergeable Word64 where symbolicMerge _ _ = concreteMerge "Word64" "SWord64" (==)-instance Mergeable Int8 where symbolicMerge _ _ = concreteMerge "Int8" "SInt8" (==)-instance Mergeable Int16 where symbolicMerge _ _ = concreteMerge "Int16" "SInt16" (==)-instance Mergeable Int32 where symbolicMerge _ _ = concreteMerge "Int32" "SInt32" (==)-instance Mergeable Int64 where symbolicMerge _ _ = concreteMerge "Int64" "SInt64" (==)---- Arbitrary product types, using GHC.Generics------ NB: Because of the way GHC.Generics works, the implementation of--- symbolicMerge' is recursive. The derived instance for @data T a = T a a a a@--- resembles that for (a, (a, (a, a))), not the flat 4-tuple (a, a, a, a). This--- difference should have no effect in practice. Note also that, unlike the--- hand-rolled tuple instances, the generic instance does not provide a custom--- 'select' implementation, and so does not benefit from the SMT-table--- implementation in the 'SBV a' instance.---- | Not exported. Symbolic merge using the generic representation provided by--- 'G.Generics'.-symbolicMergeDefault :: (G.Generic a, GMergeable (G.Rep a)) => Bool -> SBool -> a -> a -> a-symbolicMergeDefault force t x y = G.to $ symbolicMerge' force t (G.from x) (G.from y)---- | Not exported. Used only in 'symbolicMergeDefault'. Instances are provided for--- the generic representations of product types where each element is Mergeable.-class GMergeable f where- symbolicMerge' :: Bool -> SBool -> f a -> f a -> f a--{-- - N.B. A V1 instance like the below would be wrong!- - Why? Because inSBV, we use empty data to mean "uninterpreted" sort; not- - something that has no constructors. Perhaps that was a bad design- - decision. So, do not allow merging of such values!-instance GMergeable V1 where- symbolicMerge' _ _ x _ = x--}--instance GMergeable U1 where- symbolicMerge' _ _ _ _ = U1--instance (Mergeable c) => GMergeable (K1 i c) where- symbolicMerge' force t (K1 x) (K1 y) = K1 $ symbolicMerge force t x y--instance (GMergeable f) => GMergeable (M1 i c f) where- symbolicMerge' force t (M1 x) (M1 y) = M1 $ symbolicMerge' force t x y--instance (GMergeable f, GMergeable g) => GMergeable (f :*: g) where- symbolicMerge' force t (x1 :*: y1) (x2 :*: y2) = symbolicMerge' force t x1 x2 :*: symbolicMerge' force t y1 y2--{- A mergeable instance for sum-types isn't possible. Why? It would something like:--instance (GMergeable f, GMergeable g) => GMergeable (f :+: g) where- symbolicMerge' force t (L1 x) (L1 y) = L1 $ symbolicMerge' force t x y- symbolicMerge' force t (R1 x) (R1 y) = R1 $ symbolicMerge' force t x y- symbolicMerge' force t l r- | Just tv <- unliteral t = if tv then l else r- | True = ????--There's really no good code to put in ????. We have no way to ask the SMT solver to merge composite values that-have different constructors. Calling "error" here would pass the type-checker, but that simply postpones the problem-to run-time. If you need mergeable on sum-types, you better write one yourself, possibly using the SEither type yourself.-As we have it, you'll get a type-error; which can be hard to read, but is preferable.--NB. This isn't a problem with the generic version of symbolic equality; since we can simply return sFalse if we-see different constructors. Such isn't the case when merging.--}---- Bounded instances-instance {-# OVERLAPPABLE #-} (SymVal a, Bounded a) => Bounded (SBV a) where- minBound = literal minBound- maxBound = literal maxBound---- Haskell and SMTLib differ in their default char ranges. In Haskell, maxbound is a lot larger.--- But in SMTLib, we only go upto 0x2FFFF. So, we adopt the SMTLib variant here. This is hardly--- an issue in practice, but the discrepancy is disconcerting.-instance {-# OVERLAPPING #-} Bounded SChar where- minBound = literal (chr 0)- maxBound = literal (chr 0x2FFFF)---- | Choose a value that satisfies the given predicate. This is Hillbert's choice, essentially. Note that--- if the predicate given is not satisfiable (for instance @const sFalse@), then the element returned will be arbitrary.--- The only guarantee is that if there's at least one element that satisfies the predicate, then the returned--- element will be one of those that do. The returned element is not guaranteed to be unique, least, greatest etc, unless--- there happens to be exactly one satisfying element.-some :: forall a. (SymVal a, HasKind a) => String -> (SBV a -> SBool) -> SBV a-some inpName cond = mk f- where mk = SBV . SVal k . Right . cache-- k = kindOf (Proxy @a)--- f st = do ctr <- incrementFreshNameCounter st- let pre = atProxy (Proxy @a) inpName- nm | ctr == 0 = pre- | True = pre ++ "_" ++ show ctr- op <- newUninterpreted st (UIGiven nm) Nothing (SBVType [k]) (UINone False)- chosen <- newExpr st k $ SBVApp op []- let ifExists = quantifiedBool $ \(Exists ex) -> cond ex- internalConstraint st False [] (unSBV (ifExists .=> cond (mk (pure (pure chosen)))))- pure chosen---- | Find the final part of a kind that looks like an array-resKind :: Kind -> Kind-resKind (KArray _ k) = resKind k-resKind k = k---- | SMT definable constants and functions, which can also be uninterpeted.--- This class captures functions that we can generate standalone-code for--- in the SMT solver. Note that we also allow uninterpreted constants and--- functions too. An uninterpreted constant is a value that is indexed by its name. The only--- property the prover assumes -- about these values are that they are equivalent to themselves; i.e., (for--- functions) they return the same results when applied to same arguments.--- We support uninterpreted-functions as a general means of black-box'ing--- operations that are /irrelevant/ for the purposes of the proof; i.e., when--- the proofs can be performed without any knowledge about the function itself.------ Minimal complete definition: 'sbvDefineValue'. However, most instances in--- practice are already provided by SBV, so end-users should not need to define their--- own instances.-class SMTDefinable a where- -- | Generate the code for this value as an SMTLib function, instead of- -- the usual unrolling semantics. This is useful for generating sub-functions- -- in generated SMTLib problem, or handling recursive (and mutually-recursive)- -- definitions that wouldn't terminate in an unrolling symbolic simulation context.- --- -- __IMPORTANT NOTE__ The string argument names this function. Note that SBV will identify- -- this function with that name, i.e., if you use this function twice (or use it recursively),- -- it will simply assume this name uniquely identifies the function being defined. Hence,- -- the user has to assure that this string is unique amongst all the functions you use.- -- Furthermore, if the call to 'smtFunction' happens in the scope of a parameter, you- -- must make sure the string is chosen to keep it unique per parameter value. For instance,- -- if you have:- --- -- @- -- bar :: SInteger -> SInteger -> SInteger- -- bar k = smtFunction "bar" (\x -> x+k) -- Note the capture of k!- -- @- --- -- and you call @bar 2@ and @bar 3@, you *will* get the same SMTLib function. Obviously- -- this is unsound. The reason is that the parameter value isn't captured by the name. In general,- -- you should simply not do this, but if you must, have a concrete argument to make sure you can- -- create a unique name. Something like:- --- -- @- -- bar :: String -> SInteger -> SInteger -> SInteger- -- bar tag k = smtFunction ("bar_" ++ tag) (\x -> x+k) -- Tag should make the name unique!- -- @- --- -- Then, make sure you use @bar "two" 2@ and @bar "three" 3@ etc. to preserve the invariant.- --- -- Furthermore, the function argument must not capture any non-constant variables in the context.- -- You can also define higher-order functions, see 'smtHOFunction' for that purpose.- --- -- Note that this is a design choice, to keep function creation as easy to use as possible. SBV- -- could've made 'smtFunction' a monadic call and generated the name itself to avoid all these issues.- -- But the ergonomics of that is worse, and doesn't fit with the general design philosophy. If you- -- can think of a solution (perhaps using some nifty GHC tricks?) to avoid this issue without making- -- 'smtFunction' return a monadic result, please get in touch!- smtFunction :: (Typeable a, Lambda Symbolic a) => String -> a -> a-- -- | Register a function. This function is typically not needed as SBV will register functions used- -- automatically upon first use. However, there are scenarios (in particular query contexts)- -- where the definition isn't used before query-mode starts, and SBV (for historical reasons)- -- requires functions to be known before query-mode starts executing. In such cases, use this function- -- to register them with the system.- registerFunction :: a -> Symbolic ()-- -- | Uninterpret a value, i.e., add this value as a completely undefined value/function that- -- the solver is free to instantiate to satisfy other constraints.- --- -- __Known issues__- --- -- Usually using an uninterpret function will register itself to the solver, but sometimes the laziness- -- of the evaluation might render this unreliable.- --- -- For example, when working with quantifiers and uninterpreted functions with the following code:- --- -- > runSMTWith z3 $ do- -- > let f = uninterpret "f" :: SInteger -> SInteger- -- > query $ do- -- > constrain $ \(Forall (b :: SInteger)) -> f b .== f b- -- > checkSat- --- -- The solver will complain about the unknown constant @f (Int)@.- --- -- A workaround of this is to explicit register them with 'Data.SBV.Control.registerUISMTFunction':- --- -- > runSMTWith z3 $ do- -- > let f = uninterpret "f" :: SInteger -> SInteger- -- > registerUISMTFunction f- -- > query $ do- -- > constrain $ \(Forall (b :: SInteger)) -> f b .== f b- -- > checkSat- --- -- See https://github.com/LeventErkok/sbv/issues/711 for more info.- uninterpret :: String -> a-- -- | Uninterpret a value, with named arguments in case of functions. SBV will use these- -- names when it shows the values for the arguments. If the given names are more than needed- -- we ignore the excess. If not enough, we add from a stock set of variables.- uninterpretWithArgs :: String -> [String] -> a-- -- | Uninterpret a value, only for the purposes of code-generation. For execution- -- and verification the value is used as is. For code-generation, the alternate- -- definition is used. This is useful when we want to take advantage of native- -- libraries on the target languages.- cgUninterpret :: String -> [String] -> a -> a-- -- | More generalized form of uninterpretation that wraps 'sbvDefineValueFun';- -- this function should not be needed by end-user-code- sbvDefineValue :: UIName -> Maybe [String] -> UIKind a -> a-- -- | The most generalized form of uninterpretation, that generates an- -- uninterpreted function over a sequence of 'SBVs' values; this function is- -- internal-only, and should not be needed by end-user-code- sbvDefineValueFun :: UIName -> Maybe [String] -> SymValInsts as ->- UIKind (SBVs as -> a) -> SBVs as -> a-- -- | A synonym for 'uninterpret'. Allows us to create variables without- -- having to call 'free' explicitly, i.e., without being in the symbolic monad.- sym :: String -> a-- -- | Render an uninterpeted value as an SMTLib definition- sbv2smt :: ExtractIO m => a -> m String-- -- | Render an uninterpeted value function as an SMTLib definition- sbvFun2smt :: (SymVals as, ExtractIO m) => (SBVs as -> a) -> m String-- -- | Make this name a constructor, coming from an ADT. Only used internally- mkADTConstructor :: HasKind a => String -> a- mkADTTester :: HasKind a => String -> a- mkADTAccessor :: HasKind a => String -> a-- {-# MINIMAL sbvDefineValueFun, sbvFun2smt, registerFunction #-}-- -- defaults:- uninterpret nm = sbvDefineValue (UIGiven nm) Nothing $ UIFree True- uninterpretWithArgs nm as = sbvDefineValue (UIGiven nm) (Just as) $ UIFree True- cgUninterpret nm code v = sbvDefineValue (UIGiven nm) Nothing $ UICodeC (v, code)- sym = uninterpret- sbv2smt a = sbvFun2smt (\(_ :: SBVs RNil) -> a)-- sbvDefineValue nm mbArgs k =- sbvDefineValueFun nm mbArgs SymValsNil (fmap const k) SBVsNil-- mkADTConstructor nm = let k = resKind (kindOf v); v = sbvDefineValue (UIADT (ADTConstructor nm k)) Nothing $ UIFree True in v- mkADTTester nm = let k = resKind (kindOf v); v = sbvDefineValue (UIADT (ADTTester nm k)) Nothing $ UIFree True in v- mkADTAccessor nm = let k = resKind (kindOf v); v = sbvDefineValue (UIADT (ADTAccessor nm k)) Nothing $ UIFree True in v-- smtFunction nm v = sbvDefineValue (UIGiven (atProxy (Proxy @a) nm)) Nothing $ UIFun (v, \st fk -> lambda st TopLevel fk v)----- | Kind of uninterpretation-data UIKind a = UIFree Bool -- ^ completely uninterpreted. If Bool is true, then this is curried.- | UIFun (a, State -> Kind -> IO SMTDef) -- ^ has code for SMTLib, with final type of kind (note this is the result- -- , not the arguments), which can be generated by calling the function on the state.- | UICodeC (a, [String]) -- ^ has code for code-generation, i.e., C- deriving Functor---- Get the code associated with the UI, unless we've already did this once. (To support recursive defs.)-retrieveUICode :: UIName -> State -> Kind -> UIKind a -> IO UICodeKind-retrieveUICode _ _ _ (UIFree c) = pure $ UINone c-retrieveUICode (UIADT _) _ _ _ = pure $ UINone True-retrieveUICode (UIGiven nm) st fk (UIFun (_, f)) = do userFuncs <- readIORef (rUserFuncs st)- if nm `Set.member` userFuncs- then pure $ UINone True- else do modifyState st rUserFuncs (Set.insert nm) (pure ())- UISMT <$> f st fk-retrieveUICode _ _ _ (UICodeC (_, c)) = pure $ UICgC c---- Get the constant value associated with the UI-retrieveConstCode :: UIKind a -> Maybe a-retrieveConstCode UIFree{} = Nothing-retrieveConstCode (UIFun (v, _)) = Just v-retrieveConstCode (UICodeC (v, _)) = Just v--instance SymVal a => SMTDefinable (SBV a) where- sbvFun2smt (fn :: SBVs as -> SBV a)- | SymValsNil <- symValInsts :: SymValInsts as- , a <- fn SBVsNil- = do st <- mkNewState defaultSMTCfg (LambdaGen (Just 0))- s <- lambdaStr st TopLevel (kindOf a) a- pure $ intercalate "\n" [ "; Automatically generated by SBV. Do not modify!"- , "; Type: " ++ smtType (kindOf a)- , show s- ]- sbvFun2smt fn = defs2smt (\args -> fn args .== fn args)-- sbvDefineValueFun nm mbArgs insts uiKind args- | Just v <- retrieveConstCode uiKind- , foldlSymSBVs (\r x -> r && isConcrete x) True insts args- = v args- | ka <- kindOf (Proxy @a)- = SBV $ SVal ka $ Right $ cache $ \st ->- do isSMT <- inSMTMode st- case (isSMT, uiKind) of- (True, UICodeC (v, _)) -> sbvToSV st (v args)- _ -> do let ks = symValKinds insts ++ [ka]- ui <- retrieveUICode nm st ka uiKind- op <- newUninterpreted st nm mbArgs (SBVType ks) ui- svs <- rlist2list <$> mapMSBVs (sbvToSV st) args- mapM_ forceSVArg svs- newExpr st ka $ SBVApp op svs-- registerFunction x = constrain $ x .== x---instance (SymVal a, SMTDefinable b) => SMTDefinable (SBV a -> b) where- sbvFun2smt (fn :: SBVs as -> SBV a -> b) =- sbvFun2smt (\((SBVsCons as a) :: SBVs (as :> a)) -> fn as a)-- sbvDefineValueFun nm mbArgs insts uiKind args a =- sbvDefineValueFun nm mbArgs (SymValsCons insts)- (fmap (\f (SBVsCons xs x) -> f xs x) uiKind) (SBVsCons args a)-- registerFunction f = do let k = kindOf (Proxy @a)- st <- symbolicEnv- v <- liftIO $ newInternalVariable st k- let a = SBV $ SVal k $ Right $ cache (const (pure v))- registerFunction $ f a---- Mark the UIKind as uncurried-mkUncurried :: UIKind a -> UIKind a-mkUncurried (UIFree _) = UIFree False-mkUncurried (UIFun a) = UIFun a-mkUncurried (UICodeC a) = UICodeC a---uncurrySBVs2 :: (SBVs as -> (SBV c, SBV b) -> SBV a) ->- (SBVs (as :> c :> b) -> SBV a)-uncurrySBVs2 fn (SBVsCons (SBVsCons as c) b) = fn as (c,b)---- Uncurried functions of two arguments-instance (SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs2-- registerFunction = registerFunction . curry2- sbvDefineValueFun nm mbArgs insts uiKind = uncurry2 <$> sbvDefineValueFun nm mbArgs insts (fmap curry2 <$> mkUncurried uiKind)---- Uncurried functions of three arguments-instance (SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs3- where uncurrySBVs3 :: (SBVs as -> (SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> d :> c :> b) -> SBV a)- uncurrySBVs3 fn (SBVsCons (SBVsCons (SBVsCons as d) c) b) = fn as (d,c,b)- registerFunction = registerFunction . curry3- sbvDefineValueFun nm mbArgs insts uiKind = uncurry3 <$> sbvDefineValueFun nm mbArgs insts (fmap curry3 <$> mkUncurried uiKind)---- Uncurried functions of four arguments-instance (SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs4- where uncurrySBVs4 :: (SBVs as -> (SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> e :> d :> c :> b) -> SBV a)- uncurrySBVs4 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons as e) d) c) b) = fn as (e,d,c,b)- registerFunction = registerFunction . curry4- sbvDefineValueFun nm mbArgs insts uiKind = uncurry4 <$> sbvDefineValueFun nm mbArgs insts (fmap curry4 <$> mkUncurried uiKind)---- Uncurried functions of five arguments-instance (SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs5- where uncurrySBVs5 :: (SBVs as -> (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs5 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as f) e) d) c) b) = fn as (f,e,d,c,b)- registerFunction = registerFunction . curry5- sbvDefineValueFun nm mbArgs insts uiKind = uncurry5 <$> sbvDefineValueFun nm mbArgs insts (fmap curry5 <$> mkUncurried uiKind)---- Uncurried functions of six arguments-instance (SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs6- where uncurrySBVs6 :: (SBVs as -> (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> g :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs6 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as g) f) e) d) c) b) = fn as (g,f,e,d,c,b)-- registerFunction = registerFunction . curry6- sbvDefineValueFun nm mbArgs insts uiKind = uncurry6 <$> sbvDefineValueFun nm mbArgs insts (fmap curry6 <$> mkUncurried uiKind)---- Uncurried functions of seven arguments-instance (SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs7- where uncurrySBVs7 :: (SBVs as -> (SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> h :> g :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs7 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as h) g) f) e) d) c) b) = fn as (h,g,f,e,d,c,b)- registerFunction = registerFunction . curry7- sbvDefineValueFun nm mbArgs insts uiKind = uncurry7 <$> sbvDefineValueFun nm mbArgs insts (fmap curry7 <$> mkUncurried uiKind)---- Uncurried functions of eight arguments-instance (SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs8- where uncurrySBVs8 :: (SBVs as -> (SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs8 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as i) h) g) f) e) d) c) b) = fn as (i,h,g,f,e,d,c,b)- registerFunction = registerFunction . curry8- sbvDefineValueFun nm mbArgs insts uiKind = uncurry8 <$> sbvDefineValueFun nm mbArgs insts (fmap curry8 <$> mkUncurried uiKind)---- Uncurried functions of nine arguments-instance (SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs9- where uncurrySBVs9 :: (SBVs as -> (SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs9 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as j) i) h) g) f) e) d) c) b) = fn as (j,i,h,g,f,e,d,c,b)- registerFunction = registerFunction . curry9- sbvDefineValueFun nm mbArgs insts uiKind = uncurry9 <$> sbvDefineValueFun nm mbArgs insts (fmap curry9 <$> mkUncurried uiKind)---- Uncurried functions of ten arguments-instance (SymVal k, SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs10- where uncurrySBVs10 :: (SBVs as -> (SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> k :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs10 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as k) j) i) h) g) f) e) d) c) b) = fn as (k,j,i,h,g,f,e,d,c,b)- registerFunction = registerFunction . curry10- sbvDefineValueFun nm mbArgs insts uiKind = uncurry10 <$> sbvDefineValueFun nm mbArgs insts (fmap curry10 <$> mkUncurried uiKind)---- Uncurried functions of eleven arguments-instance (SymVal l, SymVal k, SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs11- where uncurrySBVs11 :: (SBVs as -> (SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> l :> k :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs11 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as l) k) j) i) h) g) f) e) d) c) b) = fn as (l,k,j,i,h,g,f,e,d,c,b)- registerFunction = registerFunction . curry11- sbvDefineValueFun nm mbArgs insts uiKind = uncurry11 <$> sbvDefineValueFun nm mbArgs insts (fmap curry11 <$> mkUncurried uiKind)---- Uncurried functions of twelve arguments-instance (SymVal m, SymVal l, SymVal k, SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV m, SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where- sbvFun2smt = sbvFun2smt . uncurrySBVs12- where uncurrySBVs12 :: (SBVs as -> (SBV m, SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> m :> l :> k :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)- uncurrySBVs12 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as m) l) k) j) i) h) g) f) e) d) c) b) = fn as (m,l,k,j,i,h,g,f,e,d,c,b)- registerFunction = registerFunction . curry12- sbvDefineValueFun nm mbArgs insts uiKind = uncurry12 <$> sbvDefineValueFun nm mbArgs insts (fmap curry12 <$> mkUncurried uiKind)---- | Symbolic computations provide a context for writing symbolic programs.-instance MonadIO m => SolverContext (SymbolicT m) where- constrain = imposeConstraint False [] . unSBV . quantifiedBool- softConstrain = imposeConstraint True [] . unSBV . quantifiedBool- namedConstraint nm = imposeConstraint False [(":named", nm)] . unSBV . quantifiedBool- constrainWithAttribute atts = imposeConstraint False atts . unSBV . quantifiedBool-- contextState = symbolicEnv- setOption o = addNewSMTOption o-- internalVariable k = contextState >>= \st -> liftIO $ do- sv <- newInternalVariable st k- pure $ SBV $ SVal k (Right (cache (const (pure sv))))---- | Generalization of 'Data.SBV.assertWithPenalty'-assertWithPenalty :: MonadSymbolic m => String -> SBool -> Penalty -> m ()-assertWithPenalty nm o p = addSValOptGoal $ unSBV `fmap` AssertWithPenalty nm o p---- | Class of metrics we can optimize for. Currently, booleans,--- bounded signed/unsigned bit-vectors, unbounded integers,--- algebraic reals and floats can be optimized. You can add--- your instances, but bewared that the 'MetricSpace' should--- map your type to something the backend solver understands, which--- are limited to unsigned bit-vectors, reals, and unbounded integers--- for z3.------ A good reference on these features is given in the following paper:--- <http://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/nbjorner-scss2014.pdf>.------ Minimal completion: None. However, if @MetricSpace@ is not identical to the type, you want--- to define 'toMetricSpace'/'annotateForMS', and possibly 'minimize'/'maximize' to add extra constraints as necessary.-class Metric a where- -- | The metric space we optimize the goal over. Usually the same as the type itself, but not always!- -- For instance, signed bit-vectors are optimized over their unsigned counterparts, floats are- -- optimized over their 'Word32' comparable counterparts, etc.- type MetricSpace a :: Type- type MetricSpace a = a-- -- | Compute the metric value to optimize.- toMetricSpace :: SBV a -> SBV (MetricSpace a)-- -- | Compute the value itself from the metric corresponding to it.- fromMetricSpace :: SBV (MetricSpace a) -> SBV a-- -- | Annotate for the metric space, to clarify the new name. If this result is not identity,- -- we will add an sObserve on the original.- annotateForMS :: Proxy a -> String -> String-- -- | Minimizing a metric space- msMinimize :: (MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()- msMinimize nm o = do let nm' = annotateForMS (Proxy @a) nm- when (nm' /= nm) $ sObserve nm (unSBV o)- addSValOptGoal $ unSBV `fmap` Minimize nm' (toMetricSpace o)-- -- | Maximizing a metric space- msMaximize :: (MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()- msMaximize nm o = do let nm' = annotateForMS (Proxy @a) nm- when (nm' /= nm) $ sObserve nm (unSBV o)- addSValOptGoal $ unSBV `fmap` Maximize nm' (toMetricSpace o)-- -- if MetricSpace is the same, we can give a default definition- default toMetricSpace :: (a ~ MetricSpace a) => SBV a -> SBV (MetricSpace a)- toMetricSpace = id-- default fromMetricSpace :: (a ~ MetricSpace a) => SBV (MetricSpace a) -> SBV a- fromMetricSpace = id-- -- Annotations to indicate if the metric space transition was needed- default annotateForMS :: (a ~ MetricSpace a) => Proxy a -> String -> String- annotateForMS _ s = s---- Booleans assume True is greater than False-instance Metric Bool where- type MetricSpace Bool = Word8- toMetricSpace t = ite t 1 0- fromMetricSpace w = w ./= 0- annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"---- | Generalization of 'Data.SBV.minimize'-minimize :: (Metric a, MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()-minimize = msMinimize---- | Generalization of 'Data.SBV.maximize'-maximize :: (Metric a, MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()-maximize = msMaximize---- Unsigned types, integers, and reals directly optimize-instance Metric Word8-instance Metric Word16-instance Metric Word32-instance Metric Word64-instance Metric Integer-instance Metric AlgReal---- To optimize signed bounded values, we have to adjust to the range-instance Metric Int8 where- type MetricSpace Int8 = Word8- toMetricSpace x = sFromIntegral x + 128 -- 2^7- fromMetricSpace x = sFromIntegral x - 128- annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"--instance Metric Int16 where- type MetricSpace Int16 = Word16- toMetricSpace x = sFromIntegral x + 32768 -- 2^15- fromMetricSpace x = sFromIntegral x - 32768- annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"--instance Metric Int32 where- type MetricSpace Int32 = Word32- toMetricSpace x = sFromIntegral x + 2147483648 -- 2^31- fromMetricSpace x = sFromIntegral x - 2147483648- annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"--instance Metric Int64 where- type MetricSpace Int64 = Word64- toMetricSpace x = sFromIntegral x + 9223372036854775808 -- 2^63- fromMetricSpace x = sFromIntegral x - 9223372036854775808- annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"---- | Optimizing 'WordN'-instance (KnownNat n, BVIsNonZero n) => Metric (WordN n)---- | Optimizing 'IntN'-instance (KnownNat n, BVIsNonZero n) => Metric (IntN n) where- type MetricSpace (IntN n) = WordN n- toMetricSpace x = sFromIntegral x + 2 ^ (intOfProxy (Proxy @n) - 1)- fromMetricSpace x = sFromIntegral x - 2 ^ (intOfProxy (Proxy @n) - 1)- annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"---- Quickcheck interface on symbolic-booleans..-instance Testable SBool where- property (SBV (SVal _ (Left b))) = property (cvToBool b)- property s = cantQuickCheck $ "Result did not evaluate to a concrete boolean: " ++ show s--instance Testable (Symbolic SBool) where- property prop = QC.monadicIO $ do (cond, r, modelVals) <- QC.run test- QC.pre cond- unless (r || null modelVals) $ QC.monitor (QC.counterexample (complain modelVals))- QC.assert r- where test = do (r, Result{resTraces=tvals, resObservables=ovals, resConsts=(_, cs), resConstraints=cstrs, resUIConsts=unints}) <- - C.catch (runSymbolic defaultSMTCfg (Concrete Nothing) prop)- (\(e :: C.SomeException) -> cantQuickCheck (show e))--- let cval = fromMaybe (cantQuickCheck "A constraint did not evaluate to a concrete boolean") . (`lookup` cs)- cond = -- Only pick-up "hard" constraints, as indicated by False in the fist component- and [cvToBool (cval v) | (False, _, v) <- F.toList cstrs]-- getObservable (nm, f, v) = case v `lookup` cs of- Just cv -> if f cv then Just (nm, cv) else Nothing- Nothing -> cantQuickCheck "An observable did not evaluate to a concrete value"-- case map fst unints of- [] -> case unliteral r of- Nothing -> cantQuickCheck "The result did not evaluate to a concrete value"- Just b -> return (cond, b, tvals ++ mapMaybe getObservable ovals)- uis -> cantQuickCheck $ "Uninterpreted constants remain: " ++ unwords uis-- complain qcInfo = showModel defaultSMTCfg (SMTModel [] Nothing qcInfo [])---- Complain if what we got isn't something we can quick-check-cantQuickCheck :: String -> a-cantQuickCheck why = error $ unlines [ "*** Data.SBV: Cannot quickcheck the given property."- , "***"- , "*** Certain SBV properties cannot be quick-checked. In particular,"- , "*** SBV can't quick-check in the presence of:"- , "***"- , "*** - Uninterpreted constants."- , "*** - Uninterpreted types."- , "*** - Floating point operations with rounding modes other than RNE."- , "*** - Floating point FMA operation, regardless of rounding mode."- , "*** - Quantified booleans, i.e., uses of Forall/Exists/ExistsUnique."- , "*** - Uses of quantifiedBool"- , "*** - Calls to 'observe' (use 'sObserve' instead)"- , "***"- , "*** If you can't avoid the above features or run into an issue with"- , "*** quickcheck even though you haven't used these features, please report this as a bug!"- , "***"- , "*** Origin:"- , "***"- , why- ]---- | Quick check an SBV property. Note that a regular @quickCheck@ call will work just as--- well. Use this variant if you want to receive the boolean result.-sbvQuickCheck :: Symbolic SBool -> IO Bool-sbvQuickCheck prop = QC.isSuccess `fmap` QC.quickCheckResult prop---- Quickcheck interface on dynamically-typed values. A run-time check--- ensures that the value has boolean type.-instance Testable (Symbolic SVal) where- property m = property $ do s <- m- when (kindOf s /= KBool) $ error "Cannot quickcheck non-boolean value"- return (SBV s :: SBool)---- | Explicit sharing combinator. The SBV library has internal caching/hash-consing mechanisms--- built in, based on Andy Gill's type-safe observable sharing technique (see: <http://ku-fpg.github.io/files/Gill-09-TypeSafeReification.pdf>).--- However, there might be times where being explicit on the sharing can help, especially in experimental code. The 'slet' combinator--- ensures that its first argument is computed once and passed on to its continuation, explicitly indicating the intent of sharing. Most--- use cases of the SBV library should simply use Haskell's @let@ construct for this purpose.-slet :: forall a b. (HasKind a, HasKind b) => SBV a -> (SBV a -> SBV b) -> SBV b-slet x f = SBV $ SVal k $ Right $ cache r- where k = kindOf (Proxy @b)- r st = do xsv <- sbvToSV st x- let xsbv = SBV $ SVal (kindOf x) (Right (cache (const (return xsv))))- res = f xsbv- sbvToSV st res---- | Class of things that we can logically reduce to a boolean, by saturating and then asserting equivalance to itself-class QSaturate m a where- qSaturate :: a -> m ()---- | Base case; simple variable in the symbolic monad-instance SolverContext m => QSaturate m SBool where- qSaturate b = constrain $ b .== b---- | Saturate over a universal quantifier-instance (HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (Forall nm a -> r) where- qSaturate f = qSaturate . f . Forall =<< internalVariable (kindOf (Proxy @a))---- | Saturate over a pair of universal quantifiers-instance (HasKind a, HasKind b, Monad m, SolverContext m, QSaturate m r) => QSaturate m ((Forall na a, Forall nb b) -> r) where- qSaturate = qSaturate . curry---- | Saturate over a pair of existential quantifiers-instance (HasKind a, HasKind b, Monad m, SolverContext m, QSaturate m r) => QSaturate m ((Exists na a, Exists nb b) -> r) where- qSaturate = qSaturate . curry---- | Saturate over a number of universal quantifiers-instance (KnownNat n, HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (ForallN n nm a -> r) where- qSaturate f = qSaturate . f . ForallN =<< replicateM (intOfProxy (Proxy @n)) (internalVariable (kindOf (Proxy @a)))---- | Saturate over an existential quantifier-instance (HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (Exists nm a -> r) where- qSaturate f = qSaturate . f . Exists =<< internalVariable (kindOf (Proxy @a))---- | Saturate over an a number of existential quantifiers-instance (KnownNat n, HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (ExistsN n nm a -> r) where- qSaturate f = qSaturate . f . ExistsN =<< replicateM (intOfProxy (Proxy @n)) (internalVariable (kindOf (Proxy @a)))---- | Saturate over a unique-exists variable-instance (HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (ExistsUnique nm a -> r) where- qSaturate f = qSaturate . f . ExistsUnique =<< internalVariable (kindOf (Proxy @a))---- | Saturate a predicate, but save/restore observables so they're not messed up.-qSaturateSavingObservables :: (Monad m, MonadIO m, SolverContext m, QSaturate m a) => a -> m ()-qSaturateSavingObservables p = do State{rObservables} <- contextState- curObservables <- liftIO $ readIORef rObservables- qSaturate p- liftIO $ writeIORef rObservables curObservables---- | Equality as a proof method. Allows for--- very concise construction of equivalence proofs, which is very typical in--- bit-precise proofs.-infix 4 ===-class Equality a where- (===) :: a -> a -> IO ThmResult--instance {-# OVERLAPPABLE #-} (SymVal a, EqSymbolic z) => Equality (SBV a -> z) where- k === l = prove $ \a -> k a .== l a--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, EqSymbolic z) => Equality (SBV a -> SBV b -> z) where- k === l = prove $ \a b -> k a b .== l a b--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, EqSymbolic z) => Equality ((SBV a, SBV b) -> z) where- k === l = prove $ \a b -> k (a, b) .== l (a, b)--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> z) where- k === l = prove $ \a b c -> k a b c .== l a b c--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c) -> z) where- k === l = prove $ \a b c -> k (a, b, c) .== l (a, b, c)--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> z) where- k === l = prove $ \a b c d -> k a b c d .== l a b c d--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d) -> z) where- k === l = prove $ \a b c d -> k (a, b, c, d) .== l (a, b, c, d)--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z) where- k === l = prove $ \a b c d e -> k a b c d e .== l a b c d e--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e) -> z) where- k === l = prove $ \a b c d e -> k (a, b, c, d, e) .== l (a, b, c, d, e)--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z) where- k === l = prove $ \a b c d e f -> k a b c d e f .== l a b c d e f--instance {-# OVERLAPPABLE #-}- (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z) where- k === l = prove $ \a b c d e f -> k (a, b, c, d, e, f) .== l (a, b, c, d, e, f)--instance {-# OVERLAPPABLE #-}- (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z) where- k === l = prove $ \a b c d e f g -> k a b c d e f g .== l a b c d e f g--instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z) where- k === l = prove $ \a b c d e f g -> k (a, b, c, d, e, f, g) .== l (a, b, c, d, e, f, g)---- | Reading a value from an array.-readArray :: forall key val. (SymVal key, SymVal val, HasKind val) => SArray key val -> SBV key -> SBV val-readArray array key- | eqCheckIsObjectEq ka, Just (ArrayModel tbl def) <- unliteral array, Just _ <- unliteral key, Just r <- locate (unSBV key) def tbl- = r- | True- = symRes- where symRes = SBV . SVal kb . Right $ cache g- ka = kindOf (Proxy @key)- kb = kindOf (Proxy @val)- g st = do f <- sbvToSV st array- k <- sbvToSV st key- newExpr st kb (SBVApp ReadArray [f, k])-- -- return the first value, since we don't bother deleting previous writes. Note that this might- -- fail if we don't have equality; but that's OK; in that case we'll go symbolic.- locate skey def vals = go vals- where go [] = Just $ literal def- go ((k, v) : rest) = case unliteral (SBV (svStrongEqual skey (unSBV (literal k)))) of- Nothing -> Nothing- Just True -> Just $ literal v- Just False -> go rest---- | Writing a value to an array. For the concrete case, we don't bother deleting earlier entries, we keep a history. The earlier a value is in the list, the "later" it happened; in a stack fashion.-writeArray :: forall key val. (HasKind key, SymVal key, SymVal val, HasKind val) => SArray key val -> SBV key -> SBV val -> SArray key val-writeArray array key value- | Just (ArrayModel tbl def) <- unliteral array, Just keyVal <- unliteral key, Just val <- unliteral value- = literal $ ArrayModel ((keyVal, val) : tbl) def -- It's important that we "cons" the value here, since it takes precedence in a read- | True- = SBV . SVal k . Right $ cache g- where k = KArray (kindOf (Proxy @key)) (kindOf (Proxy @val))-- g st = do arr <- sbvToSV st array- keyVal <- sbvToSV st key- val <- sbvToSV st value- newExpr st k (SBVApp WriteArray [arr, keyVal, val])---- | Create a constant array. This is a special case of 'lambdaArray', but it creates a--- simpler expression in the case of constants.-constArray :: forall key val. (SymVal key, SymVal val) => SBV val -> SArray key val-constArray v- | Just v' <- unliteral v- = literal $ ArrayModel [] v'- | True- = SBV . SVal k . Right $ cache g- where ka = kindOf (Proxy @key)- kb = kindOf (Proxy @val)- k = KArray ka kb-- g st = do sv <- sbvToSV st v- newExpr st k (SBVApp (ArrayInit (Left (ka, kb))) [sv])---- | Create a completely free array, with no constraints on it, as an expression.--- Note that you can create an array in the symbolic context with the regular 'free'--- calls. (Or 'sArray' if you prefer.) This variant creates it as an expression, i.e.,--- without having to be in the monadic context. We take a name identifier here as an--- argument which uniquely identifies this array. Note that this is necessary, as otherwise--- there would be no way to distinguish two different calls in the pure context. If you--- use the same name, then you'll get the same array, much like uninterpreted functions.-freeArray :: forall key val. (SymVal key, SymVal val) => String -> SArray key val-freeArray = lambdaArray . uninterpret---- | Using a lambda as an array. We can turn a function into an array, relating indexes--- to their values. (That is, passing @f@ would create an array where entry @i@--- is initialized to value @f i@.) For the special case of initializing with a constant--- value, either pass @const val@, or use 'constArray'.-lambdaArray :: forall a b. (SymVal a, HasKind b) => (SBV a -> SBV b) -> SArray a b-lambdaArray f = SBV . SVal k . Right $ cache g- where k = KArray (kindOf (Proxy @a)) (kindOf (Proxy @b))-- g st = do def <- lambdaStr st TopLevel (kindOf (Proxy @b)) f- newExpr st k (SBVApp (ArrayInit (Right def)) [])---- | Turn a constant association-list and a default into a symbolic array.-listArray :: (SymVal a, SymVal b) => [(a, b)] -> b -> SArray a b-listArray ascs def = literal $ ArrayModel ascs def---- | Create a closure, wrapping the free variables together with the function. When using higher-order functions--- in SBV (like map), the function passed must be closed, i.e., not have any free variables. If you need to call--- such a function with a function capturing a free variable, you should create a closure instead.-data Closure env a = Closure { closureEnv :: env- , closureFun :: env -> a- }---- | Define a higher-order function. Similar to 'smtFunction', but when we have a higher-order argument. Note that--- the higher-order argument cannot have free variables. Also, if the function is recursive, you should call--- the first argument of the defining function, which SBV uses to tie the recursive knot. (Note that recursive--- functions defined via 'smtFunction' don't have this latter requirement as they can figure out the recursion--- automatically. Higher-order functions, unfortunately, can't do this: They firstify their high-order argument,--- giving the whole function a unique name; captured via the call to the recursive definition.)-smtHOFunction :: forall a b f.- ( SMTDefinable (a -> SBV b)- , Lambda Symbolic f- , Lambda Symbolic (a -> SBV b)- , HasKind b- , HasKind f- , Typeable a- , Typeable b- , Typeable f- ) => String -- prefix to use- -> f -- The higher-order argument. We're very generic here!- -> (a -> SBV b) -- The ho-function we're modeling- -> a -> SBV b -- The resulting function, that can be used as is, and will be rendered in SMTLib without unfolding-smtHOFunction nm f hof arg = SBV $ SVal (kindOf (Proxy @(SBV b))) $ Right $ cache r- where r st = do SMTLambda lam <- lambdaStr st HigherOrderArg (resKindOf (kindOf (Proxy @f))) f- let uniqLen = firstifyUniqueLen $ stCfg st- uniq = take uniqLen (BC.unpack (B.encode (hash (BC.pack (unwords (words lam))))))- sbvToSV st (smtFunction (atProxy (Proxy @f) nm <> "_" <> uniq) hof arg)-- -- we get the functions as arrays here, so chase to find the result- resKindOf (KArray _ k) = resKindOf k- resKindOf k = k--{- HLint ignore module "Reduce duplication" -}-{- HLint ignore module "Eta reduce" -}-{- HLint ignore module "Avoid NonEmpty.unzip" -}-{- HLint ignore module "Redundant id" -}+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE NamedFieldPuns #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE UndecidableInstances #-}++{-# OPTIONS_GHC -Wall -Werror -fno-warn-orphans -Wno-incomplete-uni-patterns #-}++module Data.SBV.Core.Model (+ Mergeable(..), Equality(..), EqSymbolic(..), OrdSymbolic(..)+ , Zero(..), MeasureOf, Measure(..), MeasureHelper(..)+ , ContractOf, smtFunction, smtFunctionWithMeasure, smtFunctionWithContract, smtProductiveFunction, smtFunctionNoTermination+ , checkMutualGroup+ , SDivisible(..), SMTDefinable(..), QSaturate, qSaturateSavingObservables+ , Metric(..), minimize, maximize, assertWithPenalty, SIntegral, SFiniteBits(..)+ , ite, iteLazy, sFromIntegral, sShiftLeft, sShiftRight, sRotateLeft, sBarrelRotateLeft, sRotateRight, sBarrelRotateRight, sSignedShiftArithRight, (.^)+ , some+ , oneIf, genVar, genVar_+ , pbAtMost, pbAtLeast, pbExactly, pbLe, pbGe, pbEq, pbMutexed, pbStronglyMutexed+ , sBool, sBool_, sBools, sWord8, sWord8_, sWord8s, sWord16, sWord16_, sWord16s, sWord32, sWord32_, sWord32s+ , sWord64, sWord64_, sWord64s, sInt8, sInt8_, sInt8s, sInt16, sInt16_, sInt16s, sInt32, sInt32_, sInt32s, sInt64, sInt64_+ , sInt64s, sInteger, sInteger_, sIntegers, sReal, sReal_, sReals, sFloat, sFloat_, sFloats, sDouble, sDouble_, sDoubles+ , sWord, sWord_, sWords, sInt, sInt_, sInts+ , sFPHalf, sFPHalf_, sFPHalfs, sFPBFloat, sFPBFloat_, sFPBFloats, sFPSingle, sFPSingle_, sFPSingles, sFPDouble, sFPDouble_, sFPDoubles, sFPQuad, sFPQuad_, sFPQuads, sArray, sArray_, sArrays+ , sFloatingPoint, sFloatingPoint_, sFloatingPoints+ , sRoundNearestTiesToEven, sRoundNearestTiesToAway, sRoundTowardPositive, sRoundTowardNegative, sRoundTowardZero+ , sRNE, sRNA, sRTP, sRTN, sRTZ+ , sChar, sChar_, sChars, sString, sString_, sStrings, sList, sList_, sLists+ , sRational, sRational_, sRationals+ , SymTuple, sTuple, sTuple_, sTuples+ , sSet, sSet_, sSets+ , sEDivMod, sEDiv, sEMod+ , sDivides+ , solve+ , slet+ , sRealToSInteger, sRealToSIntegerTruncate, label, observe, observeIf, sObserve+ , sAssert+ , liftQRem, liftDMod, symbolicMergeWithKind+ , genLiteral, genFromCV, genMkSymVar+ , zeroExtend, signExtend+ , sbvQuickCheck+ , readArray, writeArray, constArray, freeArray, lambdaArray, listArray+ , FromSized, ToSized, FromSizedBV(..), ToSizedBV(..)+ , smtHOFunction, smtHOFunctionWithMeasure, Closure(..)+ )+ where++import Control.Applicative (ZipList(ZipList))+import Control.Monad (when, unless, mplus, replicateM, forM_)+import Control.Monad.IO.Class (MonadIO, liftIO)++import qualified Control.Exception as C++import GHC.Generics (M1(..), U1(..), (:*:)(..), K1(..))+import qualified GHC.Generics as G++import GHC.Stack+import GHC.TypeLits+#if MIN_VERSION_base(4,18,0)+ hiding(SChar)+#endif++import Data.Array (Array, Ix, elems, bounds, rangeSize)+import qualified Data.Array as DA (listArray)++import Data.Bifunctor (first)++import Data.Bits (Bits(..))+import Data.Int (Int8, Int16, Int32, Int64)+import Data.Kind (Type, Constraint)+import Data.List (genericLength, genericIndex, genericTake, unzip4, unzip5, unzip6, unzip7+ , intercalate, dropWhileEnd, isPrefixOf, partition, nubBy+#if !MIN_VERSION_base(4,20,0)+ , foldl'+#endif+ )+import Data.Maybe (fromMaybe, mapMaybe, isJust)+import Data.String (IsString(..))+import Data.Word (Word8, Word16, Word32, Word64)++import Data.List.NonEmpty (NonEmpty(..))+import qualified Data.List.NonEmpty as NE++import qualified Data.Set as Set+import qualified Data.Graph as DG++import Data.Proxy+import Data.Dynamic (fromDynamic, toDyn, Typeable)++import Test.QuickCheck (Testable(..), Arbitrary(..))+import qualified Test.QuickCheck.Test as QC (isSuccess)+import qualified Test.QuickCheck as QC (quickCheckResult, counterexample)+import qualified Test.QuickCheck.Monadic as QC (monadicIO, run, assert, pre, monitor)++import qualified Data.Foldable as F (toList)+import qualified Data.Map.Strict as Map+import qualified Data.Sequence as Seq++import Data.SBV.Core.AlgReals+import Data.SBV.Core.Sized+import Data.SBV.Core.SizedFloats+import Data.SBV.Core.Data hiding (Constraint)+import Data.SBV.Core.Symbolic+import Data.SBV.Core.Operations+import Data.SBV.Core.Kind+import Data.SBV.Lambda+import Data.SBV.Utils.ExtractIO (ExtractIO)++import Data.SBV.Provers.Prover (defaultSMTCfg, SafeResult(..), defs2smt, prove, proveWith)+import Data.SBV.SMT.SMT (ThmResult(..), showModel)+import Data.SBV.SMT.Utils (debug)++import Data.SBV.Utils.Numeric (fpIsEqualObjectH)++import Data.IORef (readIORef, writeIORef, modifyIORef')+import System.Mem.StableName (makeStableName, hashStableName)+import Data.SBV.Utils.Lib++import Data.Char++import System.FilePath (dropExtension, takeExtension)++-- Symbolic-Word class instances++import Crypto.Hash.SHA512 (hash)+import qualified Data.ByteString.Base16 as B+import qualified Data.ByteString.Char8 as BC++-- | Generate a variable, named+genVar :: MonadSymbolic m => VarContext -> Kind -> String -> m (SBV a)+genVar q k = mkSymSBV q k . Just++-- | Generate an unnamed variable+genVar_ :: MonadSymbolic m => VarContext -> Kind -> m (SBV a)+genVar_ q k = mkSymSBV q k Nothing++-- | Generate a finite constant bitvector+genLiteral :: Integral a => Kind -> a -> SBV b+genLiteral k = SBV . SVal k . Left . mkConstCV k++-- | Convert a constant to an integral value+genFromCV :: Integral a => CV -> a+genFromCV (CV _ (CInteger x)) = fromInteger x+genFromCV c = error $ "genFromCV: Unsupported non-integral value: " ++ show c++-- | Generalization of 'Data.SBV.genMkSymVar'+genMkSymVar :: MonadSymbolic m => Kind -> VarContext -> Maybe String -> m (SBV a)+genMkSymVar k mbq Nothing = genVar_ mbq k+genMkSymVar k mbq (Just s) = genVar mbq k s++instance SymVal Bool where+ mkSymVal = genMkSymVar KBool+ literal = SBV . svBool+ fromCV = cvToBool++instance SymVal Word8 where+ mkSymVal = genMkSymVar (KBounded False 8)+ literal = genLiteral (KBounded False 8)+ fromCV = genFromCV++instance SymVal Int8 where+ mkSymVal = genMkSymVar (KBounded True 8)+ literal = genLiteral (KBounded True 8)+ fromCV = genFromCV++instance SymVal Word16 where+ mkSymVal = genMkSymVar (KBounded False 16)+ literal = genLiteral (KBounded False 16)+ fromCV = genFromCV++instance SymVal Int16 where+ mkSymVal = genMkSymVar (KBounded True 16)+ literal = genLiteral (KBounded True 16)+ fromCV = genFromCV++instance SymVal Word32 where+ mkSymVal = genMkSymVar (KBounded False 32)+ literal = genLiteral (KBounded False 32)+ fromCV = genFromCV++instance SymVal Int32 where+ mkSymVal = genMkSymVar (KBounded True 32)+ literal = genLiteral (KBounded True 32)+ fromCV = genFromCV++instance SymVal Word64 where+ mkSymVal = genMkSymVar (KBounded False 64)+ literal = genLiteral (KBounded False 64)+ fromCV = genFromCV++instance SymVal Int64 where+ mkSymVal = genMkSymVar (KBounded True 64)+ literal = genLiteral (KBounded True 64)+ fromCV = genFromCV++instance SymVal Integer where+ mkSymVal = genMkSymVar KUnbounded+ literal = SBV . SVal KUnbounded . Left . mkConstCV KUnbounded+ fromCV = genFromCV+ minMaxBound = Nothing++instance SymVal Rational where+ mkSymVal = genMkSymVar KRational+ literal = SBV . SVal KRational . Left . CV KRational . CRational+ fromCV (CV _ (CRational r)) = r+ fromCV c = error $ "SymVal.Rational: Unexpected non-rational value: " ++ show c+ minMaxBound = Nothing++instance SymVal AlgReal where+ mkSymVal = genMkSymVar KReal+ literal = SBV . SVal KReal . Left . CV KReal . CAlgReal+ fromCV (CV _ (CAlgReal a)) = a+ fromCV c = error $ "SymVal.AlgReal: Unexpected non-real value: " ++ show c+ minMaxBound = Nothing++ -- AlgReal needs its own definition of isConcretely+ -- to make sure we avoid using unimplementable Haskell functions+ isConcretely (SBV (SVal KReal (Left (CV KReal (CAlgReal v))))) p+ | isExactRational v = p v+ isConcretely _ _ = False++instance SymVal Float where+ mkSymVal = genMkSymVar KFloat+ literal = SBV . SVal KFloat . Left . CV KFloat . CFloat+ fromCV (CV _ (CFloat a)) = a+ fromCV c = error $ "SymVal.Float: Unexpected non-float value: " ++ show c+ minMaxBound = Nothing++ -- For Float, we conservatively return 'False' for isConcretely. The reason is that+ -- this function is used for optimizations when only one of the argument is concrete,+ -- and in the presence of NaN's it would be incorrect to do any optimization+ isConcretely _ _ = False++instance SymVal Double where+ mkSymVal = genMkSymVar KDouble+ literal = SBV . SVal KDouble . Left . CV KDouble . CDouble+ fromCV (CV _ (CDouble a)) = a+ fromCV c = error $ "SymVal.Double: Unexpected non-double value: " ++ show c+ minMaxBound = Nothing++ -- For Double, we conservatively return 'False' for isConcretely. The reason is that+ -- this function is used for optimizations when only one of the argument is concrete,+ -- and in the presence of NaN's it would be incorrect to do any optimization+ isConcretely _ _ = False++instance SymVal RoundingMode where+ literal s = SBV $ SVal kRoundingMode $ Left $ CV kRoundingMode $ CADT (show s, [])+ fromCV (CV k (CADT (s, [])))+ | k == kRoundingMode+ , Just mode <- s `lookup` [(show m, m) | m <- [minBound .. maxBound :: RoundingMode]]+ = mode+ fromCV c = error $ "SymVal.RoundingMode: Unexpected non-rounding mode value: " ++ show c++-- | Symbolic variant of 'RoundNearestTiesToEven'+sRoundNearestTiesToEven :: SRoundingMode+sRoundNearestTiesToEven = literal RoundNearestTiesToEven++-- | Symbolic variant of 'RoundNearestTiesToAway'+sRoundNearestTiesToAway :: SRoundingMode+sRoundNearestTiesToAway = literal RoundNearestTiesToAway++-- | Symbolic variant of 'RoundTowardPositive'+sRoundTowardPositive :: SRoundingMode+sRoundTowardPositive = literal RoundTowardPositive++-- | Symbolic variant of 'RoundTowardNegative'+sRoundTowardNegative :: SRoundingMode+sRoundTowardNegative = literal RoundTowardNegative++-- | Symbolic variant of 'RoundTowardZero'+sRoundTowardZero :: SRoundingMode+sRoundTowardZero = literal RoundTowardZero++-- | Alias for 'sRoundNearestTiesToEven'+sRNE :: SRoundingMode+sRNE = sRoundNearestTiesToEven++-- | Alias for 'sRoundNearestTiesToAway'+sRNA :: SRoundingMode+sRNA = sRoundNearestTiesToAway++-- | Alias for 'sRoundTowardPositive'+sRTP :: SRoundingMode+sRTP = sRoundTowardPositive++-- | Alias for 'sRoundTowardNegative'+sRTN :: SRoundingMode+sRTN = sRoundTowardNegative++-- | Alias for 'sRoundTowardZero'+sRTZ :: SRoundingMode+sRTZ = sRoundTowardZero+++instance SymVal Char where+ mkSymVal = genMkSymVar KChar+ literal c = SBV . SVal KChar . Left . CV KChar $ CChar c+ fromCV (CV _ (CChar a)) = a+ fromCV c = error $ "SymVal.String: Unexpected non-char value: " ++ show c++instance SymVal a => SymVal [a] where+ mkSymVal+ | isKString @[a] undefined = genMkSymVar KString+ | True = genMkSymVar (KList (kindOf (Proxy @a)))++ literal as+ | isKString @[a] undefined = case fromDynamic (toDyn as) of+ Just s -> SBV . SVal KString . Left . CV KString . CString $ s+ Nothing -> error "SString: Cannot construct literal string!"+ | True = let k = KList (kindOf (Proxy @a))+ in SBV $ SVal k $ Left $ CV k $ CList $ map toCV as++ fromCV (CV _ (CString a)) = fromMaybe (error "SString: Cannot extract a literal string!")+ (fromDynamic (toDyn a))+ fromCV (CV _ (CList a)) = fromCV . CV (kindOf (Proxy @a)) <$> a+ fromCV c = error $ "SymVal.fromCV: Unexpected non-list value: " ++ show c++ minMaxBound = Nothing++instance ValidFloat eb sb => HasKind (FloatingPoint eb sb) where+ kindOf _ = KFP (intOfProxy (Proxy @eb)) (intOfProxy (Proxy @sb))++instance ValidFloat eb sb => SymVal (FloatingPoint eb sb) where+ mkSymVal = genMkSymVar (KFP (intOfProxy (Proxy @eb)) (intOfProxy (Proxy @sb)))+ literal (FloatingPoint r) = let k = KFP (intOfProxy (Proxy @eb)) (intOfProxy (Proxy @sb))+ in SBV $ SVal k $ Left $ CV k (CFP r)+ fromCV (CV _ (CFP r)) = FloatingPoint r+ fromCV c = error $ "SymVal.FPR: Unexpected non-arbitrary-precision value: " ++ show c+ minMaxBound = Nothing++-- | 'SymVal' instance for 'WordN'+instance (KnownNat n, BVIsNonZero n) => SymVal (WordN n) where+ literal x = genLiteral (kindOf x) x+ mkSymVal = genMkSymVar (kindOf (undefined :: WordN n))+ fromCV = genFromCV++-- | 'SymVal' instance for 'IntN'+instance (KnownNat n, BVIsNonZero n) => SymVal (IntN n) where+ literal x = genLiteral (kindOf x) x+ mkSymVal = genMkSymVar (kindOf (undefined :: IntN n))+ fromCV = genFromCV++toCV :: SymVal a => a -> CVal+toCV a = case literal a of+ SBV (SVal _ (Left cv)) -> cvVal cv+ _ -> error "SymVal.toCV: Impossible happened, couldn't produce a concrete value"++mkCVTup :: Int -> Kind -> [CVal] -> SBV a+mkCVTup i k@(KTuple ks) cs+ | lks == lcs && lks == i+ = SBV $ SVal k $ Left $ CV k $ CTuple cs+ | True+ = error $ "SymVal.mkCVTup: Impossible happened. Malformed tuple received: " ++ show (i, k)+ where lks = length ks+ lcs = length cs+mkCVTup i k _+ = error $ "SymVal.mkCVTup: Impossible happened. Non-tuple received: " ++ show (i, k)++fromCVTup :: Int -> CV -> [CV]+fromCVTup i inp@(CV (KTuple ks) (CTuple cs))+ | lks == lcs && lks == i+ = zipWith CV ks cs+ | True+ = error $ "SymVal.fromCTup: Impossible happened. Malformed tuple received: " ++ show (i, inp)+ where lks = length ks+ lcs = length cs+fromCVTup i inp = error $ "SymVal.fromCVTup: Impossible happened. Non-tuple received: " ++ show (i, inp)++instance (HasKind a, HasKind b, SymVal a, SymVal b) => SymVal (ArrayModel a b) where+ mkSymVal = genMkSymVar (KArray (kindOf (Proxy @a)) (kindOf (Proxy @b)))++ -- If the table has duplicate entries for keys, then the first one takes precedence.+ -- That is, [(a, v1), (a, v2)] is equivalent to [(a, v1)]. The best way to think about+ -- this is as a "stack" of writes. [(a, v1), (a, v2)] means we first "wrote" v2 at+ -- a, and then wrote v1 at the same address; so the first write of v2 got overwritten.+ literal (ArrayModel tbl def) = SBV . SVal knd . Left . CV knd $ CArray $ ArrayModel [(toCV k, toCV v) | (k, v) <- tbl] (toCV def)+ where knd = kindOf (Proxy @(ArrayModel a b))++ fromCV (CV (KArray k1 k2) (CArray (ArrayModel assocs def))) = ArrayModel [(fromCV (CV k1 a), fromCV (CV k2 b)) | (a, b) <- assocs]+ (fromCV (CV k2 def))++ fromCV bad = error $ "SymVal.fromCV (SArray): Malformed array received: " ++ show bad++ minMaxBound = Nothing++instance (Arbitrary a, Arbitrary b) => Arbitrary (ArrayModel a b) where+ arbitrary = ArrayModel <$> arbitrary <*> arbitrary++instance (Ord a, SymVal a) => SymVal (RCSet a) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(RCSet a)))++ literal eur = SBV $ SVal k $ Left $ CV k $ CSet $ dir $ Set.map toCV s+ where (dir, s) = case eur of+ RegularSet x -> (RegularSet, x)+ ComplementSet x -> (ComplementSet, x)+ k = kindOf (Proxy @(RCSet a))++ fromCV (CV (KSet a) (CSet (RegularSet s))) = RegularSet $ Set.map (fromCV . CV a) s+ fromCV (CV (KSet a) (CSet (ComplementSet s))) = ComplementSet $ Set.map (fromCV . CV a) s+ fromCV bad = error $ "SymVal.fromCV (Set): Malformed set received: " ++ show bad++ minMaxBound = Nothing++-- | SymVal for 0-tuple (i.e., unit)+instance SymVal () where+ mkSymVal = genMkSymVar (KTuple [])+ literal () = mkCVTup 0 (kindOf (Proxy @())) []+ fromCV cv = fromCVTup 0 cv `seq` ()++-- | SymVal for 2-tuples+instance (SymVal a, SymVal b) => SymVal (a, b) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(a, b)))+ literal (v1, v2) = mkCVTup 2 (kindOf (Proxy @(a, b))) [toCV v1, toCV v2]+ fromCV cv = let ~[v1, v2] = fromCVTup 2 cv+ in (fromCV v1, fromCV v2)++ minMaxBound = Nothing++-- | SymVal for 3-tuples+instance (SymVal a, SymVal b, SymVal c) => SymVal (a, b, c) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c)))+ literal (v1, v2, v3) = mkCVTup 3 (kindOf (Proxy @(a, b, c))) [toCV v1, toCV v2, toCV v3]+ fromCV cv = let ~[v1, v2, v3] = fromCVTup 3 cv+ in (fromCV v1, fromCV v2, fromCV v3)+ minMaxBound = Nothing++-- | SymVal for 4-tuples+instance (SymVal a, SymVal b, SymVal c, SymVal d) => SymVal (a, b, c, d) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d)))+ literal (v1, v2, v3, v4) = mkCVTup 4 (kindOf (Proxy @(a, b, c, d))) [toCV v1, toCV v2, toCV v3, toCV v4]+ fromCV cv = let ~[v1, v2, v3, v4] = fromCVTup 4 cv+ in (fromCV v1, fromCV v2, fromCV v3, fromCV v4)+ minMaxBound = Nothing++-- | SymVal for 5-tuples+instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e) => SymVal (a, b, c, d, e) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e)))+ literal (v1, v2, v3, v4, v5) = mkCVTup 5 (kindOf (Proxy @(a, b, c, d, e))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5]+ fromCV cv = let ~[v1, v2, v3, v4, v5] = fromCVTup 5 cv+ in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5)+ minMaxBound = Nothing++-- | SymVal for 6-tuples+instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f) => SymVal (a, b, c, d, e, f) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e, f)))+ literal (v1, v2, v3, v4, v5, v6) = mkCVTup 6 (kindOf (Proxy @(a, b, c, d, e, f))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5, toCV v6]+ fromCV cv = let ~[v1, v2, v3, v4, v5, v6] = fromCVTup 6 cv+ in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5, fromCV v6)+ minMaxBound = Nothing++-- | SymVal for 7-tuples+instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g) => SymVal (a, b, c, d, e, f, g) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e, f, g)))+ literal (v1, v2, v3, v4, v5, v6, v7) = mkCVTup 7 (kindOf (Proxy @(a, b, c, d, e, f, g))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5, toCV v6, toCV v7]+ fromCV cv = let ~[v1, v2, v3, v4, v5, v6, v7] = fromCVTup 7 cv+ in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5, fromCV v6, fromCV v7)+ minMaxBound = Nothing++-- | SymVal for 8-tuples+instance (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, SymVal h) => SymVal (a, b, c, d, e, f, g, h) where+ mkSymVal = genMkSymVar (kindOf (Proxy @(a, b, c, d, e, f, g, h)))+ literal (v1, v2, v3, v4, v5, v6, v7, v8) = mkCVTup 8 (kindOf (Proxy @(a, b, c, d, e, f, g, h))) [toCV v1, toCV v2, toCV v3, toCV v4, toCV v5, toCV v6, toCV v7, toCV v8]+ fromCV cv = let ~[v1, v2, v3, v4, v5, v6, v7, v8] = fromCVTup 8 cv+ in (fromCV v1, fromCV v2, fromCV v3, fromCV v4, fromCV v5, fromCV v6, fromCV v7, fromCV v8)+ minMaxBound = Nothing++instance IsString SString where+ fromString = literal++------------------------------------------------------------------------------------+-- * Smart constructors for creating symbolic values. These are not strictly+-- necessary, as they are mere aliases for 'symbolic' and 'symbolics', but+-- they nonetheless make programming easier.+------------------------------------------------------------------------------------++-- | Generalization of 'Data.SBV.sBool'+sBool :: MonadSymbolic m => String -> m SBool+sBool = symbolic++-- | Generalization of 'Data.SBV.sBool_'+sBool_ :: MonadSymbolic m => m SBool+sBool_ = free_++-- | Generalization of 'Data.SBV.sBools'+sBools :: MonadSymbolic m => [String] -> m [SBool]+sBools = symbolics++-- | Generalization of 'Data.SBV.sWord8'+sWord8 :: MonadSymbolic m => String -> m SWord8+sWord8 = symbolic++-- | Generalization of 'Data.SBV.sWord8_'+sWord8_ :: MonadSymbolic m => m SWord8+sWord8_ = free_++-- | Generalization of 'Data.SBV.sWord8s'+sWord8s :: MonadSymbolic m => [String] -> m [SWord8]+sWord8s = symbolics++-- | Generalization of 'Data.SBV.sWord16'+sWord16 :: MonadSymbolic m => String -> m SWord16+sWord16 = symbolic++-- | Generalization of 'Data.SBV.sWord16_'+sWord16_ :: MonadSymbolic m => m SWord16+sWord16_ = free_++-- | Generalization of 'Data.SBV.sWord16s'+sWord16s :: MonadSymbolic m => [String] -> m [SWord16]+sWord16s = symbolics++-- | Generalization of 'Data.SBV.sWord32'+sWord32 :: MonadSymbolic m => String -> m SWord32+sWord32 = symbolic++-- | Generalization of 'Data.SBV.sWord32_'+sWord32_ :: MonadSymbolic m => m SWord32+sWord32_ = free_++-- | Generalization of 'Data.SBV.sWord32s'+sWord32s :: MonadSymbolic m => [String] -> m [SWord32]+sWord32s = symbolics++-- | Generalization of 'Data.SBV.sWord64'+sWord64 :: MonadSymbolic m => String -> m SWord64+sWord64 = symbolic++-- | Generalization of 'Data.SBV.sWord64_'+sWord64_ :: MonadSymbolic m => m SWord64+sWord64_ = free_++-- | Generalization of 'Data.SBV.sWord64s'+sWord64s :: MonadSymbolic m => [String] -> m [SWord64]+sWord64s = symbolics++-- | Generalization of 'Data.SBV.sInt8'+sInt8 :: MonadSymbolic m => String -> m SInt8+sInt8 = symbolic++-- | Generalization of 'Data.SBV.sInt8_'+sInt8_ :: MonadSymbolic m => m SInt8+sInt8_ = free_++-- | Generalization of 'Data.SBV.sInt8s'+sInt8s :: MonadSymbolic m => [String] -> m [SInt8]+sInt8s = symbolics++-- | Generalization of 'Data.SBV.sInt16'+sInt16 :: MonadSymbolic m => String -> m SInt16+sInt16 = symbolic++-- | Generalization of 'Data.SBV.sInt16_'+sInt16_ :: MonadSymbolic m => m SInt16+sInt16_ = free_++-- | Generalization of 'Data.SBV.sInt16s'+sInt16s :: MonadSymbolic m => [String] -> m [SInt16]+sInt16s = symbolics++-- | Generalization of 'Data.SBV.sInt32'+sInt32 :: MonadSymbolic m => String -> m SInt32+sInt32 = symbolic++-- | Generalization of 'Data.SBV.sInt32_'+sInt32_ :: MonadSymbolic m => m SInt32+sInt32_ = free_++-- | Generalization of 'Data.SBV.sInt32s'+sInt32s :: MonadSymbolic m => [String] -> m [SInt32]+sInt32s = symbolics++-- | Generalization of 'Data.SBV.sInt64'+sInt64 :: MonadSymbolic m => String -> m SInt64+sInt64 = symbolic++-- | Generalization of 'Data.SBV.sInt64_'+sInt64_ :: MonadSymbolic m => m SInt64+sInt64_ = free_++-- | Generalization of 'Data.SBV.sInt64s'+sInt64s :: MonadSymbolic m => [String] -> m [SInt64]+sInt64s = symbolics++-- | Generalization of 'Data.SBV.sInteger'+sInteger:: MonadSymbolic m => String -> m SInteger+sInteger = symbolic++-- | Generalization of 'Data.SBV.sInteger_'+sInteger_:: MonadSymbolic m => m SInteger+sInteger_ = free_++-- | Generalization of 'Data.SBV.sIntegers'+sIntegers :: MonadSymbolic m => [String] -> m [SInteger]+sIntegers = symbolics++-- | Generalization of 'Data.SBV.sReal'+sReal:: MonadSymbolic m => String -> m SReal+sReal = symbolic++-- | Generalization of 'Data.SBV.sReal_'+sReal_:: MonadSymbolic m => m SReal+sReal_ = free_++-- | Generalization of 'Data.SBV.sReals'+sReals :: MonadSymbolic m => [String] -> m [SReal]+sReals = symbolics++-- | Generalization of 'Data.SBV.sFloat'+sFloat :: MonadSymbolic m => String -> m SFloat+sFloat = symbolic++-- | Generalization of 'Data.SBV.sFloat_'+sFloat_ :: MonadSymbolic m => m SFloat+sFloat_ = free_++-- | Generalization of 'Data.SBV.sFloats'+sFloats :: MonadSymbolic m => [String] -> m [SFloat]+sFloats = symbolics++-- | Generalization of 'Data.SBV.sDouble'+sDouble :: MonadSymbolic m => String -> m SDouble+sDouble = symbolic++-- | Generalization of 'Data.SBV.sDouble_'+sDouble_ :: MonadSymbolic m => m SDouble+sDouble_ = free_++-- | Generalization of 'Data.SBV.sDoubles'+sDoubles :: MonadSymbolic m => [String] -> m [SDouble]+sDoubles = symbolics++-- | Generalization of 'Data.SBV.sFPHalf'+sFPHalf :: String -> Symbolic SFPHalf+sFPHalf = symbolic++-- | Generalization of 'Data.SBV.sFPHalf_'+sFPHalf_ :: Symbolic SFPHalf+sFPHalf_ = free_++-- | Generalization of 'Data.SBV.sFPHalfs'+sFPHalfs :: [String] -> Symbolic [SFPHalf]+sFPHalfs = symbolics++-- | Generalization of 'Data.SBV.sFPBFloat'+sFPBFloat :: String -> Symbolic SFPBFloat+sFPBFloat = symbolic++-- | Generalization of 'Data.SBV.sFPBFloat_'+sFPBFloat_ :: Symbolic SFPBFloat+sFPBFloat_ = free_++-- | Generalization of 'Data.SBV.sFPBFloats'+sFPBFloats :: [String] -> Symbolic [SFPBFloat]+sFPBFloats = symbolics++-- | Generalization of 'Data.SBV.sFPSingle'+sFPSingle :: String -> Symbolic SFPSingle+sFPSingle = symbolic++-- | Generalization of 'Data.SBV.sFPSingle_'+sFPSingle_ :: Symbolic SFPSingle+sFPSingle_ = free_++-- | Generalization of 'Data.SBV.sFPSingles'+sFPSingles :: [String] -> Symbolic [SFPSingle]+sFPSingles = symbolics++-- | Generalization of 'Data.SBV.sFPDouble'+sFPDouble :: String -> Symbolic SFPDouble+sFPDouble = symbolic++-- | Generalization of 'Data.SBV.sFPDouble_'+sFPDouble_ :: Symbolic SFPDouble+sFPDouble_ = free_++-- | Generalization of 'Data.SBV.sFPDoubles'+sFPDoubles :: [String] -> Symbolic [SFPDouble]+sFPDoubles = symbolics++-- | Generalization of 'Data.SBV.sFPQuad'+sFPQuad :: String -> Symbolic SFPQuad+sFPQuad = symbolic++-- | Generalization of 'Data.SBV.sFPQuad_'+sFPQuad_ :: Symbolic SFPQuad+sFPQuad_ = free_++-- | Generalization of 'Data.SBV.sFPQuads'+sFPQuads :: [String] -> Symbolic [SFPQuad]+sFPQuads = symbolics++-- | Generalization of 'Data.SBV.sFloatingPoint'+sFloatingPoint :: ValidFloat eb sb => String -> Symbolic (SFloatingPoint eb sb)+sFloatingPoint = symbolic++-- | Generalization of 'Data.SBV.sFloatingPoint_'+sFloatingPoint_ :: ValidFloat eb sb => Symbolic (SFloatingPoint eb sb)+sFloatingPoint_ = free_++-- | Generalization of 'Data.SBV.sFloatingPoints'+sFloatingPoints :: ValidFloat eb sb => [String] -> Symbolic [SFloatingPoint eb sb]+sFloatingPoints = symbolics++-- | Generalization of 'Data.SBV.sWord'+sWord :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => String -> m (SWord n)+sWord = symbolic++-- | Generalization of 'Data.SBV.sWord_'+sWord_ :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => m (SWord n)+sWord_ = free_++-- | Generalization of 'Data.SBV.sWord64s'+sWords :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => [String] -> m [SWord n]+sWords = symbolics++-- | Generalization of 'Data.SBV.sInt'+sInt :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => String -> m (SInt n)+sInt = symbolic++-- | Generalization of 'Data.SBV.sInt_'+sInt_ :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => m (SInt n)+sInt_ = free_++-- | Generalization of 'Data.SBV.sInts'+sInts :: (KnownNat n, BVIsNonZero n) => MonadSymbolic m => [String] -> m [SInt n]+sInts = symbolics++-- | Generalization of 'Data.SBV.sChar'+sChar :: MonadSymbolic m => String -> m SChar+sChar = symbolic++-- | Generalization of 'Data.SBV.sChar_'+sChar_ :: MonadSymbolic m => m SChar+sChar_ = free_++-- | Generalization of 'Data.SBV.sChars'+sChars :: MonadSymbolic m => [String] -> m [SChar]+sChars = symbolics++-- | Generalization of 'Data.SBV.sString'+sString :: MonadSymbolic m => String -> m SString+sString = symbolic++-- | Generalization of 'Data.SBV.sString_'+sString_ :: MonadSymbolic m => m SString+sString_ = free_++-- | Generalization of 'Data.SBV.sStrings'+sStrings :: MonadSymbolic m => [String] -> m [SString]+sStrings = symbolics++-- | Generalization of 'Data.SBV.sList'+sList :: (SymVal a, MonadSymbolic m) => String -> m (SList a)+sList = symbolic++-- | Generalization of 'Data.SBV.sList_'+sList_ :: (SymVal a, MonadSymbolic m) => m (SList a)+sList_ = free_++-- | Generalization of 'Data.SBV.sLists'+sLists :: (SymVal a, MonadSymbolic m) => [String] -> m [SList a]+sLists = symbolics++-- | Generalization of 'Data.SBV.sAray'+sArray :: (SymVal a, SymVal b, MonadSymbolic m) => String -> m (SArray a b)+sArray = symbolic++-- | Generalization of 'Data.SBV.sList_'+sArray_ :: (SymVal a, SymVal b, MonadSymbolic m) => m (SArray a b)+sArray_ = free_++-- | Generalization of 'Data.SBV.sLists'+sArrays :: (SymVal a, SymVal b, MonadSymbolic m) => [String] -> m [SArray a b]+sArrays = symbolics++-- | Identify tuple like things. Note that there are no methods, just instances to control type inference+class SymTuple a+instance SymTuple ()+instance SymTuple (a, b)+instance SymTuple (a, b, c)+instance SymTuple (a, b, c, d)+instance SymTuple (a, b, c, d, e)+instance SymTuple (a, b, c, d, e, f)+instance SymTuple (a, b, c, d, e, f, g)+instance SymTuple (a, b, c, d, e, f, g, h)++-- | Generalization of 'Data.SBV.sTuple'+sTuple :: (SymTuple tup, SymVal tup, MonadSymbolic m) => String -> m (SBV tup)+sTuple = symbolic++-- | Generalization of 'Data.SBV.sTuple_'+sTuple_ :: (SymTuple tup, SymVal tup, MonadSymbolic m) => m (SBV tup)+sTuple_ = free_++-- | Generalization of 'Data.SBV.sTuples'+sTuples :: (SymTuple tup, SymVal tup, MonadSymbolic m) => [String] -> m [SBV tup]+sTuples = symbolics++-- | Generalization of 'Data.SBV.sRational'+sRational :: MonadSymbolic m => String -> m SRational+sRational = symbolic++-- | Generalization of 'Data.SBV.sRational_'+sRational_ :: MonadSymbolic m => m SRational+sRational_ = free_++-- | Generalization of 'Data.SBV.sRationals'+sRationals :: MonadSymbolic m => [String] -> m [SRational]+sRationals = symbolics++-- | Generalization of 'Data.SBV.sSet'+sSet :: (Ord a, SymVal a, MonadSymbolic m) => String -> m (SSet a)+sSet = symbolic++-- | Generalization of 'Data.SBV.sMaybe_'+sSet_ :: (Ord a, SymVal a, MonadSymbolic m) => m (SSet a)+sSet_ = free_++-- | Generalization of 'Data.SBV.sMaybes'+sSets :: (Ord a, SymVal a, MonadSymbolic m) => [String] -> m [SSet a]+sSets = symbolics++-- | Generalization of 'Data.SBV.solve'+solve :: MonadSymbolic m => [SBool] -> m SBool+solve = return . sAnd++-- | Convert an SReal to an SInteger. That is, it computes the+-- largest integer @n@ that satisfies @sIntegerToSReal n <= r@+-- essentially giving us the @floor@.+--+-- For instance, @1.3@ will be @1@, but @-1.3@ will be @-2@.+sRealToSInteger :: SReal -> SInteger+sRealToSInteger x+ | Just i <- unliteral x, isExactRational i+ = literal $ floor (toRational i)+ | True+ = SBV (SVal KUnbounded (Right (cache y)))+ where y st = do xsv <- sbvToSV st x+ newExpr st KUnbounded (SBVApp (KindCast KReal KUnbounded) [xsv])++-- | Convert an SReal to an SInteger, truncating version.+sRealToSIntegerTruncate :: SReal -> SInteger+sRealToSIntegerTruncate x = ite (x .< 0) (sRealToSInteger x) (- (sRealToSInteger (- x)))++-- | label: Label the result of an expression. This is essentially a no-op, but useful as it generates a comment in the generated C/SMT-Lib code.+-- Note that if the argument is a constant, then the label is dropped completely, per the usual constant folding strategy. Compare this to 'observe'+-- which is good for printing counter-examples.+label :: SymVal a => String -> SBV a -> SBV a+label m x+ | Just _ <- unliteral x = x+ | True = SBV $ SVal k $ Right $ cache r+ where k = kindOf x+ r st = do xsv <- sbvToSV st x+ newExpr st k (SBVApp (Label m) [xsv])+++-- | Observe the value of an expression, if the given condition holds. Such values are useful in model construction, as they are printed part of a satisfying model, or a+-- counter-example. The same works for quick-check as well. Useful when we want to see intermediate values, or expected/obtained+-- pairs in a particular run. Note that an observed expression is always symbolic, i.e., it won't be constant folded. Compare this to 'label'+-- which is used for putting a label in the generated SMTLib-C code.+--+-- NB. If the observed expression happens under a SBV-lambda expression, then it is silently ignored; since+-- there's no way to access the value of such a value.+observeIf :: SymVal a => (a -> Bool) -> String -> SBV a -> SBV a+observeIf cond m x+ | Just bad <- checkObservableName m+ = error bad+ | True+ = SBV $ SVal k $ Right $ cache r+ where k = kindOf x+ r st = do xsv <- sbvToSV st (label ("Observing: " ++ m) x)+ recordObservable st m (cond . fromCV) xsv+ return xsv++-- | Observe the value of an expression, unconditionally. See 'observeIf' for a generalized version.+observe :: SymVal a => String -> SBV a -> SBV a+observe = observeIf (const True)++-- | Symbolic Comparisons. Similar to 'Eq', we cannot implement Haskell's 'Ord' class+-- since there is no way to return an 'Ordering' value from a symbolic comparison.+-- Furthermore, 'OrdSymbolic' requires 'Mergeable' to implement if-then-else, for the+-- benefit of implementing symbolic versions of 'max' and 'min' functions.+infix 4 .<, .<=, .>, .>=+class (Mergeable a, EqSymbolic a) => OrdSymbolic a where+ -- | Symbolic less than.+ (.<) :: a -> a -> SBool+ -- | Symbolic less than or equal to.+ (.<=) :: a -> a -> SBool+ -- | Symbolic greater than.+ (.>) :: a -> a -> SBool+ -- | Symbolic greater than or equal to.+ (.>=) :: a -> a -> SBool+ -- | Symbolic minimum.+ smin :: a -> a -> a+ -- | Symbolic maximum.+ smax :: a -> a -> a+ -- | Is the value within the allowed /inclusive/ range?+ inRange :: a -> (a, a) -> SBool++ {-# MINIMAL (.<) #-}++ a .<= b = a .< b .|| a .== b+ a .> b = b .< a+ a .>= b = b .<= a++ a `smin` b = ite (a .<= b) a b+ a `smax` b = ite (a .<= b) b a++ inRange x (y, z) = x .>= y .&& x .<= z+++{- We can't have a generic instance of the form:++instance Eq a => EqSymbolic a where+ x .== y = if x == y then true else sFalse++even if we're willing to allow Flexible/undecidable instances..+This is because if we allow this it would imply EqSymbolic (SBV a);+since (SBV a) has to be Eq as it must be a Num. But this wouldn't be+the right choice obviously; as the Eq instance is bogus for SBV+for natural reasons..+-}++-- It is tempting to put in an @Eq a@ superclass here. But doing so+-- is complicated, as it requires all underlying types to have equality,+-- which is at best shaky for algebraic reals and sets. So, leave it out.+instance (HasKind a, SymVal a) => EqSymbolic (SBV a) where+ SBV x .== SBV y = SBV (svEqual x y)+ SBV x ./= SBV y = SBV (svNotEqual x y)++ SBV x .=== SBV y = SBV (svStrongEqual x y)++ -- Custom version of distinct that generates better code for base types+ distinct [] = sTrue+ distinct [_] = sTrue+ distinct xs | all isConc xs = checkDiff xs+ | [SBV a, SBV b] <- xs, a `is` svBool True = SBV $ svNot b+ | [SBV a, SBV b] <- xs, b `is` svBool True = SBV $ svNot a+ | [SBV a, SBV b] <- xs, a `is` svBool False = SBV b+ | [SBV a, SBV b] <- xs, b `is` svBool False = SBV a+ -- 3 booleans can't be distinct!+ | (x : _ : _ : _) <- xs, isBool x = sFalse+ | True = SBV (SVal KBool (Right (cache r)))+ where r st = do xsv <- mapM (sbvToSV st) xs+ newExpr st KBool (SBVApp NotEqual xsv)++ -- We call this in case all are concrete, which will+ -- reduce to a constant and generate no code at all!+ -- Note that this is essentially the same as the default+ -- definition, which unfortunately we can no longer call!+ checkDiff [] = sTrue+ checkDiff (a:as) = sAll (a ./=) as .&& checkDiff as++ -- Sigh, we can't use isConcrete since that requires SymVal+ -- constraint that we don't have here. (To support SBools.)+ isConc (SBV (SVal _ (Left _))) = True+ isConc _ = False++ -- Likewise here; need to go lower.+ SVal k1 (Left c1) `is` SVal k2 (Left c2) = (k1, c1) == (k2, c2)+ _ `is` _ = False++ isBool (SBV (SVal KBool _)) = True+ isBool _ = False++ -- Custom version of distinctExcept that generates better code for base types+ distinctExcept [] _ = sTrue+ distinctExcept [_] _ = sTrue+ distinctExcept es ignored+ | all isConc (es ++ ignored)+ = distinct (filter ignoreConc es)+ | True+ = SBV (SVal KBool (Right (cache r)))+ where ignoreConc x = case x `sElem` ignored of+ SBV (SVal KBool (Left cv)) -> cvToBool cv+ _ -> error $ "distinctExcept: Impossible happened, concrete sElem failed: " ++ show (es, ignored, x)++ r st = do let incr x table = ite (x `sElem` ignored) (0 :: SInteger) (1 + readArrayNoEq table x)++ initArray :: SArray a Integer+ initArray = constArray 0++ finalArray = foldl' (\table x -> writeArrayNoKnd table x (incr x table)) initArray es++ sbvToSV st $ sAll (\e -> readArrayNoEq finalArray e .<= (1 :: SInteger)) es++ -- Sigh, we can't use isConcrete since that requires SymVal+ -- constraint that we don't have here. (To support SBools.)+ isConc (SBV (SVal _ (Left _))) = True+ isConc _ = False++ -- Version of readArray that doesn't have the Eq constraint, since we don't have it here+ readArrayNoEq array key = SBV . SVal KUnbounded . Right $ cache g+ where g st = do f <- sbvToSV st array+ k <- sbvToSV st key+ newExpr st KUnbounded (SBVApp ReadArray [f, k])++ writeArrayNoKnd :: forall key. HasKind key => SArray key Integer -> SBV key -> SInteger -> SArray key Integer+ writeArrayNoKnd array key value = SBV . SVal k . Right $ cache g+ where k = KArray (kindOf (Proxy @key)) KUnbounded++ g st = do arr <- sbvToSV st array+ keyVal <- sbvToSV st key+ val <- sbvToSV st value+ newExpr st k (SBVApp WriteArray [arr, keyVal, val])++-- We don't want to do a generic OrdSymbolic (SBV a) instance; since that would be dangerous, like the case+-- for Num. So, we explicitly define for each type we care about.++#define MKSORD(CSTR, TYPE) \+instance CSTR => OrdSymbolic TYPE where { \+ a@(SBV x) .< b@(SBV y) | smtComparable "<" a b = SBV (svLessThan x y) \+ | True = SBV (svStructuralLessThan x y); \+ \+ a@(SBV x) .<= b@(SBV y) | smtComparable ".<=" a b = SBV (svLessEq x y) \+ | True = a .< b .|| a .== b; \+ \+ a@(SBV x) .> b@(SBV y) | smtComparable ">" a b = SBV (svGreaterThan x y) \+ | True = b .< a; \+ \+ a@(SBV x) .>= b@(SBV y) | smtComparable ">=" a b = SBV (svGreaterEq x y) \+ | True = b .<= a; \+} \++-- Derive basic instances we need. NB. We don't give the SRational instance here. It's handled+-- in Data/SBV/Rational due to representation issues.+MKSORD((), SInteger)+MKSORD((), SWord8)+MKSORD((), SWord16)+MKSORD((), SWord32)+MKSORD((), SWord64)+MKSORD((), SInt8)+MKSORD((), SInt16)+MKSORD((), SInt32)+MKSORD((), SInt64)+MKSORD((), SFloat)+MKSORD((), SChar)+MKSORD((SymVal a), (SList a))+MKSORD((), SDouble)+MKSORD((), SReal)+MKSORD((KnownNat n, BVIsNonZero n), (SWord n))+MKSORD((KnownNat n, BVIsNonZero n), (SInt n))+MKSORD((ValidFloat eb sb), (SFloatingPoint eb sb))++-- Tuples+MKSORD((SymVal a, SymVal b), (SBV (a, b)))+MKSORD((SymVal a, SymVal b, SymVal c), (SBV (a, b, c)))+MKSORD((SymVal a, SymVal b, SymVal c, SymVal d), (SBV (a, b, c, d)))+MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e), (SBV (a, b, c, d, e)))+MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f), (SBV (a, b, c, d, e, f)))+MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g), (SBV (a, b, c, d, e, f, g)))+MKSORD((SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, SymVal h), (SBV (a, b, c, d, e, f, g, h)))+#undef MKSORD++-- Is this a type that's comparable by underlying translation to SMTLib?+-- Note that we allow concrete versions to go through unless the type is a set, as there's really no reason not to.+smtComparable :: (SymVal a, HasKind a) => String -> SBV a -> SBV a -> Bool+smtComparable op x y+ | isConcrete x && isConcrete y && not (isSet k)+ = True+ | True+ = case k of+ KVar {} -> False+ KBool -> True+ KBounded {} -> True+ KUnbounded {} -> True+ KReal {} -> True+ KApp {} -> True+ KADT {} -> True+ KFloat -> True+ KDouble -> True+ KRational {} -> True+ KFP {} -> True+ KChar -> True+ KString -> True+ KList {} -> nope -- Unfortunately, no way for us to desugar this+ KSet {} -> nope -- Ditto here..+ KTuple {} -> False+ KArray {} -> True+ where k = kindOf x+ nope = error $ "Data.SBV.OrdSymbolic: SMTLib does not support " ++ op ++ " for " ++ show k++-- Bool+instance EqSymbolic Bool where+ x .== y = fromBool $ x == y++-- Lists+instance EqSymbolic a => EqSymbolic [a] where+ [] .== [] = sTrue+ (x:xs) .== (y:ys) = x .== y .&& xs .== ys+ _ .== _ = sFalse++ [] .=== [] = sTrue+ (x:xs) .=== (y:ys) = x .=== y .&& xs .=== ys+ _ .=== _ = sFalse++instance OrdSymbolic a => OrdSymbolic [a] where+ [] .< [] = sFalse+ [] .< _ = sTrue+ _ .< [] = sFalse+ (x:xs) .< (y:ys) = x .< y .|| (x .== y .&& xs .< ys)++-- NonEmpty+instance EqSymbolic a => EqSymbolic (NonEmpty a) where+ (x :| xs) .== (y :| ys) = x : xs .== y : ys+ (x :| xs) .=== (y :| ys) = x : xs .=== y : ys++instance OrdSymbolic a => OrdSymbolic (NonEmpty a) where+ (x :| xs) .< (y :| ys) = x : xs .< y : ys++-- Maybe+instance EqSymbolic a => EqSymbolic (Maybe a) where+ Nothing .== Nothing = sTrue+ Just a .== Just b = a .== b+ _ .== _ = sFalse++instance OrdSymbolic a => OrdSymbolic (Maybe a) where+ Nothing .< Nothing = sFalse+ Nothing .< _ = sTrue+ Just _ .< Nothing = sFalse+ Just a .< Just b = a .< b++-- Either+instance (EqSymbolic a, EqSymbolic b) => EqSymbolic (Either a b) where+ Left a .== Left b = a .== b+ Right a .== Right b = a .== b+ _ .== _ = sFalse++ Left a .=== Left b = a .=== b+ Right a .=== Right b = a .=== b+ _ .=== _ = sFalse++instance (OrdSymbolic a, OrdSymbolic b) => OrdSymbolic (Either a b) where+ Left a .< Left b = a .< b+ Left _ .< Right _ = sTrue+ Right _ .< Left _ = sFalse+ Right a .< Right b = a .< b++-- 2-Tuple+instance (EqSymbolic a, EqSymbolic b) => EqSymbolic (a, b) where+ (a0, b0) .== (a1, b1) = a0 .== a1 .&& b0 .== b1+ (a0, b0) .=== (a1, b1) = a0 .=== a1 .&& b0 .=== b1++instance (OrdSymbolic a, OrdSymbolic b) => OrdSymbolic (a, b) where+ (a0, b0) .< (a1, b1) = a0 .< a1 .|| (a0 .== a1 .&& b0 .< b1)++-- 3-Tuple+instance (EqSymbolic a, EqSymbolic b, EqSymbolic c) => EqSymbolic (a, b, c) where+ (a0, b0, c0) .== (a1, b1, c1) = (a0, b0) .== (a1, b1) .&& c0 .== c1+ (a0, b0, c0) .=== (a1, b1, c1) = (a0, b0) .=== (a1, b1) .&& c0 .=== c1++instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c) => OrdSymbolic (a, b, c) where+ (a0, b0, c0) .< (a1, b1, c1) = (a0, b0) .< (a1, b1) .|| ((a0, b0) .== (a1, b1) .&& c0 .< c1)++-- 4-Tuple+instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d) => EqSymbolic (a, b, c, d) where+ (a0, b0, c0, d0) .== (a1, b1, c1, d1) = (a0, b0, c0) .== (a1, b1, c1) .&& d0 .== d1+ (a0, b0, c0, d0) .=== (a1, b1, c1, d1) = (a0, b0, c0) .=== (a1, b1, c1) .&& d0 .=== d1++instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d) => OrdSymbolic (a, b, c, d) where+ (a0, b0, c0, d0) .< (a1, b1, c1, d1) = (a0, b0, c0) .< (a1, b1, c1) .|| ((a0, b0, c0) .== (a1, b1, c1) .&& d0 .< d1)++-- 5-Tuple+instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e) => EqSymbolic (a, b, c, d, e) where+ (a0, b0, c0, d0, e0) .== (a1, b1, c1, d1, e1) = (a0, b0, c0, d0) .== (a1, b1, c1, d1) .&& e0 .== e1+ (a0, b0, c0, d0, e0) .=== (a1, b1, c1, d1, e1) = (a0, b0, c0, d0) .=== (a1, b1, c1, d1) .&& e0 .=== e1++instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e) => OrdSymbolic (a, b, c, d, e) where+ (a0, b0, c0, d0, e0) .< (a1, b1, c1, d1, e1) = (a0, b0, c0, d0) .< (a1, b1, c1, d1) .|| ((a0, b0, c0, d0) .== (a1, b1, c1, d1) .&& e0 .< e1)++-- 6-Tuple+instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e, EqSymbolic f) => EqSymbolic (a, b, c, d, e, f) where+ (a0, b0, c0, d0, e0, f0) .== (a1, b1, c1, d1, e1, f1) = (a0, b0, c0, d0, e0) .== (a1, b1, c1, d1, e1) .&& f0 .== f1+ (a0, b0, c0, d0, e0, f0) .=== (a1, b1, c1, d1, e1, f1) = (a0, b0, c0, d0, e0) .=== (a1, b1, c1, d1, e1) .&& f0 .=== f1++instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e, OrdSymbolic f) => OrdSymbolic (a, b, c, d, e, f) where+ (a0, b0, c0, d0, e0, f0) .< (a1, b1, c1, d1, e1, f1) = (a0, b0, c0, d0, e0) .< (a1, b1, c1, d1, e1)+ .|| ((a0, b0, c0, d0, e0) .== (a1, b1, c1, d1, e1) .&& f0 .< f1)++-- 7-Tuple+instance (EqSymbolic a, EqSymbolic b, EqSymbolic c, EqSymbolic d, EqSymbolic e, EqSymbolic f, EqSymbolic g) => EqSymbolic (a, b, c, d, e, f, g) where+ (a0, b0, c0, d0, e0, f0, g0) .== (a1, b1, c1, d1, e1, f1, g1) = (a0, b0, c0, d0, e0, f0) .== (a1, b1, c1, d1, e1, f1) .&& g0 .== g1+ (a0, b0, c0, d0, e0, f0, g0) .=== (a1, b1, c1, d1, e1, f1, g1) = (a0, b0, c0, d0, e0, f0) .=== (a1, b1, c1, d1, e1, f1) .&& g0 .=== g1++instance (OrdSymbolic a, OrdSymbolic b, OrdSymbolic c, OrdSymbolic d, OrdSymbolic e, OrdSymbolic f, OrdSymbolic g) => OrdSymbolic (a, b, c, d, e, f, g) where+ (a0, b0, c0, d0, e0, f0, g0) .< (a1, b1, c1, d1, e1, f1, g1) = (a0, b0, c0, d0, e0, f0) .< (a1, b1, c1, d1, e1, f1)+ .|| ((a0, b0, c0, d0, e0, f0) .== (a1, b1, c1, d1, e1, f1) .&& g0 .< g1)++-- | A class of values that capture the notion of a zero for measure values.+-- Used in termination checking for recursive SMT functions.+class OrdSymbolic (SBV a) => Zero a where+ zero :: SBV a+ -- | Component-wise non-negativity check. For scalars this is simply @>= 0@.+ -- For tuples, every component must be @>= 0@, which is stronger than+ -- lexicographic @>= (0, 0, ..)@. This is required for well-foundedness+ -- of the lexicographic ordering on the non-negative part.+ nonNeg :: SBV a -> SBool+ nonNeg x = x .>= zero++-- | An integer as a measure+instance Zero Integer where+ zero = literal 0++-- NB. We would like to use 'Data.SBV.Tuple.untuple' in the 'nonNeg' definitions below,+-- but 'Data.SBV.Tuple' imports 'Data.SBV.Core.Model', creating a circular dependency.+-- So we extract components at the SVal level using 'TupleAccess' directly.++-- | A tuple of integers as a measure+instance Zero (Integer, Integer) where+ zero = literal (0, 0)+ nonNeg = tupleNonNeg 2++-- | A triple of integers as a measure+instance Zero (Integer, Integer, Integer) where+ zero = literal (0, 0, 0)+ nonNeg = tupleNonNeg 3++-- | A quadruple of integers as a measure+instance Zero (Integer, Integer, Integer, Integer) where+ zero = literal (0, 0, 0, 0)+ nonNeg = tupleNonNeg 4++-- | A quintuple of integers as a measure+instance Zero (Integer, Integer, Integer, Integer, Integer) where+ zero = literal (0, 0, 0, 0, 0)+ nonNeg = tupleNonNeg 5++-- | A float as a measure+instance Zero Float where+ zero = literal 0++-- | A double as a measure+instance Zero Double where+ zero = literal 0++-- | An algebraic real as a measure+instance Zero AlgReal where+ zero = literal 0++-- | A floating-point as a measure+instance ValidFloat eb sb => Zero (FloatingPoint eb sb) where+ zero = literal 0++-- | Component-wise non-negativity for an n-tuple of integers.+-- Extracts each component via 'TupleAccess' and checks @>= 0@.+tupleNonNeg :: SymVal a => Int -> SBV a -> SBool+tupleNonNeg n t = sAll (.>= (0 :: SInteger)) [acc i | i <- [1..n]]+ where acc i = SBV $ SVal KUnbounded $ Right $ cache $ \st -> do+ sv <- sbvToSV st t+ newExpr st KUnbounded (SBVApp (TupleAccess i n) [sv])++-- | Type family that maps a function type to its corresponding measure type.+-- The measure function takes the same arguments but returns a different type.+type family MeasureOf f r where+ MeasureOf (SBV a -> r) r' = SBV a -> MeasureOf r r'+ MeasureOf (SBV a) r = SBV r++-- | Apply a measure function to a list of SVal arguments, producing the measure value.+-- This is used internally during measure verification.+class ApplyMeasure a r where+ applyMeasure :: MeasureOf a r -> [SVal] -> SBV r++instance ApplyMeasure (SBV a) r where+ applyMeasure m [] = m+ applyMeasure _ _ = error "Data.SBV.applyMeasure: too many arguments"++instance ApplyMeasure b r => ApplyMeasure (SBV a -> b) r where+ applyMeasure _ [] = error "Data.SBV.applyMeasure: not enough arguments"+ applyMeasure m (sv:svs) = applyMeasure @b @r (m (SBV sv)) svs++-- | Type family that maps a function type to its corresponding contract type.+-- A contract takes the same arguments as the function, plus the result, and returns 'SBool'.+-- For example, a contract for @SBV Integer -> SBV Integer@ has type @SBV Integer -> SBV Integer -> SBool@+-- (first arg is the input, second is the output).+type family ContractOf f where+ ContractOf (SBV a) = SBV a -> SBool+ ContractOf (SBV a -> r) = SBV a -> ContractOf r++-- | Apply a contract function to a list of input t'SVal' arguments and a result t'SVal'.+class ApplyContract a where+ applyContract :: ContractOf a -> [SVal] -> SVal -> SBool++instance ApplyContract (SBV a) where+ applyContract c [] sv = c (SBV sv)+ applyContract _ _ _ = error "Data.SBV.applyContract: too many arguments"++instance ApplyContract b => ApplyContract (SBV a -> b) where+ applyContract _ [] _ = error "Data.SBV.applyContract: not enough arguments"+ applyContract c (sv:svs) r = applyContract @b (c (SBV sv)) svs r++-- | An evaluated measure: captures the ability to apply the measure function+-- to a list of arguments, along with the ordering and zero constraints.+data MeasureEval where+ MeasureEval :: (Zero r, OrdSymbolic (SBV r), SymVal r) => ([SVal] -> SBV r) -> MeasureEval++-- | An evaluated contract: captures the ability to apply a contract predicate+-- to a list of input arguments and a result value. Used during measure verification+-- for nested recursive functions, where the inductive hypothesis provides the contract+-- on recursive call results.+data ContractEval where+ ContractEval :: ([SVal] -> SVal -> SBool) -> ContractEval++-- | A measure for a function, used to prove termination of recursive definitions.+--+-- * 'AutoMeasure': The function either doesn't need a measure (because it's not recursive),+-- or SBV will automatically guess one based on argument types.+-- * 'HasMeasure': The user provided an explicit measure function.+-- * 'HasContract': The user provided a measure and a contract. The contract is a predicate+-- on the function's inputs and output that is proven simultaneously with the measure decrease+-- via well-founded induction. This handles nested recursion (e.g., McCarthy 91) where the+-- termination argument depends on the function's return value at smaller inputs.+-- * 'Productive': The function is corecursive (productive). Instead of proving termination via a+-- measure, SBV checks that every recursive call is guarded by a data constructor (list cons,+-- ADT constructor, etc.), ensuring the function always produces output incrementally.+-- * 'Unverified': No termination or productivity check is performed. The function is emitted as+-- @define-fun-rec@ and the user takes responsibility for well-definedness. Use this for functions+-- where termination is believed but cannot be proven (e.g., Collatz).+data Measure f where+ AutoMeasure :: Measure f+ HasMeasure :: MeasureEval -> [MeasureHelper] -> Measure f+ HasContract :: MeasureEval -> ContractEval -> [MeasureHelper] -> Measure f+ Productive :: Measure f+ Unverified :: Measure f++-- | A helper axiom for measure verification. When a measure's correctness depends on+-- properties that require induction to prove (e.g., @ifComplexity f > 0@), the user+-- provides these properties along with their proofs. During the measure check, each+-- helper is run: the TP proof is executed to confirm the property holds, and the+-- proven property is asserted as an axiom in the measure verification session.+--+-- Use the 'Data.SBV.TP.measureLemma' smart constructor to create these from TP proofs.+newtype MeasureHelper = MeasureHelper { runMeasureHelper :: SMTConfig -> IO SBool }++-- | Verify that a measure decreases at each recursive call site.+-- Walks the expression DAG to find recursive calls, computes reaching conditions+-- via ITE analysis, and verifies the measure property in a separate solver session.+-- Throws an error with a detailed message if verification fails.+verifyMeasure :: SMTConfig -> String -> LambdaInfo -> MeasureEval -> [MeasureHelper] -> IO ()+verifyMeasure cfg funcNm info meval helpers = do+ -- Run each helper with funcNm added to measuresBeingVerified, preventing re-entrant verification.+ -- This is needed when a measureLemma proof uses the function whose measure is being checked+ -- (e.g., revPreservesLen proves length(rev xs) == length xs, using rev itself).+ let curVerifying = measuresBeingVerified (tpOptions cfg)+ cfg' = cfg{tpOptions = (tpOptions cfg){measuresBeingVerified = Set.insert funcNm curVerifying}}++ debug cfg ["[MEASURE] " ++ funcNm ++ ": verifying with " ++ show (length helpers) ++ " helper(s)"+ ++ if Set.null curVerifying then "" else ", already verifying: " ++ show (Set.toList curVerifying)]+ axioms <- mapM (`runMeasureHelper` cfg') helpers+ debug cfg ["[MEASURE] " ++ funcNm ++ ": " ++ show (length axioms) ++ " helper axiom(s) collected, checking measure"]+ result <- checkMeasure cfg funcNm False info meval axioms+ let prettyNm = prettyFuncNm funcNm+ case result of+ MeasureOK -> pure ()+ MeasureNotNonNeg r -> error $ unlines $+ [ ""+ , "*** Data.SBV: Termination measure is not non-negative."+ , "***"+ , "*** Function: " ++ prettyNm+ , "***"+ ]+ ++ ["*** " ++ l | l <- lines (show r)]+ +++ [ "***"+ , "*** The measure must be non-negative for all inputs."+ ]+ MeasureNotDecreasing r -> error $ unlines $+ [ ""+ , "*** Data.SBV: Termination measure does not strictly decrease at a recursive call site."+ , "***"+ , "*** Function: " ++ prettyNm+ , "***"+ ]+ ++ ["*** " ++ l | l <- lines (show r)]+ +++ [ "***"+ , "*** The measure must strictly decrease at every recursive call."+ ]++-- | Result of checking a measure.+data MeasureCheckResult = MeasureOK -- ^ Measure is valid+ | MeasureNotNonNeg ThmResult -- ^ Measure can be negative+ | MeasureNotDecreasing ThmResult -- ^ Measure doesn't strictly decrease++-- | Check that a measure is valid: non-negative and strictly decreasing at each recursive call.+-- Returns 'MeasureOK' if valid, or the specific failure otherwise.+-- If @skipNonNeg@ is 'True', the non-negativity check is skipped (used for ADT size measures+-- where non-negativity is guaranteed by construction).+-- The @axioms@ list contains additional properties to assert in the verification session+-- (used for user-provided measures that depend on inductively-proven helper properties).+checkMeasure :: SMTConfig -> String -> Bool -> LambdaInfo -> MeasureEval -> [SBool] -> IO MeasureCheckResult+checkMeasure cfgIn funcNm skipNonNeg LambdaInfo{liAssignments, liParams, liOutput, liConsts} (MeasureEval applyM) axioms = do+ let -- Use a separate transcript for the measure check, so it doesn't clobber the main one+ addSuffix s fp = dropExtension fp ++ "_measure_" ++ map (\c -> if c == ' ' then '_' else c) funcNm ++ "_" ++ s ++ takeExtension fp+ cfgNonNeg = cfgIn{transcript = addSuffix "nonNeg" <$> transcript cfgIn}+ cfgDecrease = cfgIn{transcript = addSuffix "decrease" <$> transcript cfgIn}+ barFuncNm = barify funcNm+ recCalls = [(sv, args) | (sv, SBVApp (Uninterpreted nm) args) <- F.toList liAssignments, nm == barFuncNm]++ if null recCalls+ then pure MeasureOK+ else do+ let reachConds = computeReachingConditions liAssignments liOutput+ paramSVs = map snd liParams++ -- Set up the proving environment: create fresh symbolic parameters,+ -- constrain any axioms (which may register function definitions in this+ -- session via the SVal cache mechanism), then replay the function body DAG.+ -- The order matters: axioms must be constrained BEFORE replaying the DAG,+ -- so that replayDAG knows which functions are available in this session.+ mkProveEnv = do+ st <- symbolicEnv+ liftIO $ writeIORef (rSkipMeasureChecks st) True++ let singleParam = length paramSVs == 1+ freshParams <- liftIO $ sequence [svToSV st =<< svMkSymVar (NonQueryVar Nothing) (kindOf sv) (Just (if singleParam then "arg" else "arg" ++ show i)) st+ | (i, sv) <- zip [(0::Int)..] paramSVs+ ]+ freshConsts <- liftIO $ mapM (\(_, cv) -> svToSV st (SVal (kindOf cv) (Left cv))) liConsts++ -- Constrain axioms first: forcing axiom SBools triggers newUninterpreted+ -- for any functions they reference, registering those definitions in this session.+ mapM_ constrain axioms++ -- Now read which functions are actually available in this session+ sessionDefns <- liftIO $ readIORef (rDefns st)+ let sessionFuncs = Map.keysSet sessionDefns++ let constMapping = zip (map fst liConsts) freshConsts+ paramMapping = zip paramSVs freshParams+ initMap = Map.fromList (constMapping ++ paramMapping)+ builtinMap = Map.fromList [(trueSV, trueSV), (falseSV, falseSV)]+ startMap = Map.union initMap builtinMap++ svMap <- liftIO $ replayDAG cfgIn st (Set.singleton barFuncNm) sessionFuncs startMap (F.toList liAssignments)++ let formalSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) freshParams+ mFormal = applyM formalSVals++ pure (svMap, mFormal)++ -- Check 1: Non-negativity (skipped for ADT size measures, which are non-negative by construction)+ nonNegOK <- if skipNonNeg+ then pure (Right ())+ else do nonNegResult <- proveWith cfgNonNeg (do+ (_, mFormal) <- mkProveEnv+ sObserve "measure" (unSBV mFormal)+ pure $ nonNeg mFormal :: Symbolic SBool)+ pure $ case nonNegResult of+ ThmResult Unsatisfiable{} -> Right ()+ _ -> Left nonNegResult++ case nonNegOK of+ Right () -> do+ -- Check 2: Strict decrease at each recursive call+ decResult <- proveWith cfgDecrease (do+ (svMap, mFormal) <- mkProveEnv++ -- When we have axioms from measure helpers that reference the function being+ -- verified (e.g., revPreservesLen references rev), the axioms register the+ -- function definition in this session via the SVal cache mechanism. We then+ -- connect the fresh variables (created by replayDAG for recursive calls) to+ -- actual function calls, so the axioms can reason about them.+ -- For example, the axiom len(rev(xs)) = len(xs) needs to know that fresh_1+ -- is actually rev(as) in order to derive len(fresh_1) = len(as).+ st <- symbolicEnv+ defns <- liftIO $ readIORef (rDefns st)+ let funcRegistered = Map.member barFuncNm defns+ when funcRegistered $+ liftIO $ mapM_ (\(rcSV, callArgSVs) -> do+ let freshSV = Map.findWithDefault rcSV rcSV svMap+ mappedArgs = map (\sv -> Map.findWithDefault sv sv svMap) callArgSVs+ k = kindOf rcSV+ -- Create the actual function call: f(mapped_args)+ actualSV <- newExpr st k (SBVApp (Uninterpreted barFuncNm) mappedArgs)+ -- Assert fresh_var == f(mapped_args)+ let freshSVal = SVal k (Right (cache (const (pure freshSV))))+ actualSVal = SVal k (Right (cache (const (pure actualSV))))+ internalConstraint st False [] (svEqual freshSVal actualSVal)+ ) recCalls++ let singleCall = length recCalls == 1+ mkObligation (i, (rcSV, callArgSVs)) = do+ let mappedArgs = map (\sv -> Map.findWithDefault sv sv svMap) callArgSVs+ argSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) mappedArgs+ mCall = applyM argSVals++ reachSVal = case Map.lookup rcSV reachConds of+ Just conds -> sAnd [ let sv' = Map.findWithDefault condSV condSV svMap+ s = SBV (SVal KBool (Right (cache (\_ -> pure sv'))))+ in if pol then s else sNot s+ | (condSV, pol) <- conds+ ]+ Nothing -> sTrue++ tag nm | singleCall = nm+ | True = nm ++ "[" ++ show (i :: Int) ++ "]"++ sObserve (tag "then") (unSBV mCall)+ pure $ reachSVal .=> mFormal .> mCall++ sObserve "before" (unSBV mFormal)+ obligations <- mapM mkObligation (zip [1..] recCalls)+ pure $ sAnd obligations :: Symbolic SBool)++ case decResult of+ ThmResult Unsatisfiable{} -> pure MeasureOK+ _ -> pure $ MeasureNotDecreasing decResult++ Left nonNegResult -> pure $ MeasureNotNonNeg nonNegResult++-- | Verify a measure with a contract for nested recursive functions.+-- Uses well-founded induction: the inductive hypothesis provides the contract+-- on recursive call results, and we prove both measure decrease and contract simultaneously.+-- One-step unfolding of the function body at each recursive call site gives the solver+-- information about base-case behavior without assuming totality.+verifyMeasureWithContract :: SMTConfig -> String -> LambdaInfo -> MeasureEval -> ContractEval -> [MeasureHelper] -> IO ()+verifyMeasureWithContract cfg funcNm info meval ceval helpers = do+ -- Run helpers with funcNm added to measuresBeingVerified, same as verifyMeasure+ let curVerifying = measuresBeingVerified (tpOptions cfg)+ cfg' = cfg{tpOptions = (tpOptions cfg){measuresBeingVerified = Set.insert funcNm curVerifying}}++ debug cfg ["[MEASURE] " ++ funcNm ++ " (contract): verifying with " ++ show (length helpers) ++ " helper(s)"]+ axioms <- mapM (`runMeasureHelper` cfg') helpers+ debug cfg ["[MEASURE] " ++ funcNm ++ " (contract): " ++ show (length axioms) ++ " helper axiom(s) collected, checking measure+contract"]+ result <- checkMeasureWithContract cfg funcNm False info meval ceval axioms+ let prettyNm = prettyFuncNm funcNm+ case result of+ MeasureOK -> pure ()+ MeasureNotNonNeg r -> error $ unlines $+ [ ""+ , "*** Data.SBV: Termination measure is not non-negative."+ , "***"+ , "*** Function: " ++ prettyNm+ , "***"+ ]+ ++ ["*** " ++ l | l <- lines (show r)]+ +++ [ "***"+ , "*** The measure must be non-negative for all inputs."+ ]+ MeasureNotDecreasing r -> error $ unlines $+ [ ""+ , "*** Data.SBV: Measure+contract verification failed."+ , "***"+ , "*** Function: " ++ prettyNm+ , "***"+ ]+ ++ ["*** " ++ l | l <- lines (show r)]+ +++ [ "***"+ , "*** The measure must strictly decrease at every recursive call,"+ , "*** and the contract must hold for the function's output."+ , "*** The inductive hypothesis provides the contract on recursive call"+ , "*** results for inputs with strictly smaller measure."+ ]++-- | Check a measure with contract: non-negative, strictly decreasing, and contract holds.+-- Uses one-step unfolding at each recursive call site to give the solver base-case behavior,+-- and assumes the inductive hypothesis (contract on recursive call results) to handle+-- nested recursion where a call's argument depends on another call's result.+checkMeasureWithContract :: SMTConfig -> String -> Bool -> LambdaInfo -> MeasureEval -> ContractEval -> [SBool] -> IO MeasureCheckResult+checkMeasureWithContract cfgIn funcNm skipNonNeg LambdaInfo{liAssignments, liParams, liOutput, liConsts} (MeasureEval applyM) (ContractEval applyC) axioms = do+ let addSuffix s fp = dropExtension fp ++ "_measure_" ++ map (\c -> if c == ' ' then '_' else c) funcNm ++ "_" ++ s ++ takeExtension fp+ cfgNonNeg = cfgIn{transcript = addSuffix "nonNeg" <$> transcript cfgIn}+ cfgDecrease = cfgIn{transcript = addSuffix "decrease" <$> transcript cfgIn}+ barFuncNm = barify funcNm+ recCalls = [(sv, args) | (sv, SBVApp (Uninterpreted nm) args) <- F.toList liAssignments, nm == barFuncNm]++ if null recCalls+ then pure MeasureOK+ else do+ -- Non-negativity: same as checkMeasure+ nonNegOK <- if skipNonNeg+ then pure (Right ())+ else do nonNegResult <- proveWith cfgNonNeg (do+ st <- symbolicEnv+ liftIO $ writeIORef (rSkipMeasureChecks st) True++ let singleParam = length paramSVs == 1+ freshParams <- liftIO $ sequence [svToSV st =<< svMkSymVar (NonQueryVar Nothing) (kindOf sv) (Just (if singleParam then "arg" else "arg" ++ show i)) st+ | (i, sv) <- zip [(0::Int)..] paramSVs+ ]+ freshConsts <- liftIO $ mapM (\(_, cv) -> svToSV st (SVal (kindOf cv) (Left cv))) liConsts++ mapM_ constrain axioms+ sessionDefns <- liftIO $ readIORef (rDefns st)+ let sessionFuncs = Map.keysSet sessionDefns++ let constMapping = zip (map fst liConsts) freshConsts+ paramMapping = zip paramSVs freshParams+ initMap = Map.fromList (constMapping ++ paramMapping)+ builtinMap = Map.fromList [(trueSV, trueSV), (falseSV, falseSV)]+ startMap = Map.union initMap builtinMap++ _ <- liftIO $ replayDAG cfgIn st (Set.singleton barFuncNm) sessionFuncs startMap (F.toList liAssignments)++ let formalSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) freshParams+ mFormal = applyM formalSVals++ sObserve "measure" (unSBV mFormal)+ pure $ nonNeg mFormal :: Symbolic SBool)+ pure $ case nonNegResult of+ ThmResult Unsatisfiable{} -> Right ()+ _ -> Left nonNegResult++ case nonNegOK of+ Right () -> do+ -- Decrease + contract check+ decResult <- proveWith cfgDecrease (do+ st <- symbolicEnv+ liftIO $ writeIORef (rSkipMeasureChecks st) True++ let singleParam = length paramSVs == 1+ freshParams <- liftIO $ sequence [svToSV st =<< svMkSymVar (NonQueryVar Nothing) (kindOf sv) (Just (if singleParam then "arg" else "arg" ++ show i)) st+ | (i, sv) <- zip [(0::Int)..] paramSVs+ ]+ freshConsts <- liftIO $ mapM (\(_, cv) -> svToSV st (SVal (kindOf cv) (Left cv))) liConsts++ mapM_ constrain axioms+ sessionDefns <- liftIO $ readIORef (rDefns st)+ let sessionFuncs = Map.keysSet sessionDefns++ let constMapping = zip (map fst liConsts) freshConsts+ paramMapping = zip paramSVs freshParams+ initMap = Map.fromList (constMapping ++ paramMapping)+ builtinMap = Map.fromList [(trueSV, trueSV), (falseSV, falseSV)]+ startMap = Map.union initMap builtinMap++ svMap <- liftIO $ replayDAG cfgIn st (Set.singleton barFuncNm) sessionFuncs startMap (F.toList liAssignments)++ let formalSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) freshParams+ mFormal = applyM formalSVals++ -- One-step unfolding: for each recursive call, replay the function body+ -- with the call's arguments substituted for the formal parameters.+ -- This gives the solver base-case behavior without assuming totality.+ let dagList = F.toList liAssignments+ liftIO $ forM_ recCalls $ \(rcSV, callArgSVs) -> do+ let -- Map the call's arguments through svMap to get the fresh session SVs+ mappedCallArgs = map (\sv -> Map.findWithDefault sv sv svMap) callArgSVs+ -- Build the initial map for the unfolded body: formal params -> call args+ unfoldParamMapping = zip paramSVs mappedCallArgs+ unfoldConstMapping = zip (map fst liConsts) freshConsts+ unfoldInitMap = Map.fromList (unfoldConstMapping ++ unfoldParamMapping)+ unfoldStartMap = Map.union unfoldInitMap builtinMap++ -- Replay the entire function body with the call's args+ unfoldSvMap <- replayDAG cfgIn st (Set.singleton barFuncNm) sessionFuncs unfoldStartMap dagList++ -- The unfolded output SV+ let unfoldedOutputSV = Map.findWithDefault liOutput liOutput unfoldSvMap+ -- The fresh variable that was assigned to this recursive call+ freshCallSV = Map.findWithDefault rcSV rcSV svMap+ -- Assert: fresh_call = unfolded_output+ freshSVal = SVal (kindOf rcSV) (Right (cache (const (pure freshCallSV))))+ unfoldedSVal = SVal (kindOf rcSV) (Right (cache (const (pure unfoldedOutputSV))))+ internalConstraint st False [] (svEqual freshSVal unfoldedSVal)++ -- IH contract: for each recursive call, assume the contract holds on its result.+ -- This is sound because we also prove measure decrease at each call site.+ liftIO $ forM_ recCalls $ \(rcSV, callArgSVs) -> do+ let mappedArgs = map (\sv -> Map.findWithDefault sv sv svMap) callArgSVs+ argSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) mappedArgs+ freshCallSV = Map.findWithDefault rcSV rcSV svMap+ freshResult = SVal (kindOf rcSV) (Right (cache (const (pure freshCallSV))))+ contractHolds = applyC argSVals freshResult+ internalConstraint st False [] (unSBV contractHolds)++ -- Proof obligations:+ -- 1. Measure strictly decreases at each reachable recursive call site+ let reachConds = computeReachingConditions liAssignments liOutput+ singleCall = length recCalls == 1+ mkDecreaseObligation (i, (rcSV, callArgSVs)) = do+ let mappedArgs = map (\sv -> Map.findWithDefault sv sv svMap) callArgSVs+ argSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) mappedArgs+ mCall = applyM argSVals++ reachSVal = case Map.lookup rcSV reachConds of+ Just conds -> sAnd [ let sv' = Map.findWithDefault condSV condSV svMap+ s = SBV (SVal KBool (Right (cache (\_ -> pure sv'))))+ in if pol then s else sNot s+ | (condSV, pol) <- conds+ ]+ Nothing -> sTrue++ tag nm | singleCall = nm+ | True = nm ++ "[" ++ show (i :: Int) ++ "]"++ sObserve (tag "then") (unSBV mCall)+ pure $ reachSVal .=> mFormal .> mCall++ sObserve "before" (unSBV mFormal)+ decreaseObligations <- mapM mkDecreaseObligation (zip [1..] recCalls)++ -- 2. Contract holds for the function's output+ let mappedOutput = Map.findWithDefault liOutput liOutput svMap+ resultSVal = SVal (kindOf liOutput) (Right (cache (const (pure mappedOutput))))+ contractObl = applyC formalSVals resultSVal++ pure $ sAnd decreaseObligations .&& contractObl :: Symbolic SBool)++ case decResult of+ ThmResult Unsatisfiable{} -> pure MeasureOK+ _ -> pure $ MeasureNotDecreasing decResult++ Left nonNegResult -> pure $ MeasureNotNonNeg nonNegResult+ where paramSVs = map snd liParams++-- | Verify that a function marked as productive is guarded-recursive:+-- every recursive call must be a direct argument to a data constructor.+verifyGuardedness :: SMTConfig -> String -> LambdaInfo -> IO ()+verifyGuardedness cfg funcNm info+ | isGuardedRecursive (Set.singleton (barify funcNm)) info+ = debug cfg ["[MEASURE] " ++ funcNm ++ ": productive (all recursive calls are guarded by constructors)"]+ | True+ = error $ unlines+ [ ""+ , "*** Data.SBV: Function marked as productive is not guarded-recursive."+ , "***"+ , "*** Function: " ++ prettyFuncNm funcNm+ , "***"+ , "*** Every recursive call must be a direct argument to a data constructor"+ , "*** (list cons, ADT constructor, etc.) to ensure productivity."+ ]++-- | Check if a recursive function is guarded: every recursive call's result+-- is consumed by a data constructor (list cons, ADT constructor, tuple constructor).+-- This ensures the function is productive — it always makes progress by producing+-- at least one constructor before recursing. The set of barified names covers+-- all functions in the mutual recursion group (or just the function itself for self-recursion).+isGuardedRecursive :: Set.Set String -> LambdaInfo -> Bool+isGuardedRecursive barFuncNms LambdaInfo{liAssignments} = all isGuarded recCallSVs+ where+ dagList = F.toList liAssignments+ recCallSVs = [sv | (sv, SBVApp (Uninterpreted nm) _) <- dagList, nm `Set.member` barFuncNms]++ -- Build a map from SV to the set of operations that consume it+ consumers :: Map.Map SV [(SV, Op)]+ consumers = foldl' addConsumers Map.empty dagList+ where addConsumers m (sv, SBVApp op args) =+ foldl' (\m' a -> Map.insertWith (++) a [(sv, op)] m') m args++ -- A recursive call is guarded if at least one of its consumers is a constructor+ isGuarded sv = case Map.lookup sv consumers of+ Nothing -> False+ Just cons -> any (isConstructorOp . snd) cons++ isConstructorOp (SeqOp SeqConcat{}) = True+ isConstructorOp (ADTOp ADTConstructor{}) = True+ isConstructorOp (TupleConstructor _) = True+ isConstructorOp _ = False++-- | Generate candidate measures based on parameter kinds.+-- For list args, we use @length@. For integer args, we use @abs@. For recursive ADTs, we use @sbv.dt.size@.+-- ADT size measures are tried first (most likely to succeed for structural recursion).+-- If there are multiple scalar candidates, we also try their sum.+-- For two or more scalar candidates, we also try lexicographic (tuple) measures+-- using all pairs and triples, which handles functions like Ackermann that+-- decrease lexicographically.+guessMeasures :: [(Quantifier, SV)] -> [(String, MeasureEval, Maybe Int)]+guessMeasures params = map (\(d, f, mi) -> (d, MeasureEval f, mi)) (adtSingles ++ otherSingles ++ summed) ++ lexPairs ++ lexTriples+ where+ singles :: [(String, [SVal] -> SInteger, Maybe Int)]+ singles = concatMap mkCandidates (zip [0..] params)++ -- ADT size measures are most likely to succeed for ADT-recursive functions, so try them first+ (adtSingles, otherSingles) = partition (\(_, _, mi) -> isJust mi) singles++ mkCandidates :: (Int, (Quantifier, SV)) -> [(String, [SVal] -> SInteger, Maybe Int)]+ mkCandidates (i, (_, sv)) = case kindOf sv of+ KList elemK -> [("length arg" ++ show (i+1), \svs ->+ let listSVal = svs !! i+ in SBV $ SVal KUnbounded $ Right $ cache $ \st -> do+ s <- sbvToSV st (SBV listSVal)+ newExpr st KUnbounded (SBVApp (SeqOp (SeqLen elemK)) [s]), Nothing)]++ -- Strings are sequences of characters in SMTLib+ KString -> [("length arg" ++ show (i+1), \svs ->+ let strSVal = svs !! i+ in SBV $ SVal KUnbounded $ Right $ cache $ \st -> do+ s <- sbvToSV st (SBV strSVal)+ newExpr st KUnbounded (SBVApp (SeqOp (SeqLen KChar)) [s]), Nothing)]++ -- Unbounded integers: try abs and smax 0 as measures+ KUnbounded -> [ ("abs arg" ++ show (i+1), \svs -> abs (SBV (svs !! i)), Nothing)+ , ("smax 0 arg" ++ show (i+1), \svs -> 0 `smax` SBV (svs !! i), Nothing)+ ]++ -- Bounded bitvectors: cast to Integer for the measure. Unsigned values are+ -- already non-negative; signed values need abs to ensure non-negativity.+ KBounded False _ -> [("arg" ++ show (i+1), \svs -> SBV (svFromIntegral KUnbounded (svs !! i)), Nothing)]+ KBounded True _ -> [("abs arg" ++ show (i+1), \svs -> abs (SBV (svFromIntegral KUnbounded (svs !! i))), Nothing)]++ KTuple ks -> concatMap (mkTupleComponent i (length ks)) (zip [1..] ks)+ KADT adtName _ ctors+ | any (any (isRecKind adtName) . snd) ctors ->+ let sizeName = "sbv.dt.size." ++ adtName+ adtKind = kindOf sv+ in [(sizeName ++ " arg" ++ show (i+1), \svs ->+ SBV $ SVal KUnbounded $ Right $ cache $ \st -> do+ ensureADTSizeDefined st sizeName adtKind ctors+ s <- sbvToSV st (SBV (svs !! i))+ newExpr st KUnbounded (SBVApp (Uninterpreted sizeName) [s]), Just i)]+ _ -> []++ mkTupleComponent :: Int -> Int -> (Int, Kind) -> [(String, [SVal] -> SInteger, Maybe Int)]+ mkTupleComponent argIdx nFields (compIdx, compKind) = case compKind of+ KList elemK -> [("length arg" ++ show (argIdx+1) ++ "._" ++ show compIdx, \svs ->+ let comp = SBV $ SVal compKind $ Right $ cache $ \st -> do+ tupSV <- sbvToSV st (SBV (svs !! argIdx))+ newExpr st compKind (SBVApp (TupleAccess compIdx nFields) [tupSV])+ in SBV $ SVal KUnbounded $ Right $ cache $ \st -> do+ s <- sbvToSV st comp+ newExpr st KUnbounded (SBVApp (SeqOp (SeqLen elemK)) [s]), Nothing)]+ KUnbounded -> [("abs arg" ++ show (argIdx+1) ++ "._" ++ show compIdx, \svs ->+ abs $ SBV $ SVal KUnbounded $ Right $ cache $ \st -> do+ tupSV <- sbvToSV st (SBV (svs !! argIdx))+ newExpr st KUnbounded (SBVApp (TupleAccess compIdx nFields) [tupSV]), Nothing)]+ _ -> []++ summed | length singles > 1 = [( intercalate " + " [d | (d, _, _) <- singles]+ , \svs -> sum [f svs | (_, f, _) <- singles]+ , Nothing+ )]+ | True = []++ -- Lexicographic pair measures: try all ordered pairs from the scalar candidates+ lexPairs :: [(String, MeasureEval, Maybe Int)]+ lexPairs+ | length singles < 2 = []+ | True = [ ( "(" ++ d1 ++ ", " ++ d2 ++ ")"+ , MeasureEval (\svs -> mkPair (f1 svs) (f2 svs))+ , Nothing+ )+ | (d1, f1, _) <- singles+ , (d2, f2, _) <- singles+ , d1 /= d2+ ]++ -- Lexicographic triple measures: try all ordered triples from the scalar candidates+ lexTriples :: [(String, MeasureEval, Maybe Int)]+ lexTriples+ | length singles < 3 = []+ | True = [ ( "(" ++ d1 ++ ", " ++ d2 ++ ", " ++ d3 ++ ")"+ , MeasureEval (\svs -> mkTriple (f1 svs) (f2 svs) (f3 svs))+ , Nothing+ )+ | (d1, f1, _) <- singles+ , (d2, f2, _) <- singles+ , d1 /= d2+ , (d3, f3, _) <- singles+ , d1 /= d3, d2 /= d3+ ]++ -- Build an SBV (Integer, Integer) from two SIntegers+ mkPair :: SInteger -> SInteger -> SBV (Integer, Integer)+ mkPair a b = SBV $ SVal (KTuple [KUnbounded, KUnbounded]) $ Right $ cache $ \st -> do+ sa <- sbvToSV st a+ sb <- sbvToSV st b+ newExpr st (KTuple [KUnbounded, KUnbounded]) (SBVApp (TupleConstructor 2) [sa, sb])++ -- Build an SBV (Integer, Integer, Integer) from three SIntegers+ mkTriple :: SInteger -> SInteger -> SInteger -> SBV (Integer, Integer, Integer)+ mkTriple a b c = SBV $ SVal (KTuple [KUnbounded, KUnbounded, KUnbounded]) $ Right $ cache $ \st -> do+ sa <- sbvToSV st a+ sb <- sbvToSV st b+ sc <- sbvToSV st c+ newExpr st (KTuple [KUnbounded, KUnbounded, KUnbounded]) (SBVApp (TupleConstructor 3) [sa, sb, sc])++-- | Check if a kind refers back to a given ADT name (i.e., is a recursive field).+-- Recursive fields in constructor kinds use 'KApp', not 'KADT'.+isRecKind :: String -> Kind -> Bool+isRecKind adtName (KApp n _) = n == adtName+isRecKind adtName (KADT n _ _) = n == adtName+isRecKind _ _ = False++-- | Ensure that an ADT size function is defined in the given state. The size function+-- maps ADT values to non-negative integers, returning 0 for base constructors and+-- @1 + sum(sizes of recursive fields)@ for recursive constructors.+-- This is used as a termination measure for functions that recurse on ADT values.+ensureADTSizeDefined :: State -> String -> Kind -> [(String, [Kind])] -> IO ()+ensureADTSizeDefined st sizeName adtKind ctors = do+ defs <- readIORef (rDefns st)+ unless (Map.member sizeName defs) $ do+ let argNm = "x"+ smtArgType = smtType adtKind++ -- Build the SMT-Lib body for the size function+ body = buildBody ctors++ buildBody [] = "0"+ buildBody [c] = caseExpr c+ buildBody (c:cs) = "(ite " ++ testerExpr c ++ " " ++ caseExpr c ++ " " ++ buildBody cs ++ ")"++ testerExpr (cName, _) = "(is-" ++ cName ++ " " ++ argNm ++ ")"++ caseExpr (cName, flds) =+ let recIdxs = [j | (j, k) <- zip [1::Int ..] flds, isRecKind (adtNameOf adtKind) k]+ in if null recIdxs+ then "0"+ else let recCalls = ["(" ++ sizeName ++ " (get" ++ cName ++ "_" ++ show j ++ " " ++ argNm ++ "))" | j <- recIdxs]+ in "(+ 1 " ++ smtSum recCalls ++ ")"++ smtSum [x] = x+ smtSum (x:xs) = "(+ " ++ x ++ " " ++ smtSum xs ++ ")"+ smtSum [] = "0"++ paramStr = "((" ++ argNm ++ " " ++ smtArgType ++ "))"+ smtDef = SMTDef KUnbounded [sizeName] (Just paramStr) (\n -> replicate n ' ' ++ body)+ sbvTy = SBVType [adtKind, KUnbounded]++ modifyIORef' (rDefns st) (Map.insert sizeName (smtDef, sbvTy))+ modifyState st rUIMap (Map.insert sizeName (True, Nothing, sbvTy)) (pure ())++-- | Extract the ADT name from a KADT kind.+adtNameOf :: Kind -> String+adtNameOf (KADT n _ _) = n+adtNameOf _ = ""++-- | Check if a function is structurally recursive on a given parameter.+-- Returns 'True' if every recursive call passes a strict sub-term of the+-- formal parameter (obtained via one or more 'ADTAccessor' operations) as+-- the argument at that parameter position. Structural recursion on an ADT+-- guarantees termination by the well-foundedness of the datatype, so the+-- measure check can be skipped.+isStructurallyDecreasing :: String -> LambdaInfo -> Int -> Bool+isStructurallyDecreasing funcNm LambdaInfo{liAssignments, liParams} paramIdx =+ not (null recCalls) && all checkCall recCalls+ where+ barFuncNm = barify funcNm+ paramSV = snd (liParams !! paramIdx)+ asgns = F.toList liAssignments+ defMap = Map.fromList asgns++ recCalls = [args | (_, SBVApp (Uninterpreted nm) args) <- asgns, nm == barFuncNm]++ checkCall callArgs+ | paramIdx < length callArgs = isProperSubTerm (callArgs !! paramIdx)+ | True = False++ -- An SV is a proper sub-term of the parameter if it is obtained by applying+ -- one or more ADTAccessor operations to the parameter.+ isProperSubTerm sv = case Map.lookup sv defMap of+ Just (SBVApp (ADTOp (ADTAccessor _ _)) [parent]) ->+ parent == paramSV || isProperSubTerm parent+ _ -> False++-- | Try to auto-guess a termination measure for a recursive function. Generates candidates+-- based on parameter kinds and tries each one. Returns the first measure that passes both+-- non-negativity and strict decrease checks, or 'Nothing' if no guess works.+autoGuess :: SMTConfig -> String -> LambdaInfo -> IO (Maybe MeasureEval)+autoGuess cfg funcNm info = do+ let barFuncNm = barify funcNm+ recCalls = [(sv, args) | (sv, SBVApp (Uninterpreted nm) args) <- F.toList (liAssignments info), nm == barFuncNm]+ allUIs = [(nm, length args) | (_, SBVApp (Uninterpreted nm) args) <- F.toList (liAssignments info)]+ debug cfg ["[MEASURE] " ++ funcNm ++ ": barified = " ++ show barFuncNm]+ debug cfg ["[MEASURE] " ++ funcNm ++ ": Uninterpreted ops in DAG: " ++ show allUIs]+ debug cfg ["[MEASURE] " ++ funcNm ++ ": recursive calls found = " ++ show (length recCalls)]+ go candidates+ where+ candidates = guessMeasures (liParams info)+ go [] = pure Nothing+ go ((desc, m, mbIdx):ms) = do let skipNonNeg = "sbv.dt.size." `isPrefixOf` desc+ debug cfg ["[MEASURE] " ++ funcNm ++ ": trying " ++ desc]+ -- For ADT size measures, try syntactic sub-term check first.+ -- This avoids calling the solver, which can hang on recursive+ -- define-fun-rec definitions.+ result <- case mbIdx of+ Just idx | isStructurallyDecreasing funcNm info idx -> do+ debug cfg ["[MEASURE] " ++ funcNm ++ ": " ++ desc ++ " -> OK (structural recursion)"]+ pure MeasureOK+ _ -> checkMeasure cfg funcNm skipNonNeg info m []+ case result of+ MeasureOK -> do debug cfg ["[MEASURE] " ++ funcNm ++ ": " ++ desc ++ " -> OK"]+ pure (Just m)+ MeasureNotNonNeg r -> do debug cfg ["[MEASURE] " ++ funcNm ++ ": " ++ desc ++ " failed non-negativity: " ++ show r]+ debug cfg ["[MEASURE] " ++ funcNm ++ ": trying next candidate.."]+ go ms+ MeasureNotDecreasing r -> do debug cfg ["[MEASURE] " ++ funcNm ++ ": " ++ desc ++ " failed strict decrease: " ++ show r]+ debug cfg ["[MEASURE] " ++ funcNm ++ ": trying next candidate.."]+ go ms++-- | Auto-guess a termination measure, or fail with a helpful error message.+autoGuessOrFail :: SMTConfig -> String -> LambdaInfo -> IO ()+autoGuessOrFail cfg funcNm info = do+ mbMeasure <- autoGuess cfg funcNm info+ case mbMeasure of+ Just _ -> pure ()+ Nothing -> error $ unlines $+ [ ""+ , "*** Data.SBV: Cannot determine a termination measure."+ , "***"+ , "*** Function: " ++ prettyFuncNm funcNm+ ]+ ++ guessLines+ +++ [ "***"+ , "*** Please use 'smtFunctionWithMeasure' to provide an explicit measure."+ ]+ where candidates = guessMeasures (liParams info)+ guessLines+ | null candidates = [ "***"+ , "*** No measure candidates could be derived from the argument types."+ ]+ | True = [ "***"+ , "*** Measures tried:"+ ]+ ++ [ "*** " ++ d | (d, _, _) <- candidates]++-- | Check mutual recursion for a function by computing the SCC from State.+-- This is called as a deferred closure from rMeasureChecks. It computes the SCC+-- of the function graph, finds the group containing the given function, and+-- verifies the whole group if it's a multi-member cycle. Multiple members of the+-- same group may register this check, but only the first execution does work;+-- after successful verification, verified members are removed from rFuncLambdaInfos,+-- so subsequent closures find insufficient infos and skip.+--+-- The optional t'MeasureEval' is a user-provided measure (from 'smtFunctionWithMeasure').+-- If given, it is tried first before falling back to auto-guessing.+checkMutualFromState :: SMTConfig -> String -> State -> Maybe MeasureEval -> IO ()+checkMutualFromState cfg funcNm st mbMeasure = do+ defns <- readIORef (rDefns st)+ funcInfos <- readIORef (rFuncLambdaInfos st)++ let barFuncNm = barify funcNm+ nodes = [(nm, nm, deps) | (nm, (SMTDef _ deps _ _, _)) <- Map.toList defns]+ sccs = DG.stronglyConnComp nodes++ -- Find the SCC containing our function (using barified name since rDefns keys are barified)+ mySCC = [members | DG.CyclicSCC members <- sccs, barFuncNm `elem` members]++ case mySCC of+ [members] | length members >= 2 -> do+ -- rFuncLambdaInfos uses plain names, so unbar the SCC member names for lookup.+ -- Build the infos map with plain names as keys (matching rFuncLambdaInfos convention).+ let plainMembers = map unBar members+ infos = Map.fromList [(pnm, v) | pnm <- plainMembers, Just v <- [Map.lookup pnm funcInfos]]+ if Map.size infos >= 2+ then do checkMutualGroup cfg infos mbMeasure+ -- Remove verified members from rFuncLambdaInfos so that subsequent closures+ -- for the same group (registered by other members) find insufficient infos and skip.+ modifyIORef' (rFuncLambdaInfos st) (\m -> foldl' (flip Map.delete) m plainMembers)+ else do debug cfg ["[MEASURE] " ++ funcNm ++ ": mutual group already verified, skipping"]+ modifyIORef' (rFuncLambdaInfos st) (Map.delete funcNm)+ _ -> do debug cfg ["[MEASURE] " ++ funcNm ++ ": not in a multi-member cycle, skipping mutual check"]+ modifyIORef' (rFuncLambdaInfos st) (Map.delete funcNm)++-- | Reject mutual recursion for contract-based functions. Deferred to SCC computation time+-- so that non-mutual cross-refs (helper functions, uninterpreted constants) don't cause false positives.+rejectMutualContractFromState :: SMTConfig -> String -> State -> IO ()+rejectMutualContractFromState cfg funcNm st = do+ defns <- readIORef (rDefns st)++ let barFuncNm = barify funcNm+ nodes = [(nm, nm, deps) | (nm, (SMTDef _ deps _ _, _)) <- Map.toList defns]+ sccs = DG.stronglyConnComp nodes+ mySCC = [members | DG.CyclicSCC members <- sccs, barFuncNm `elem` members]++ case mySCC of+ [members] | length members >= 2 ->+ error $ unlines [ ""+ , "*** Data.SBV: smtFunctionWithContract does not support mutual recursion."+ , "***"+ , "*** Function: " ++ prettyFuncNm funcNm+ , "***"+ , "*** Please use smtFunction or smtFunctionWithMeasure for mutual recursion groups."+ , ""+ ]+ _ -> debug cfg ["[MEASURE] " ++ funcNm ++ ": not in a multi-member cycle, skipping mutual contract check"]++-- | Check that all members of a mutual recursion group marked as productive are guarded-recursive,+-- considering cross-calls as well as self-calls.+checkMutualProductiveFromState :: SMTConfig -> String -> State -> IO ()+checkMutualProductiveFromState cfg funcNm st = do+ defns <- readIORef (rDefns st)+ funcInfos <- readIORef (rFuncLambdaInfos st)++ let barFuncNm = barify funcNm+ nodes = [(nm, nm, deps) | (nm, (SMTDef _ deps _ _, _)) <- Map.toList defns]+ sccs = DG.stronglyConnComp nodes+ mySCC = [members | DG.CyclicSCC members <- sccs, barFuncNm `elem` members]++ case mySCC of+ [members] | length members >= 2 -> do+ let plainMembers = map unBar members+ infos = Map.fromList [(pnm, v) | pnm <- plainMembers, Just v <- [Map.lookup pnm funcInfos]]+ if Map.size infos >= 2+ then do let barNames = Set.fromList members+ memberNamesStr = intercalate ", " (map prettyFuncNm plainMembers)+ debug cfg ["[MEASURE] Checking mutual productive group: {" ++ memberNamesStr ++ "}"]+ let failed = [(pnm, info) | (pnm, info) <- Map.toList infos, not (isGuardedRecursive barNames info)]+ case failed of+ [] -> do debug cfg ["[MEASURE] Mutual productive group: all members are guarded"]+ modifyIORef' (rFuncLambdaInfos st) (\m -> foldl' (flip Map.delete) m plainMembers)+ _ -> error $ unlines $+ [ ""+ , "*** Data.SBV: Mutual productive group has unguarded recursive calls."+ , "***"+ ]+ ++ groupLines (Map.toList infos)+ +++ [ "*** Unguarded: " ++ intercalate ", " (map (prettyFuncNm . fst) failed)+ , "***"+ , "*** Every recursive call (self or cross) must be a direct argument to a data constructor."+ , ""+ ]+ else do debug cfg ["[MEASURE] " ++ funcNm ++ ": mutual productive group already verified, skipping"]+ modifyIORef' (rFuncLambdaInfos st) (Map.delete funcNm)+ _ -> do debug cfg ["[MEASURE] " ++ funcNm ++ ": not in a multi-member cycle, skipping mutual productive check"]+ modifyIORef' (rFuncLambdaInfos st) (Map.delete funcNm)++-- | Check termination for a mutual recursion group. Each function in the group+-- gets an auto-guessed measure, and we verify that at every call edge (self or cross),+-- the caller's measure at formal parameters strictly exceeds the callee's measure at actual arguments.+--+-- If a user-provided measure is given ('Just'), it is tried first before auto-guessing.+checkMutualGroup :: SMTConfig -> Map.Map String LambdaInfo -> Maybe MeasureEval -> IO ()+checkMutualGroup cfg members mbMeasure = do+ let memberNames = Map.keys members+ memberNamesStr = intercalate ", " (map prettyFuncNm memberNames)+ debug cfg ["[MEASURE] Checking mutual recursion group: {" ++ memberNamesStr ++ "}"]++ -- If a user-provided measure is given, try it first+ let memberList = Map.toList members+ userOK <- case mbMeasure of+ Nothing -> pure False+ Just m -> do+ debug cfg ["[MEASURE] Mutual group: trying user-provided measure for all members"]+ ok <- checkMutualMeasure cfg memberList m+ if ok+ then do debug cfg ["[MEASURE] Mutual group: user-provided measure works for all members"]+ pure True+ else do debug cfg ["[MEASURE] Mutual group: user-provided measure failed, falling back to auto-guess"]+ pure False++ unless userOK $ do+ -- Auto-guess: for each function, generate measure candidates+ let memberCandidates = [(nm, info, guessMeasures (liParams info)) | (nm, info) <- memberList]++ -- Check if any member has no candidates at all+ case [(nm, info) | (nm, info, []) <- memberCandidates] of+ (nm, _):_ -> error $ unlines $+ [ ""+ , "*** Data.SBV: Cannot determine a termination measure for mutual recursion group."+ , "***"+ ]+ ++ groupLines memberList+ +++ [ "*** Function with no measure candidates: " ++ prettyFuncNm nm+ , "***"+ , if isJust mbMeasure+ then "*** The user-provided measure did not work, and no auto-guess candidates are available."+ else "*** Please use 'smtFunctionWithMeasure' to provide explicit measures."+ ]+ [] -> pure ()++ -- Try to find a working combination. For efficiency, when all members have the same+ -- parameter kinds, we try the same candidate for all. Otherwise we try combinations.+ let allCandidateLists = [(nm, info, cs) | (nm, info, cs) <- memberCandidates]+ tryMeasures allCandidateLists++ where+ tryMeasures :: [(String, LambdaInfo, [(String, MeasureEval, Maybe Int)])] -> IO ()+ tryMeasures memberInfos = do+ -- Collect all unique candidates from all members (by description).+ -- Different members may have different parameter kinds, yielding different candidates.+ let allCandidates = nubBy (\(d1,_,_) (d2,_,_) -> d1 == d2)+ $ concatMap (\(_, _, cs) -> cs) memberInfos++ result <- go allCandidates+ case result of+ Just _ -> pure ()+ Nothing -> do+ error $ unlines $+ [ ""+ , "*** Data.SBV: Cannot determine a termination measure for mutual recursion group."+ , "***"+ ]+ ++ groupLines (Map.toList members)+ +++ [ "***"+ , if isJust mbMeasure+ then "*** The user-provided measure did not work, and auto-guessing also failed."+ else "*** Please use 'smtFunctionWithMeasure' to provide explicit measures."+ ]++ where+ go [] = pure Nothing+ go ((desc, m, _mbIdx):rest) = do+ debug cfg ["[MEASURE] Mutual group: trying measure " ++ desc ++ " for all members"]+ -- Try the same measure for all members. Catch exceptions from kind mismatches+ -- (e.g., applying abs to a list parameter) and treat them as failure.+ let memberList = [(nm, info) | (nm, info, _) <- memberInfos]+ result <- C.try $ checkMutualMeasure cfg memberList m+ case result of+ Right True -> do debug cfg ["[MEASURE] Mutual group: measure " ++ desc ++ " works for all members"]+ pure (Just m)+ Right False -> do debug cfg ["[MEASURE] Mutual group: measure " ++ desc ++ " failed, trying next"]+ go rest+ Left (e :: C.SomeException) -> do+ debug cfg ["[MEASURE] Mutual group: measure " ++ desc ++ " incompatible: " ++ show e]+ go rest++-- | Verify that a given measure works for all functions in a mutual recursion group.+-- Uses the same measure for all members. For each function f, check that at every call+-- site to any function g in the group, measure(f's formals) > measure(g's actuals).+checkMutualMeasure :: SMTConfig -> [(String, LambdaInfo)] -> MeasureEval -> IO Bool+checkMutualMeasure cfgIn members (MeasureEval applyM) = go members+ where+ -- Set of barified names of all group members+ groupBarNames = Set.fromList [barify nm | (nm, _) <- members]++ go [] = pure True+ go ((funcNm, LambdaInfo{liAssignments, liParams, liOutput, liConsts}):rest) = do+ -- Find all calls to any member of the mutual group+ let allGroupCalls = [(sv, args)+ | (sv, SBVApp (Uninterpreted calleeNm) args) <- F.toList liAssignments+ , calleeNm `Set.member` groupBarNames+ ]++ if null allGroupCalls+ then go rest -- No calls to group members, no decrease needed+ else do+ let addSuffix s fp = dropExtension fp ++ "_measure_" ++ map (\c -> if c == ' ' then '_' else c) funcNm ++ "_" ++ s ++ takeExtension fp+ cfgDecrease = cfgIn{transcript = addSuffix "mutual_decrease" <$> transcript cfgIn}+ cfgNonNeg = cfgIn{transcript = addSuffix "mutual_nonNeg" <$> transcript cfgIn}+ paramSVs = map snd liParams+ reachConds = computeReachingConditions liAssignments liOutput++ mkProveEnv = do+ st <- symbolicEnv+ liftIO $ writeIORef (rSkipMeasureChecks st) True+ let singleParam = length paramSVs == 1+ freshParams <- liftIO $ sequence+ [svToSV st =<< svMkSymVar (NonQueryVar Nothing) (kindOf sv)+ (Just (if singleParam then "arg" else "arg" ++ show i)) st+ | (i, sv) <- zip [(0::Int)..] paramSVs+ ]+ freshConsts <- liftIO $ mapM (\(_, cv) -> svToSV st (SVal (kindOf cv) (Left cv))) liConsts+ sessionDefns <- liftIO $ readIORef (rDefns st)+ let sessionFuncs = Map.keysSet sessionDefns+ constMapping = zip (map fst liConsts) freshConsts+ paramMapping = zip paramSVs freshParams+ initMap = Map.fromList (constMapping ++ paramMapping)+ builtinMap = Map.fromList [(trueSV, trueSV), (falseSV, falseSV)]+ startMap = Map.union initMap builtinMap+ svMap <- liftIO $ replayDAG cfgIn st groupBarNames sessionFuncs startMap (F.toList liAssignments)+ let formalSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) freshParams+ mFormal = applyM formalSVals+ pure (svMap, mFormal)++ -- Check 1: Non-negativity of caller's measure+ nonNegResult <- proveWith cfgNonNeg (do+ (_, mFormal) <- mkProveEnv+ sObserve "measure" (unSBV mFormal)+ pure $ nonNeg mFormal :: Symbolic SBool)++ case nonNegResult of+ ThmResult Unsatisfiable{} -> do+ -- Check 2: Strict decrease at each call site+ decResult <- proveWith cfgDecrease (do+ (svMap, mFormal) <- mkProveEnv+ let singleCall = length allGroupCalls == 1+ mkObligation (i, (rcSV, callArgSVs)) = do+ let mappedArgs = map (\sv -> Map.findWithDefault sv sv svMap) callArgSVs+ argSVals = map (\sv -> SVal (kindOf sv) (Right (cache (\_ -> pure sv)))) mappedArgs+ mCall = applyM argSVals+ reachSVal = case Map.lookup rcSV reachConds of+ Just conds -> sAnd [ let sv' = Map.findWithDefault condSV condSV svMap+ s = SBV (SVal KBool (Right (cache (\_ -> pure sv'))))+ in if pol then s else sNot s+ | (condSV, pol) <- conds+ ]+ Nothing -> sTrue+ tag nm | singleCall = nm+ | True = nm ++ "[" ++ show (i :: Int) ++ "]"+ sObserve (tag "then") (unSBV mCall)+ pure $ reachSVal .=> mFormal .> mCall+ sObserve "before" (unSBV mFormal)+ obligations <- mapM mkObligation (zip [1..] allGroupCalls)+ pure $ sAnd obligations :: Symbolic SBool)+ case decResult of+ ThmResult Unsatisfiable{} -> do+ debug cfgIn ["[MEASURE] Mutual group: decrease verified for " ++ funcNm]+ go rest+ _ -> do+ debug cfgIn ["[MEASURE] Mutual group: decrease failed for " ++ funcNm ++ ": " ++ show decResult]+ pure False+ _ -> do+ debug cfgIn ["[MEASURE] Mutual group: non-negativity failed for " ++ funcNm]+ pure False++-- | Pretty-print a function name: turn @"insert @(SBV Integer -> SBV [Integer])"@ into @"insert :: SBV Integer -> SBV [Integer]"@+prettyFuncNm :: String -> String+prettyFuncNm m = case break (== '@') m of+ (nm, '@':'(':tp) | not (null tp) -> dropWhileEnd (== ' ') nm ++ " :: " ++ init tp+ _ -> m++-- | Format group members on separate lines, aligned on @::@.+groupLines :: [(String, LambdaInfo)] -> [String]+groupLines ms = case map (prettyFuncNm . fst) ms of+ [] -> []+ names -> let parts = [(nm, tp) | n <- names, let (nm, tp) = case break (== ':') n of+ (a, ':':':':b) -> (dropWhileEnd (== ' ') a, " ::" ++ b)+ _ -> (n, "")]+ maxNm = maximum (map (length . fst) parts)+ pad s = s ++ replicate (maxNm - length s) ' '+ fmt (n, t) = "*** " ++ pad n ++ " " ++ t+ in map fmt parts++-- | Replay the DAG in a new state, building up an SV mapping from old to new.+-- Recursive calls to the functions being verified are replaced with fresh variables.+-- Calls to other DEFINED functions (present in the parent state's rDefns) are replayed as actual calls.+-- All other Uninterpreted references (uninterpreted constants, free functions, sentinels)+-- are replaced with fresh variables since they aren't defined in the fresh proveWith session.+replayDAG :: SMTConfig -> State -> Set.Set String -> Set.Set String -> Map.Map SV SV -> [(SV, SBVExpr)] -> IO (Map.Map SV SV)+replayDAG cfg st recFuncNames definedFuncs startMap dag = do+ let n = length dag+ let nms = intercalate ", " (map unBar (Set.toList recFuncNames))+ debug cfg ["[MEASURE] replayDAG {" ++ nms ++ "}: replaying " ++ show n ++ " node(s)"]+ go startMap dag+ where -- Map an SV through the svMap. If it's not found, it's an external captured variable+ -- (e.g., from a higher-order function's closure). Create a fresh unconstrained variable+ -- for it to avoid leaking foreign-context SVals into the current state.+ mapArg svMap a = case Map.lookup a svMap of+ Just a' -> pure (a', svMap)+ Nothing -> do fresh <- newInternalVariable st (kindOf a)+ pure (fresh, Map.insert a fresh svMap)++ mapArgs svMap [] = pure ([], svMap)+ mapArgs svMap (a:as) = do (a', svMap') <- mapArg svMap a+ (as', svMap'') <- mapArgs svMap' as+ pure (a':as', svMap'')++ go svMap [] = pure svMap+ go svMap ((sv, expr):rest) = do+ let SBVApp op args = expr+ (mappedArgs, svMap') <- mapArgs svMap args+ newSV' <- case op of+ -- For recursive calls (self or mutual), create a fresh uninterpreted value instead of replaying+ Uninterpreted nm | nm `Set.member` recFuncNames -> newInternalVariable st (kindOf sv)+ -- For calls to other defined functions (e.g., partition), replay properly+ Uninterpreted nm | nm `Set.member` definedFuncs -> do+ let mappedOp = mapOpSVs (\a -> Map.findWithDefault a a svMap') op+ newExpr st (kindOf sv) (SBVApp mappedOp mappedArgs)+ -- For everything else that's Uninterpreted (free functions, sentinels, etc.),+ -- create fresh values since they aren't defined in the proveWith session+ Uninterpreted{} -> newInternalVariable st (kindOf sv)+ -- For all other operations (arithmetic, list ops, etc.), replay properly+ _ -> do let mappedOp = mapOpSVs (\a -> Map.findWithDefault a a svMap') op+ newExpr st (kindOf sv) (SBVApp mappedOp mappedArgs)+ go (Map.insert sv newSV' svMap') rest++-- | Map any SVs embedded directly in an Op (e.g., in LkUp, FP_Cast)+mapOpSVs :: (SV -> SV) -> Op -> Op+mapOpSVs f (LkUp p sv1 sv2) = LkUp p (f sv1) (f sv2)+mapOpSVs f (IEEEFP (FP_Cast fk tk sv)) = IEEEFP (FP_Cast fk tk (f sv))+mapOpSVs _ (ArrayInit (Right (SMTLambda s))) = ArrayInit (Right (SMTLambda s)) -- Lambda strings don't contain SVs to map+mapOpSVs _ op = op++-- | Compute the reaching condition for each SV: under what boolean condition+-- does the SV's value contribute to the output? Propagates conditions top-down+-- through ITE, AND, and OR nodes. Each reaching condition is a list of+-- @(condSV, polarity)@ pairs; the actual condition is the conjunction: for each+-- pair, @condSV@ if polarity is 'True', @not condSV@ if polarity is 'False'.+computeReachingConditions :: Seq.Seq (SV, SBVExpr) -> SV -> Map.Map SV [(SV, Bool)]+computeReachingConditions asgns outSV = go initMap (reverse $ F.toList asgns)+ where+ -- The output's reaching condition is True (empty conjunction)+ initMap = Map.singleton outSV []++ go condMap [] = condMap+ go condMap ((sv, SBVApp op args) : rest) =+ case Map.lookup sv condMap of+ Nothing -> go condMap rest -- This SV doesn't contribute to the output+ Just rc ->+ let condMap' = case (op, args) of+ (Ite, [c, t, e]) ->+ let condMapT = addReach t ((c, True) : rc) condMap+ condMapE = addReach e ((c, False) : rc) condMapT+ in condMapE+ -- For AND: each arg is only relevant when the other is True+ (And, [a, b]) ->+ let condMapA = addReach a ((b, True) : rc) condMap+ condMapB = addReach b ((a, True) : rc) condMapA+ in condMapB+ -- For OR: each arg is only relevant when the other is False+ (Or, [a, b]) ->+ let condMapA = addReach a ((b, False) : rc) condMap+ condMapB = addReach b ((a, False) : rc) condMapA+ in condMapB+ _ -> foldl' (\m a -> addReach a rc m) condMap args+ in go condMap' rest++ -- Add a reaching condition to an SV. For shared nodes, keep the first condition found+ -- (most direct path from the output).+ addReach sv rc m = Map.insertWith (\_ old -> old) sv rc m++-- | Regular expressions can be compared for equality. Note that we diverge here from the equality+-- in the concrete sense; i.e., the Eq instance does not match the symbolic case. This is a bit unfortunate,+-- but unavoidable with the current design of how we "distinguish" operators. Hopefully shouldn't be a big deal,+-- though one should be careful.+instance EqSymbolic RegExp where+ r1 .== r2 = SBV $ SVal KBool $ Right $ cache r+ where r st = newExpr st KBool $ SBVApp (RegExOp (RegExEq r1 r2)) []++ r1 ./= r2 = SBV $ SVal KBool $ Right $ cache r+ where r st = newExpr st KBool $ SBVApp (RegExOp (RegExNEq r1 r2)) []++-- | Symbolic Numbers. This is a simple class that simply incorporates all number like+-- base types together, simplifying writing polymorphic type-signatures that work for all+-- symbolic numbers, such as 'SWord8', 'SInt8' etc. For instance, we can write a generic+-- list-minimum function as follows:+--+-- @+-- mm :: SIntegral a => [SBV a] -> SBV a+-- mm = foldr1 (\a b -> ite (a .<= b) a b)+-- @+--+-- It is similar to the standard 'Integral' class, except ranging over symbolic instances.+class (SymVal a, Num a, Num (SBV a), Bits a, Integral a) => SIntegral a++-- 'SIntegral' Instances, skips Real/Float/Bool+instance SIntegral Word8+instance SIntegral Word16+instance SIntegral Word32+instance SIntegral Word64+instance SIntegral Int8+instance SIntegral Int16+instance SIntegral Int32+instance SIntegral Int64+instance SIntegral Integer+instance (KnownNat n, BVIsNonZero n) => SIntegral (WordN n)+instance (KnownNat n, BVIsNonZero n) => SIntegral (IntN n)++-- | Zero extend a bit-vector.+zeroExtend :: forall n m bv. ( KnownNat n, BVIsNonZero n, SymVal (bv n)+ , KnownNat m, BVIsNonZero m, SymVal (bv m)+ , n + 1 <= m+ , SIntegral (bv (m - n))+ , BVIsNonZero (m - n)+ ) => SBV (bv n) -- ^ Input, of size @n@+ -> SBV (bv m) -- ^ Output, of size @m@. @n < m@ must hold+zeroExtend n = SBV $ svZeroExtend i (unSBV n)+ where nv = intOfProxy (Proxy @n)+ mv = intOfProxy (Proxy @m)+ i = fromIntegral (mv - nv)++-- | Sign extend a bit-vector.+signExtend :: forall n m bv. ( KnownNat n, BVIsNonZero n, SymVal (bv n)+ , KnownNat m, BVIsNonZero m, SymVal (bv m)+ , n + 1 <= m+ , SFiniteBits (bv n)+ , SIntegral (bv (m - n))+ , BVIsNonZero (m - n)+ ) => SBV (bv n) -- ^ Input, of size @n@+ -> SBV (bv m) -- ^ Output, of size @m@. @n < m@ must hold+signExtend n = SBV $ svSignExtend i (unSBV n)+ where nv = intOfProxy (Proxy @n)+ mv = intOfProxy (Proxy @m)+ i = fromIntegral (mv - nv)+++-- | Finite bit-length symbolic values. Essentially the same as 'SIntegral', but further leaves out 'Integer'. Loosely+-- based on Haskell's @FiniteBits@ class, but with more methods defined and structured differently to fit into the+-- symbolic world view. Minimal complete definition: 'sFiniteBitSize'.+class (Ord a, SymVal a, Num a, Num (SBV a), OrdSymbolic (SBV a), Bits a) => SFiniteBits a where+ -- | Bit size.+ sFiniteBitSize :: SBV a -> Int+ -- | Least significant bit of a word, always stored at index 0.+ lsb :: SBV a -> SBool+ -- | Most significant bit of a word, always stored at the last position.+ msb :: SBV a -> SBool+ -- | Big-endian blasting of a word into its bits.+ blastBE :: SBV a -> [SBool]+ -- | Little-endian blasting of a word into its bits.+ blastLE :: SBV a -> [SBool]+ -- | Reconstruct from given bits, given in little-endian.+ fromBitsBE :: [SBool] -> SBV a+ -- | Reconstruct from given bits, given in little-endian.+ fromBitsLE :: [SBool] -> SBV a+ -- | Replacement for 'testBit', returning 'SBool' instead of 'Bool'.+ sTestBit :: SBV a -> Int -> SBool+ -- | Variant of 'sTestBit', where we want to extract multiple bit positions.+ sExtractBits :: SBV a -> [Int] -> [SBool]+ -- | Variant of 'popCount', returning a symbolic value.+ sPopCount :: SBV a -> SWord8+ -- | A combo of 'setBit' and 'clearBit', when the bit to be set is symbolic.+ setBitTo :: SBV a -> Int -> SBool -> SBV a+ -- | Variant of 'setBitTo' when the index is symbolic. If the index it out-of-bounds,+ -- then the result is underspecified.+ sSetBitTo :: Integral a => SBV a -> SBV a -> SBool -> SBV a+ -- | Full adder, returns carry-out from the addition. Only for unsigned quantities.+ fullAdder :: SBV a -> SBV a -> (SBool, SBV a)+ -- | Full multiplier, returns both high and low-order bits. Only for unsigned quantities.+ fullMultiplier :: SBV a -> SBV a -> (SBV a, SBV a)+ -- | Count leading zeros in a word, big-endian interpretation.+ sCountLeadingZeros :: SBV a -> SWord8+ -- | Count trailing zeros in a word, big-endian interpretation.+ sCountTrailingZeros :: SBV a -> SWord8++ {-# MINIMAL sFiniteBitSize #-}++ -- Default implementations+ lsb (SBV v) = SBV (svTestBit v 0)+ msb x = sTestBit x (sFiniteBitSize x - 1)++ blastBE = reverse . blastLE+ blastLE x = map (sTestBit x) [0 .. intSizeOf x - 1]++ fromBitsBE = fromBitsLE . reverse+ fromBitsLE bs+ | length bs /= w+ = error $ "SBV.SFiniteBits.fromBitsLE/BE: Expected: " ++ show w ++ " bits, received: " ++ show (length bs)+ | True+ = result+ where w = sFiniteBitSize result+ result = go 0 0 bs++ go !acc _ [] = acc+ go !acc !i (x:xs) = go (ite x (setBit acc i) acc) (i+1) xs++ sTestBit (SBV x) i = SBV (svTestBit x i)+ sExtractBits x = map (sTestBit x)++ -- NB. 'sPopCount' returns an 'SWord8', which can overflow when used on quantities that have+ -- more than 255 bits. For the regular interface, this suffices for all types we support.+ -- For the Dynamic interface, if we ever implement this, this will fail for bit-vectors+ -- larger than that many bits. The alternative would be to return SInteger here, but that+ -- seems a total overkill for most use cases. If such is required, users are encouraged+ -- to define their own variants, which is rather easy.+ sPopCount x+ | Just v <- unliteral x = go 0 v+ | True = sum [ite b 1 0 | b <- blastLE x]+ where -- concrete case+ go !c 0 = c+ go !c w = go (c+1) (w .&. (w-1))++ setBitTo x i b = ite b (setBit x i) (clearBit x i)++ sSetBitTo x idx b+ | Just i <- unliteral idx, Just index <- safe i+ = setBitTo x index b+ | True+ = go x [0 .. sFiniteBitSize x - 1]+ where -- paranoia check: make sure index can fit in an int+ safe i = let asInteger = toInteger i+ asInt = fromIntegral asInteger+ backInteger = toInteger asInt+ in if backInteger == asInteger+ then Just asInt+ else Nothing++ go v [] = v+ go v (i:is) = go (ite (idx .== literal (fromIntegral i)) (setBitTo v (fromIntegral i) b) v) is++ fullAdder a b+ | isSigned a = error "fullAdder: only works on unsigned numbers"+ | True = (a .> s .|| b .> s, s)+ where s = a + b++ -- N.B. The higher-order bits are determined using a simple shift-add multiplier,+ -- thus involving bit-blasting. It'd be naive to expect SMT solvers to deal efficiently+ -- with properties involving this function, at least with the current state of the art.+ fullMultiplier a b+ | isSigned a = error "fullMultiplier: only works on unsigned numbers"+ | True = (go (sFiniteBitSize a) 0 a, a*b)+ where go 0 p _ = p+ go n p x = let (c, p') = ite (lsb x) (fullAdder p b) (sFalse, p)+ (o, p'') = shiftIn c p'+ (_, x') = shiftIn o x+ in go (n-1) p'' x'+ shiftIn k v = (lsb v, mask .|. (v `shiftR` 1))+ where mask = ite k (bit (sFiniteBitSize v - 1)) 0++ -- See the note for 'sPopCount' for a comment on why we return 'SWord8'+ sCountLeadingZeros x = fromIntegral m - go m+ where m = sFiniteBitSize x - 1++ -- NB. When i is 0 below, which happens when x is 0 as we count all the way down,+ -- we return -1, which is equal to 2^n-1, giving us: n-1-(2^n-1) = n-2^n = n, as required, i.e., the bit-size.+ go :: Int -> SWord8+ go i | i < 0 = i8+ | True = ite (sTestBit x i) i8 (go (i-1))+ where i8 = literal (fromIntegral i :: Word8)++ -- See the note for 'sPopCount' for a comment on why we return 'SWord8'+ sCountTrailingZeros x = go 0+ where m = sFiniteBitSize x++ go :: Int -> SWord8+ go i | i >= m = i8+ | True = ite (sTestBit x i) i8 (go (i+1))+ where i8 = literal (fromIntegral i :: Word8)++-- 'SFiniteBits' Instances, skips Real/Float/Bool/Integer+instance SFiniteBits Word8 where sFiniteBitSize _ = 8+instance SFiniteBits Word16 where sFiniteBitSize _ = 16+instance SFiniteBits Word32 where sFiniteBitSize _ = 32+instance SFiniteBits Word64 where sFiniteBitSize _ = 64+instance SFiniteBits Int8 where sFiniteBitSize _ = 8+instance SFiniteBits Int16 where sFiniteBitSize _ = 16+instance SFiniteBits Int32 where sFiniteBitSize _ = 32+instance SFiniteBits Int64 where sFiniteBitSize _ = 64+instance (KnownNat n, BVIsNonZero n) => SFiniteBits (WordN n) where sFiniteBitSize _ = intOfProxy (Proxy @n)+instance (KnownNat n, BVIsNonZero n) => SFiniteBits (IntN n) where sFiniteBitSize _ = intOfProxy (Proxy @n)++-- | Returns 1 if the boolean is 'sTrue', otherwise 0.+oneIf :: (Ord a, Num (SBV a), SymVal a) => SBool -> SBV a+oneIf t = ite t 1 0++-- | Lift a pseudo-boolean op, performing checks+liftPB :: String -> PBOp -> [SBool] -> SBool+liftPB w o xs+ | Just e <- check o+ = error $ "SBV." ++ w ++ ": " ++ e+ | True+ = result+ where check (PB_AtMost k) = pos k+ check (PB_AtLeast k) = pos k+ check (PB_Exactly k) = pos k+ check (PB_Le cs k) = pos k `mplus` match cs+ check (PB_Ge cs k) = pos k `mplus` match cs+ check (PB_Eq cs k) = pos k `mplus` match cs++ pos k+ | k < 0 = Just $ "comparison value must be positive, received: " ++ show k+ | True = Nothing++ match cs+ | any (< 0) cs = Just $ "coefficients must be non-negative. Received: " ++ show cs+ | lxs /= lcs = Just $ "coefficient length must match number of arguments. Received: " ++ show (lcs, lxs)+ | True = Nothing+ where lxs = length xs+ lcs = length cs++ result = SBV (SVal KBool (Right (cache r)))+ r st = do xsv <- mapM (sbvToSV st) xs+ -- PseudoBoolean's implicitly require support for integers, so make sure to register that kind!+ registerKind st KUnbounded+ newExpr st KBool (SBVApp (PseudoBoolean o) xsv)++-- | 'sTrue' if at most @k@ of the input arguments are 'sTrue'+pbAtMost :: [SBool] -> Int -> SBool+pbAtMost xs k+ | k < 0 = error $ "SBV.pbAtMost: Non-negative value required, received: " ++ show k+ | all isConcrete xs = literal $ sum (map (pbToInteger "pbAtMost" 1) xs) <= fromIntegral k+ | True = liftPB "pbAtMost" (PB_AtMost k) xs++-- | 'sTrue' if at least @k@ of the input arguments are 'sTrue'+pbAtLeast :: [SBool] -> Int -> SBool+pbAtLeast xs k+ | k < 0 = error $ "SBV.pbAtLeast: Non-negative value required, received: " ++ show k+ | all isConcrete xs = literal $ sum (map (pbToInteger "pbAtLeast" 1) xs) >= fromIntegral k+ | True = liftPB "pbAtLeast" (PB_AtLeast k) xs++-- | 'sTrue' if exactly @k@ of the input arguments are 'sTrue'+pbExactly :: [SBool] -> Int -> SBool+pbExactly xs k+ | k < 0 = error $ "SBV.pbExactly: Non-negative value required, received: " ++ show k+ | all isConcrete xs = literal $ sum (map (pbToInteger "pbExactly" 1) xs) == fromIntegral k+ | True = liftPB "pbExactly" (PB_Exactly k) xs++-- | 'sTrue' if the sum of coefficients for 'sTrue' elements is at most @k@. Generalizes 'pbAtMost'.+pbLe :: [(Int, SBool)] -> Int -> SBool+pbLe xs k+ | k < 0 = error $ "SBV.pbLe: Non-negative value required, received: " ++ show k+ | all (isConcrete . snd) xs = literal $ sum [pbToInteger "pbLe" c b | (c, b) <- xs] <= fromIntegral k+ | True = liftPB "pbLe" (PB_Le (map fst xs) k) (map snd xs)++-- | 'sTrue' if the sum of coefficients for 'sTrue' elements is at least @k@. Generalizes 'pbAtLeast'.+pbGe :: [(Int, SBool)] -> Int -> SBool+pbGe xs k+ | k < 0 = error $ "SBV.pbGe: Non-negative value required, received: " ++ show k+ | all (isConcrete . snd) xs = literal $ sum [pbToInteger "pbGe" c b | (c, b) <- xs] >= fromIntegral k+ | True = liftPB "pbGe" (PB_Ge (map fst xs) k) (map snd xs)++-- | 'sTrue' if the sum of coefficients for 'sTrue' elements is exactly least @k@. Useful for coding+-- /exactly K-of-N/ constraints, and in particular mutex constraints.+pbEq :: [(Int, SBool)] -> Int -> SBool+pbEq xs k+ | k < 0 = error $ "SBV.pbEq: Non-negative value required, received: " ++ show k+ | all (isConcrete . snd) xs = literal $ sum [pbToInteger "pbEq" c b | (c, b) <- xs] == fromIntegral k+ | True = liftPB "pbEq" (PB_Eq (map fst xs) k) (map snd xs)++-- | 'sTrue' if there is at most one set bit+pbMutexed :: [SBool] -> SBool+pbMutexed xs = pbAtMost xs 1++-- | 'sTrue' if there is exactly one set bit+pbStronglyMutexed :: [SBool] -> SBool+pbStronglyMutexed xs = pbExactly xs 1++-- | Convert a concrete pseudo-boolean to given int; converting to integer+pbToInteger :: String -> Int -> SBool -> Integer+pbToInteger w c b+ | c < 0 = error $ "SBV." ++ w ++ ": Non-negative coefficient required, received: " ++ show c+ | Just v <- unliteral b = if v then fromIntegral c else 0+ | True = error $ "SBV.pbToInteger: Received a symbolic boolean: " ++ show (c, b)++-- | Predicate for optimizing word operations like (+) and (*).+isConcreteZero :: SBV a -> Bool+isConcreteZero (SBV (SVal _ (Left (CV _ (CInteger n))))) = n == 0+isConcreteZero (SBV (SVal KReal (Left (CV KReal (CAlgReal v))))) = isExactRational v && v == 0+isConcreteZero _ = False++-- | Predicate for optimizing word operations like (+) and (*).+isConcreteOne :: SBV a -> Bool+isConcreteOne (SBV (SVal _ (Left (CV _ (CInteger 1))))) = True+isConcreteOne (SBV (SVal KReal (Left (CV KReal (CAlgReal v))))) = isExactRational v && v == 1+isConcreteOne _ = False++-- | Symbolic exponentiation using bit blasting and repeated squaring.+--+-- N.B. The exponent must be unsigned/bounded if symbolic. Signed exponents will be rejected.+(.^) :: (Mergeable b, Num b, SIntegral e) => b -> SBV e -> b+b .^ e+ | isConcrete e, Just (x :: Integer) <- unliteral (sFromIntegral e)+ = if x >= 0 then let go n v+ | n == 0 = 1+ | even n = go (n `div` 2) (v * v)+ | True = v * go (n `div` 2) (v * v)+ in go x b+ else error $ "(.^): exponentiation: negative exponent: " ++ show x+ | not (isBounded e) || isSigned e+ = error $ "(.^): exponentiation only works with unsigned bounded symbolic exponents, kind: " ++ show (kindOf e)+ | True+ = -- NB. We can't simply use sTestBit and blastLE since they have SFiniteBit requirement+ -- but we want to have SIntegral here only.+ let SBV expt = e+ expBit i = SBV (svTestBit expt i)+ blasted = map expBit [0 .. intSizeOf e - 1]+ in product $ zipWith (\use n -> ite use n 1)+ blasted+ (iterate (\x -> x*x) b)+infixr 8 .^++instance (Ord a, Num (SBV a), SymVal a, Fractional a) => Fractional (SBV a) where+ fromRational = literal . fromRational+ SBV x / sy@(SBV y) | div0 = ite (sy .== 0) 0 res+ | True = res+ where res = SBV (svDivide x y)+ -- Identify those kinds where we have a div-0 equals 0 exception+ div0 = case kindOf sy of+ KVar{} -> error $ "Unexpected Fractional case for: " ++ show (kindOf sy)+ KFloat -> False+ KDouble -> False+ KFP{} -> False+ KReal -> True+ KRational -> True+ -- Following cases should not happen since these types should *not* be instances of Fractional+ k@KBounded{} -> error $ "Unexpected Fractional case for: " ++ show k+ k@KUnbounded -> error $ "Unexpected Fractional case for: " ++ show k+ k@KBool -> error $ "Unexpected Fractional case for: " ++ show k+ k@KString -> error $ "Unexpected Fractional case for: " ++ show k+ k@KChar -> error $ "Unexpected Fractional case for: " ++ show k+ k@KList{} -> error $ "Unexpected Fractional case for: " ++ show k+ k@KSet{} -> error $ "Unexpected Fractional case for: " ++ show k+ k@KApp{} -> error $ "Unexpected Fractional case for: " ++ show k+ k@KADT{} -> error $ "Unexpected Fractional case for: " ++ show k+ k@KTuple{} -> error $ "Unexpected Fractional case for: " ++ show k+ k@KArray{} -> error $ "Unexpected Fractional case for: " ++ show k++-- | Define Floating instance on SBV's; only for base types that are already floating; i.e., 'SFloat', 'SDouble', and 'SReal'.+-- (See the separate definition below for 'SFloatingPoint'.) Note that unless you use delta-sat via 'Data.SBV.Provers.dReal' on 'SReal', most+-- of the fields are "undefined" for symbolic values. We will add methods as they are supported by SMTLib. Currently, the+-- only symbolically available function in this class is 'sqrt' for 'SFloat', 'SDouble' and 'SFloatingPoint'.+instance (Ord a, Num (SBV a), SymVal a, Fractional a, Floating a) => Floating (SBV a) where+ pi = fromRational . toRational $ (pi :: Double)+ exp = lift1FNS "exp" exp+ log = lift1FNS "log" log+ sqrt = lift1F FP_Sqrt sqrt+ sin = lift1FNS "sin" sin+ cos = lift1FNS "cos" cos+ tan = lift1FNS "tan" tan+ asin = lift1FNS "asin" asin+ acos = lift1FNS "acos" acos+ atan = lift1FNS "atan" atan+ sinh = lift1FNS "sinh" sinh+ cosh = lift1FNS "cosh" cosh+ tanh = lift1FNS "tanh" tanh+ asinh = lift1FNS "asinh" asinh+ acosh = lift1FNS "acosh" acosh+ atanh = lift1FNS "atanh" atanh+ (**) = lift2FNS "**" (**)+ logBase = lift2FNS "logBase" logBase++unsupported :: String -> a+unsupported w = error $ "Data.SBV.FloatingPoint: Unsupported operation: " ++ w ++ ". Please request this as a feature!"++-- | We give a specific instance for 'SFloatingPoint', because the underlying floating-point type doesn't support+-- fromRational directly. The overlap with the above instance is unfortunate.+instance {-# OVERLAPPING #-} ValidFloat eb sb => Floating (SFloatingPoint eb sb) where+ -- Try from double; if there's enough precision this'll work, otherwise will bail out.+ pi+ | ei > 11 || si > 53 = unsupported $ "Floating.SFloatingPoint.pi (not-enough-precision for " ++ show (ei, si) ++ ")"+ | True = literal $ FloatingPoint $ fpFromRational ei si (toRational (pi :: Double))+ where ei = intOfProxy (Proxy @eb)+ si = intOfProxy (Proxy @sb)++ -- Likewise, exponentiation is again limited to precision of double+ exp i+ | ei > 11 || si > 53 = unsupported $ "Floating.SFloatingPoint.exp (not-enough-precision for " ++ show (ei, si) ++ ")"+ | True = literal e ** i+ where ei = intOfProxy (Proxy @eb)+ si = intOfProxy (Proxy @sb)+ e = FloatingPoint $ fpFromRational ei si (toRational (exp 1 :: Double))++ log = lift1FNS "log" log+ sqrt = lift1F FP_Sqrt sqrt+ sin = lift1FNS "sin" sin+ cos = lift1FNS "cos" cos+ tan = lift1FNS "tan" tan+ asin = lift1FNS "asin" asin+ acos = lift1FNS "acos" acos+ atan = lift1FNS "atan" atan+ sinh = lift1FNS "sinh" sinh+ cosh = lift1FNS "cosh" cosh+ tanh = lift1FNS "tanh" tanh+ asinh = lift1FNS "asinh" asinh+ acosh = lift1FNS "acosh" acosh+ atanh = lift1FNS "atanh" atanh+ (**) = lift2FNS "**" (**)+ logBase = lift2FNS "logBase" logBase++-- | Lift a 1 arg FP-op, using sRNE default+lift1F :: SymVal a => FPOp -> (a -> a) -> SBV a -> SBV a+lift1F w op a+ | Just v <- unliteral a+ = literal $ op v+ | True+ = SBV $ SVal k $ Right $ cache r+ where k = kindOf a+ r st = do swa <- sbvToSV st a+ swm <- sbvToSV st sRNE+ newExpr st k (SBVApp (IEEEFP w) [swm, swa])++-- | Lift a float/double unary function, only over constants+lift1FNS :: (SymVal a, Floating a) => String -> (a -> a) -> SBV a -> SBV a+lift1FNS nm f sv+ | Just v <- unliteral sv = literal $ f v+ | True = error $ "SBV." ++ nm ++ ": not supported for symbolic values of type " ++ show (kindOf sv)++-- | Lift a float/double binary function, only over constants+lift2FNS :: (SymVal a, Floating a) => String -> (a -> a -> a) -> SBV a -> SBV a -> SBV a+lift2FNS nm f sv1 sv2+ | Just v1 <- unliteral sv1+ , Just v2 <- unliteral sv2 = literal $ f v1 v2+ | True = error $ "SBV." ++ nm ++ ": not supported for symbolic values of type " ++ show (kindOf sv1)++-- | SReal Floating instance, used in conjunction with the dReal solver for delta-satisfiability. Note that+-- we do not constant fold these values (except for pi), as Haskell doesn't really have any means of computing+-- them for arbitrary rationals.+instance {-# OVERLAPPING #-} Floating SReal where+ pi = fromRational . toRational $ (pi :: Double) -- Perhaps not good enough?+ exp = lift1SReal NR_Exp+ log = lift1SReal NR_Log+ sqrt = lift1SReal NR_Sqrt+ sin = lift1SReal NR_Sin+ cos = lift1SReal NR_Cos+ tan = lift1SReal NR_Tan+ asin = lift1SReal NR_ASin+ acos = lift1SReal NR_ACos+ atan = lift1SReal NR_ATan+ sinh = lift1SReal NR_Sinh+ cosh = lift1SReal NR_Cosh+ tanh = lift1SReal NR_Tanh+ asinh = error "Data.SBV.SReal: asinh is currently not supported. Please request this as a feature!"+ acosh = error "Data.SBV.SReal: acosh is currently not supported. Please request this as a feature!"+ atanh = error "Data.SBV.SReal: atanh is currently not supported. Please request this as a feature!"+ (**) = lift2SReal NR_Pow++ logBase x y = log y / log x++-- | Lift an sreal unary function+lift1SReal :: NROp -> SReal -> SReal+lift1SReal w a = SBV $ SVal k $ Right $ cache r+ where k = kindOf a+ r st = do swa <- sbvToSV st a+ newExpr st k (SBVApp (NonLinear w) [swa])++-- | Lift an sreal binary function+lift2SReal :: NROp -> SReal -> SReal -> SReal+lift2SReal w a b = SBV $ SVal k $ Right $ cache r+ where k = kindOf a+ r st = do swa <- sbvToSV st a+ swb <- sbvToSV st b+ newExpr st k (SBVApp (NonLinear w) [swa, swb])++-- Bail out nicely.+noEquals :: String -> String -> (String, String) -> a+noEquals o n (l, r) = error $ unlines [ ""+ , "*** Data.SBV: Comparing symbolic values using Haskell's Eq class!"+ , "***"+ , "*** Received: (" ++ l ++ ") " ++ o ++ " (" ++ r ++ ")"+ , "*** Instead use: (" ++ l ++ ") " ++ n ++ " (" ++ r ++ ")"+ , "***"+ , "*** The Eq instance for symbolic values are necessiated only because"+ , "*** of the Bits class requirement. You must use symbolic equality"+ , "*** operators instead. (And complain to Haskell folks that they"+ , "*** remove the 'Eq' superclass from 'Bits'!.)"+ ]++-- | This instance is only defined so that we can define an instance for+-- 'Data.Bits.Bits'. '==' and '/=' simply throw an error. Use+-- 'Data.SBV.EqSymbolic' instead.+instance SymVal a => Eq (SBV a) where+ a == b = fromMaybe (noEquals "==" ".==" (show a, show b)) (unliteral (a .== b))+ a /= b = fromMaybe (noEquals "/=" "./=" (show a, show b)) (unliteral (a ./= b))++-- NB. In the optimizations below, use of -1 is valid as+-- -1 has all bits set to True for both signed and unsigned values+-- | Using 'popCount' or 'testBit' on non-concrete values will result in an+-- error. Use 'sPopCount' or 'sTestBit' instead.+instance (Ord a, Num (SBV a), Num a, Bits a, SymVal a) => Bits (SBV a) where+ SBV x .&. SBV y = SBV (svAnd x y)+ SBV x .|. SBV y = SBV (svOr x y)+ SBV x `xor` SBV y = SBV (svXOr x y)+ complement (SBV x) = SBV (svNot x)+ bitSize x = intSizeOf x+ bitSizeMaybe x = Just $ intSizeOf x+ isSigned x = hasSign x+ bit i = 1 `shiftL` i+ setBit x i = x .|. genLiteral (kindOf x) (bit i :: Integer)+ clearBit x i = x .&. genLiteral (kindOf x) (complement (bit i) :: Integer)+ complementBit x i = x `xor` genLiteral (kindOf x) (bit i :: Integer)+ shiftL (SBV x) i = SBV (svShl x i)+ shiftR (SBV x) i = SBV (svShr x i)+ rotateL (SBV x) i = SBV (svRol x i)+ rotateR (SBV x) i = SBV (svRor x i)+ -- NB. testBit is *not* implementable on non-concrete symbolic words+ x `testBit` i+ | SBV (SVal _ (Left (CV _ (CInteger n)))) <- x+ = testBit n i+ | True+ = error $ "SBV.testBit: Called on symbolic value: " ++ show x ++ ". Use sTestBit instead."+ -- NB. popCount is *not* implementable on non-concrete symbolic words+ popCount x+ | SBV (SVal _ (Left (CV (KBounded _ w) (CInteger n)))) <- x+ = popCount (n .&. (bit w - 1))+ | True+ = error $ "SBV.popCount: Called on symbolic value: " ++ show x ++ ". Use sPopCount instead."++-- | Conversion between integral-symbolic values, akin to Haskell's `fromIntegral`+sFromIntegral :: forall a b. (Integral a, HasKind a, Num a, SymVal a, HasKind b, Num b, SymVal b) => SBV a -> SBV b+sFromIntegral x+ | kFrom == kTo+ = SBV (unSBV x)+ | isReal x+ = error "SBV.sFromIntegral: Called on a real value" -- can't really happen due to types, but being overcautious+ | Just v <- unliteral x+ = literal (fromIntegral v)+ | True+ = result+ where result = SBV (SVal kTo (Right (cache y)))+ kFrom = kindOf x+ kTo = kindOf (Proxy @b)+ y st = do xsv <- sbvToSV st x+ newExpr st kTo (SBVApp (KindCast kFrom kTo) [xsv])++-- | Lift a binary operation thru its dynamic counterpart. Note that+-- we still want the actual functions here as differ in their type+-- compared to their dynamic counterparts, but the implementations+-- are the same.+liftViaSVal :: (SVal -> SVal -> SVal) -> SBV a -> SBV b -> SBV c+liftViaSVal f (SBV a) (SBV b) = SBV $ f a b++-- | Generalization of 'shiftL', when the shift-amount is symbolic. Since Haskell's+-- 'shiftL' only takes an 'Int' as the shift amount, it cannot be used when we have+-- a symbolic amount to shift with.+sShiftLeft :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a+sShiftLeft = liftViaSVal svShiftLeft++-- | Generalization of 'shiftR', when the shift-amount is symbolic. Since Haskell's+-- 'shiftR' only takes an 'Int' as the shift amount, it cannot be used when we have+-- a symbolic amount to shift with.+--+-- NB. If the shiftee is signed, then this is an arithmetic shift; otherwise it's logical,+-- following the usual Haskell convention. See 'sSignedShiftArithRight' for a variant+-- that explicitly uses the msb as the sign bit, even for unsigned underlying types.+sShiftRight :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a+sShiftRight = liftViaSVal svShiftRight++-- | Arithmetic shift-right with a symbolic unsigned shift amount. This is equivalent+-- to 'sShiftRight' when the argument is signed. However, if the argument is unsigned,+-- then it explicitly treats its msb as a sign-bit, and uses it as the bit that+-- gets shifted in. Useful when using the underlying unsigned bit representation to implement+-- custom signed operations. Note that there is no direct Haskell analogue of this function.+sSignedShiftArithRight:: (SFiniteBits a, SIntegral b) => SBV a -> SBV b -> SBV a+sSignedShiftArithRight x i+ | isSigned i = error "sSignedShiftArithRight: shift amount should be unsigned"+ | isSigned x = ssa x i+ | True = ite (msb x)+ (complement (ssa (complement x) i))+ (ssa x i)+ where ssa = liftViaSVal svShiftRight++-- | Generalization of 'rotateL', when the shift-amount is symbolic. Since Haskell's+-- 'rotateL' only takes an 'Int' as the shift amount, it cannot be used when we have+-- a symbolic amount to shift with. The first argument should be a bounded quantity.+sRotateLeft :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a+sRotateLeft = liftViaSVal svRotateLeft++-- | An implementation of rotate-left, using a barrel shifter like design. Only works when both+-- arguments are finite bit-vectors, and furthermore when the second argument is unsigned.+-- The first condition is enforced by the type, but the second is dynamically checked.+-- We provide this implementation as an alternative to `sRotateLeft` since SMTLib logic+-- does not support variable argument rotates (as opposed to shifts), and thus this+-- implementation can produce better code for verification compared to `sRotateLeft`.+sBarrelRotateLeft :: (SFiniteBits a, SFiniteBits b) => SBV a -> SBV b -> SBV a+sBarrelRotateLeft = liftViaSVal svBarrelRotateLeft++-- | Generalization of 'rotateR', when the shift-amount is symbolic. Since Haskell's+-- 'rotateR' only takes an 'Int' as the shift amount, it cannot be used when we have+-- a symbolic amount to shift with. The first argument should be a bounded quantity.+sRotateRight :: (SIntegral a, SIntegral b) => SBV a -> SBV b -> SBV a+sRotateRight = liftViaSVal svRotateRight++-- | An implementation of rotate-right, using a barrel shifter like design. See comments+-- for `sBarrelRotateLeft` for details.+sBarrelRotateRight :: (SFiniteBits a, SFiniteBits b) => SBV a -> SBV b -> SBV a+sBarrelRotateRight = liftViaSVal svBarrelRotateRight++-- | Capturing non-matching instances for better error messages, conversions from sized+type FromSizedErr (arg :: Type) = 'Text "fromSized: Cannot convert from type: " ':<>: 'ShowType arg+ ':$$: 'Text " Source type must be one of SInt N, SWord N, IntN N, WordN N"+ ':$$: 'Text " where N is 8, 16, 32, or 64."++-- | Capturing non-matching instances for better error messages, conversions to sized+type ToSizedErr (arg :: Type) = 'Text "toSized: Cannot convert from type: " ':<>: 'ShowType arg+ ':$$: 'Text " Source type must be one of Int8/16/32/64"+ ':$$: 'Text " OR Word8/16/32/64"+ ':$$: 'Text " OR their symbolic variants."++-- | Capture the correspondence between sized and fixed-sized BVs+type family FromSized (t :: Type) :: Type where+ FromSized (WordN 8) = Word8+ FromSized (WordN 16) = Word16+ FromSized (WordN 32) = Word32+ FromSized (WordN 64) = Word64+ FromSized (IntN 8) = Int8+ FromSized (IntN 16) = Int16+ FromSized (IntN 32) = Int32+ FromSized (IntN 64) = Int64+ FromSized (SWord 8) = SWord8+ FromSized (SWord 16) = SWord16+ FromSized (SWord 32) = SWord32+ FromSized (SWord 64) = SWord64+ FromSized (SInt 8) = SInt8+ FromSized (SInt 16) = SInt16+ FromSized (SInt 32) = SInt32+ FromSized (SInt 64) = SInt64++-- | Capture the correspondence, in terms of a constraint+type family FromSizedCstr (t :: Type) :: Constraint where+ FromSizedCstr (WordN 8) = ()+ FromSizedCstr (WordN 16) = ()+ FromSizedCstr (WordN 32) = ()+ FromSizedCstr (WordN 64) = ()+ FromSizedCstr (IntN 8) = ()+ FromSizedCstr (IntN 16) = ()+ FromSizedCstr (IntN 32) = ()+ FromSizedCstr (IntN 64) = ()+ FromSizedCstr (SWord 8) = ()+ FromSizedCstr (SWord 16) = ()+ FromSizedCstr (SWord 32) = ()+ FromSizedCstr (SWord 64) = ()+ FromSizedCstr (SInt 8) = ()+ FromSizedCstr (SInt 16) = ()+ FromSizedCstr (SInt 32) = ()+ FromSizedCstr (SInt 64) = ()+ FromSizedCstr arg = TypeError (FromSizedErr arg)++-- | Conversion from a sized BV to a fixed-sized bit-vector.+class FromSizedBV a where+ -- | Convert a sized bit-vector to the corresponding fixed-sized bit-vector,+ -- for instance 'SWord 16' to 'SWord16'. See also 'toSized'.+ fromSized :: a -> FromSized a++ default fromSized :: (Num (FromSized a), Integral a) => a -> FromSized a+ fromSized = fromIntegral++instance {-# OVERLAPPING #-} FromSizedBV (WordN 8)+instance {-# OVERLAPPING #-} FromSizedBV (WordN 16)+instance {-# OVERLAPPING #-} FromSizedBV (WordN 32)+instance {-# OVERLAPPING #-} FromSizedBV (WordN 64)+instance {-# OVERLAPPING #-} FromSizedBV (IntN 8)+instance {-# OVERLAPPING #-} FromSizedBV (IntN 16)+instance {-# OVERLAPPING #-} FromSizedBV (IntN 32)+instance {-# OVERLAPPING #-} FromSizedBV (IntN 64)+instance {-# OVERLAPPING #-} FromSizedBV (SWord 8) where fromSized = sFromIntegral+instance {-# OVERLAPPING #-} FromSizedBV (SWord 16) where fromSized = sFromIntegral+instance {-# OVERLAPPING #-} FromSizedBV (SWord 32) where fromSized = sFromIntegral+instance {-# OVERLAPPING #-} FromSizedBV (SWord 64) where fromSized = sFromIntegral+instance {-# OVERLAPPING #-} FromSizedBV (SInt 8) where fromSized = sFromIntegral+instance {-# OVERLAPPING #-} FromSizedBV (SInt 16) where fromSized = sFromIntegral+instance {-# OVERLAPPING #-} FromSizedBV (SInt 32) where fromSized = sFromIntegral+instance {-# OVERLAPPING #-} FromSizedBV (SInt 64) where fromSized = sFromIntegral+instance {-# OVERLAPPABLE #-} FromSizedCstr arg => FromSizedBV arg where fromSized = error "unreachable"++-- | Capture the correspondence between fixed-sized and sized BVs+type family ToSized (t :: Type) :: Type where+ ToSized Word8 = WordN 8+ ToSized Word16 = WordN 16+ ToSized Word32 = WordN 32+ ToSized Word64 = WordN 64+ ToSized Int8 = IntN 8+ ToSized Int16 = IntN 16+ ToSized Int32 = IntN 32+ ToSized Int64 = IntN 64+ ToSized SWord8 = SWord 8+ ToSized SWord16 = SWord 16+ ToSized SWord32 = SWord 32+ ToSized SWord64 = SWord 64+ ToSized SInt8 = SInt 8+ ToSized SInt16 = SInt 16+ ToSized SInt32 = SInt 32+ ToSized SInt64 = SInt 64++-- | Capture the correspondence in terms of a constraint+type family ToSizedCstr (t :: Type) :: Constraint where+ ToSizedCstr Word8 = ()+ ToSizedCstr Word16 = ()+ ToSizedCstr Word32 = ()+ ToSizedCstr Word64 = ()+ ToSizedCstr Int8 = ()+ ToSizedCstr Int16 = ()+ ToSizedCstr Int32 = ()+ ToSizedCstr Int64 = ()+ ToSizedCstr SWord8 = ()+ ToSizedCstr SWord16 = ()+ ToSizedCstr SWord32 = ()+ ToSizedCstr SWord64 = ()+ ToSizedCstr SInt8 = ()+ ToSizedCstr SInt16 = ()+ ToSizedCstr SInt32 = ()+ ToSizedCstr SInt64 = ()+ ToSizedCstr arg = TypeError (ToSizedErr arg)++-- | Conversion from a fixed-sized BV to a sized bit-vector.+class ToSizedBV a where+ -- | Convert a fixed-sized bit-vector to the corresponding sized bit-vector,+ -- for instance 'SWord16' to 'SWord 16'. See also 'fromSized'.+ toSized :: a -> ToSized a++ default toSized :: (Num (ToSized a), Integral a) => (a -> ToSized a)+ toSized = fromIntegral++instance {-# OVERLAPPING #-} ToSizedBV Word8+instance {-# OVERLAPPING #-} ToSizedBV Word16+instance {-# OVERLAPPING #-} ToSizedBV Word32+instance {-# OVERLAPPING #-} ToSizedBV Word64+instance {-# OVERLAPPING #-} ToSizedBV Int8+instance {-# OVERLAPPING #-} ToSizedBV Int16+instance {-# OVERLAPPING #-} ToSizedBV Int32+instance {-# OVERLAPPING #-} ToSizedBV Int64+instance {-# OVERLAPPING #-} ToSizedBV SWord8 where toSized = sFromIntegral+instance {-# OVERLAPPING #-} ToSizedBV SWord16 where toSized = sFromIntegral+instance {-# OVERLAPPING #-} ToSizedBV SWord32 where toSized = sFromIntegral+instance {-# OVERLAPPING #-} ToSizedBV SWord64 where toSized = sFromIntegral+instance {-# OVERLAPPING #-} ToSizedBV SInt8 where toSized = sFromIntegral+instance {-# OVERLAPPING #-} ToSizedBV SInt16 where toSized = sFromIntegral+instance {-# OVERLAPPING #-} ToSizedBV SInt32 where toSized = sFromIntegral+instance {-# OVERLAPPING #-} ToSizedBV SInt64 where toSized = sFromIntegral+instance {-# OVERLAPPABLE #-} ToSizedCstr arg => ToSizedBV arg where toSized = error "unreachable"++-- | The 'SDivisible' class captures the essence of division.+-- Unfortunately we cannot use Haskell's 'Integral' class since the 'Real'+-- and 'Enum' superclasses are not implementable for symbolic bit-vectors.+-- However, 'quotRem' and 'divMod' both make perfect sense, and the 'SDivisible' class captures+-- this operation. One issue is how division by 0 behaves. The verification+-- technology requires total functions, and there are several design choices+-- here. We follow Isabelle/HOL approach of assigning the value 0 for division+-- by 0. Therefore, we impose the following pair of laws:+--+-- @+-- x `sQuotRem` 0 = (0, x)+-- x `sDivMod` 0 = (0, x)+-- @+--+-- Note that our instances implement this law even when @x@ is @0@ itself.+--+-- NB. 'quot' truncates toward zero, while 'div' truncates toward negative infinity.+--+-- === C code generation of division operations+--+-- In the case of division or modulo of a minimal signed value (e.g. @-128@ for+-- 'SInt8') by @-1@, SMTLIB and Haskell agree on what the result should be.+-- Unfortunately the result in C code depends on CPU architecture and compiler+-- settings, as this is undefined behaviour in C. **SBV does not guarantee**+-- what will happen in generated C code in this corner case.+class SDivisible a where+ sQuotRem :: a -> a -> (a, a)+ sDivMod :: a -> a -> (a, a)+ sQuot :: a -> a -> a+ sRem :: a -> a -> a+ sDiv :: a -> a -> a+ sMod :: a -> a -> a++ {-# MINIMAL sQuotRem, sDivMod #-}++ x `sQuot` y = fst $ x `sQuotRem` y+ x `sRem` y = snd $ x `sQuotRem` y+ x `sDiv` y = fst $ x `sDivMod` y+ x `sMod` y = snd $ x `sDivMod` y++instance SDivisible Word64 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Int64 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Word32 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Int32 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Word16 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Int16 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Word8 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Int8 where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible Integer where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++instance SDivisible CV where+ sQuotRem a b+ | CInteger x <- cvVal a, CInteger y <- cvVal b+ = let (r1, r2) = sQuotRem x y in (normCV a{ cvVal = CInteger r1 }, normCV b{ cvVal = CInteger r2 })+ sQuotRem a b = error $ "SBV.sQuotRem: impossible, unexpected args received: " ++ show (a, b)+ sDivMod a b+ | CInteger x <- cvVal a, CInteger y <- cvVal b+ = let (r1, r2) = sDivMod x y in (normCV a{ cvVal = CInteger r1 }, normCV b{ cvVal = CInteger r2 })+ sDivMod a b = error $ "SBV.sDivMod: impossible, unexpected args received: " ++ show (a, b)++instance SDivisible SWord64 where {sQuotRem = liftQRem; sDivMod = liftDMod}+instance SDivisible SWord32 where {sQuotRem = liftQRem; sDivMod = liftDMod}+instance SDivisible SWord16 where {sQuotRem = liftQRem; sDivMod = liftDMod}+instance SDivisible SWord8 where {sQuotRem = liftQRem; sDivMod = liftDMod}+instance SDivisible SInt64 where {sQuotRem = liftQRem; sDivMod = liftDMod}+instance SDivisible SInt32 where {sQuotRem = liftQRem; sDivMod = liftDMod}+instance SDivisible SInt16 where {sQuotRem = liftQRem; sDivMod = liftDMod}+instance SDivisible SInt8 where {sQuotRem = liftQRem; sDivMod = liftDMod}++-- | 'SDivisible' instance for 'WordN'+instance (KnownNat n, BVIsNonZero n) => SDivisible (WordN n) where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++-- | 'SDivisible' instance for 'IntN'+instance (KnownNat n, BVIsNonZero n) => SDivisible (IntN n) where+ sQuotRem x 0 = (0, x)+ sQuotRem x y = x `quotRem` y+ sDivMod x 0 = (0, x)+ sDivMod x y = x `divMod` y++-- | 'SDivisible' instance for 'SWord'+instance (KnownNat n, BVIsNonZero n) => SDivisible (SWord n) where+ sQuotRem = liftQRem+ sDivMod = liftDMod++-- | 'SDivisible' instance for 'SInt'+instance (KnownNat n, BVIsNonZero n) => SDivisible (SInt n) where+ sQuotRem = liftQRem+ sDivMod = liftDMod++-- | Does the concrete positive number n divide the given integer?+sDivides :: Integer -> SInteger -> SBool+sDivides n v+ | n < 0+ = error $ "svDivides: First argument must be a strictly positive integer. Received: " ++ show n+ | Just x <- unliteral v+ = if x `mod` n == 0 then sTrue else sFalse+ | True+ = SBV $ svDivides n (unSBV v)++-- | Lift 'quotRem' to symbolic words. Division by 0 is defined s.t. @x/0 = 0@; which+-- holds even when @x@ is @0@ itself.+liftQRem :: (Eq a, SymVal a) => SBV a -> SBV a -> (SBV a, SBV a)+liftQRem x y+ | isConcreteZero x+ = (x, x)+ | isConcreteOne y+ = (x, z)+{-------------------------------+ - N.B. The seemingly innocuous variant when y == -1 only holds if the type is signed;+ - and also is problematic around the minBound.. So, we refrain from that optimization+ | isConcreteOnes y+ = (-x, z)+--------------------------------}+ | True+ = ite (y .== z) (z, x) (qr x y)+ where qr (SBV (SVal sgnsz (Left a))) (SBV (SVal _ (Left b))) = let (q, r) = sQuotRem a b in (SBV (SVal sgnsz (Left q)), SBV (SVal sgnsz (Left r)))+ qr a@(SBV (SVal sgnsz _)) b = (SBV (SVal sgnsz (Right (cache (mk Quot)))), SBV (SVal sgnsz (Right (cache (mk Rem)))))+ where mk o st = do sw1 <- sbvToSV st a+ sw2 <- sbvToSV st b+ mkSymOp o st sgnsz sw1 sw2+ z = genLiteral (kindOf x) (0::Integer)++-- | Lift 'divMod' to symbolic words. Division by 0 is defined s.t. @x/0 = 0@; which+-- holds even when @x@ is @0@ itself. Essentially, this is conversion from quotRem+-- (truncate to 0) to divMod (truncate towards negative infinity)+liftDMod :: (Ord a, SymVal a, Num a, Num (SBV a), SDivisible (SBV a)) => SBV a -> SBV a -> (SBV a, SBV a)+liftDMod x y+ | isConcreteZero x+ = (x, x)+ | isConcreteOne y+ = (x, z)+{-------------------------------+ - N.B. The seemingly innocuous variant when y == -1 only holds if the type is signed;+ - and also is problematic around the minBound.. So, we refrain from that optimization+ | isConcreteOnes y+ = (-x, z)+--------------------------------}+ | True+ = ite (y .== z) (z, x) $ ite (signum r .== negate (signum y)) (q-i, r+y) qr+ where qr@(q, r) = x `sQuotRem` y+ z = genLiteral (kindOf x) (0::Integer)+ i = genLiteral (kindOf x) (1::Integer)++-- SInteger instance for quotRem/divMod are tricky!+-- SMT-Lib only has Euclidean operations, but Haskell+-- uses "truncate to 0" for quotRem, and "truncate to negative infinity" for divMod.+-- So, we cannot just use the above liftings directly.+instance SDivisible SInteger where+ sDivMod x y = ite (y .> 0) (sEDivMod x y) (liftDMod x y)+ sQuotRem x y+ | not (isSymbolic x || isSymbolic y)+ = liftQRem x y+ | True+ = ite (y .== 0) (0, x) (qE+i, rE-i*y)+ where (qE, rE) = liftQRem x y -- for integers, this is euclidean due to SMTLib semantics+ i = ite (x .>= 0 .|| rE .== 0) 0+ $ ite (y .> 0) 1 (-1)++-- | Euclidian division and modulus.+sEDivMod :: SInteger -> SInteger -> (SInteger, SInteger)+sEDivMod a b = (a `sEDiv` b, a `sEMod` b)++-- | Euclidian division. Note that unlike regular division, Euclidian division by @0@+-- is unconstrained. i.e., it can take any value whatsoever.+sEDiv :: SInteger -> SInteger -> SInteger+sEDiv (SBV a) (SBV b) = SBV $ a `svQuot` b++-- | Euclidian modulus. Note that unlike regular modulus, Euclidian division by @0@+-- is unconstrained. i.e., it can take any value whatsoever.+sEMod :: SInteger -> SInteger -> SInteger+sEMod (SBV a) (SBV b) = SBV $ a `svRem` b++-- Quickcheck interface+instance (SymVal a, Arbitrary a) => Arbitrary (SBV a) where+ arbitrary = literal `fmap` arbitrary++-- | Symbolic conditionals are modeled by the 'Mergeable' class, describing+-- how to merge the results of an if-then-else call with a symbolic test. SBV+-- provides all basic types as instances of this class, so users only need+-- to declare instances for custom data-types of their programs as needed.+--+-- A 'Mergeable' instance may be automatically derived for a custom data-type+-- with a single constructor where the type of each field is an instance of+-- 'Mergeable', such as a record of symbolic values. Users only need to add+-- 'G.Generic' and 'Mergeable' to the @deriving@ clause for the data-type. See+-- 'Documentation.SBV.Examples.Puzzles.U2Bridge.Status' for an example and an+-- illustration of what the instance would look like if written by hand.+--+-- The function 'select' is a total-indexing function out of a list of choices+-- with a default value, simulating array/list indexing. It's an n-way generalization+-- of the 'ite' function.+--+-- Minimal complete definition: None, if the type is instance of @Generic@. Otherwise+-- 'symbolicMerge'. Note that most types subject to merging are likely to be+-- trivial instances of @Generic@.+class Mergeable a where+ -- | Merge two values based on the condition. The first argument states+ -- whether we force the then-and-else branches before the merging, at the+ -- word level. This is an efficiency concern; one that we'd rather not+ -- make but unfortunately necessary for getting symbolic simulation+ -- working efficiently.+ symbolicMerge :: Bool -> SBool -> a -> a -> a++ -- | Total indexing operation. @select xs default index@ is intuitively+ -- the same as @xs !! index@, except it evaluates to @default@ if @index@+ -- underflows/overflows.+ select :: (Ord b, SymVal b, Num b, Num (SBV b), OrdSymbolic (SBV b)) => [a] -> a -> SBV b -> a++ -- NB. Earlier implementation of select used the binary-search trick+ -- on the index to chop down the search space. While that is a good trick+ -- in general, it doesn't work for SBV since we do not have any notion of+ -- "concrete" subwords: If an index is symbolic, then all its bits are+ -- symbolic as well. So, the binary search only pays off only if the indexed+ -- list is really humongous, which is not very common in general. (Also,+ -- for the case when the list is bit-vectors, we use SMT tables anyhow.)+ select xs err ind+ | isReal ind = bad "real"+ | isFloat ind = bad "float"+ | isDouble ind = bad "double"+ | hasSign ind = ite (ind .< 0) err (walk xs ind err)+ | True = walk xs ind err+ where bad w = error $ "SBV.select: unsupported " ++ w ++ " valued select/index expression"+ walk [] _ acc = acc+ walk (e:es) i acc = walk es (i-1) (ite (i .== 0) e acc)++ -- Default implementation for 'symbolicMerge' if the type is 'Generic'+ default symbolicMerge :: (G.Generic a, GMergeable (G.Rep a)) => Bool -> SBool -> a -> a -> a+ symbolicMerge = symbolicMergeDefault++-- | If-then-else. This is by definition 'symbolicMerge' with both+-- branches forced. This is typically the desired behavior, but also+-- see 'iteLazy' should you need more laziness.+ite :: Mergeable a => SBool -> a -> a -> a+ite t a b+ | Just r <- unliteral t = if r then a else b+ | True = symbolicMerge True t a b++-- | A Lazy version of ite, which does not force its arguments. This might+-- cause issues for symbolic simulation with large thunks around, so use with+-- care.+iteLazy :: Mergeable a => SBool -> a -> a -> a+iteLazy t a b+ | Just r <- unliteral t = if r then a else b+ | True = symbolicMerge False t a b++-- | Symbolic assert. Check that the given boolean condition is always 'sTrue' in the given path. The+-- optional first argument can be used to provide call-stack info via GHC's location facilities.+sAssert :: HasKind a => Maybe CallStack -> String -> SBool -> SBV a -> SBV a+sAssert cs msg cond x+ | Just mustHold <- unliteral cond+ = if mustHold+ then x+ else error $ show $ SafeResult ((locInfo . getCallStack) `fmap` cs, msg, Satisfiable defaultSMTCfg (SMTModel [] Nothing [] []))+ | True+ = SBV $ SVal k $ Right $ cache r+ where k = kindOf x+ r st = do xsv <- sbvToSV st x+ let pc = getPathCondition st+ -- We're checking if there are any cases where the path-condition holds, but not the condition+ -- Any violations of this, should be signaled, i.e., whenever the following formula is satisfiable+ mustNeverHappen = pc .&& sNot cond+ cnd <- sbvToSV st mustNeverHappen+ addAssertion st cs msg cnd+ return xsv++ locInfo ps = intercalate ",\n " (map loc ps)+ where loc (f, sl) = concat [srcLocFile sl, ":", show (srcLocStartLine sl), ":", show (srcLocStartCol sl), ":", f]++-- | Merge two symbolic values, at kind @k@, possibly @force@'ing the branches to make+-- sure they do not evaluate to the same result. This should only be used for internal purposes;+-- as default definitions provided should suffice in many cases. (i.e., End users should+-- only need to define 'symbolicMerge' when needed; which should be rare to start with.)+symbolicMergeWithKind :: Kind -> Bool -> SBool -> SBV a -> SBV a -> SBV a+symbolicMergeWithKind k force (SBV t) (SBV a) (SBV b) = SBV (svSymbolicMerge k force t a b)++instance SymVal a => Mergeable (SBV a) where+ symbolicMerge force t x y+ -- Carefully use the kindOf instance to avoid strictness issues.+ | force = symbolicMergeWithKind (kindOf x) True t x y+ | True = symbolicMergeWithKind (kindOf (Proxy @a)) False t x y+ -- Custom version of select that translates to SMT-Lib tables at the base type of words+ select xs err ind+ | SBV (SVal _ (Left c)) <- ind = case cvVal c of+ CInteger i -> if i < 0 || i >= genericLength xs+ then err+ else xs `genericIndex` i+ _ -> error $ "SBV.select: unsupported " ++ show (kindOf ind) ++ " valued select/index expression"+ select xsOrig err ind = xs `seq` SBV (SVal kElt (Right (cache r)))+ where kInd = kindOf ind+ kElt = kindOf err+ -- Based on the index size, we need to limit the elements. For instance if the index is 8 bits, but there+ -- are 257 elements, that last element will never be used and we can chop it of..+ xs = case kindOf ind of+ KBounded False i -> genericTake ((2::Integer) ^ (fromIntegral i :: Integer)) xsOrig+ KBounded True i -> genericTake ((2::Integer) ^ (fromIntegral (i-1) :: Integer)) xsOrig+ KUnbounded -> xsOrig+ _ -> error $ "SBV.select: unsupported " ++ show (kindOf ind) ++ " valued select/index expression"+ r st = do sws <- mapM (sbvToSV st) xs+ swe <- sbvToSV st err+ if all (== swe) sws -- off-chance that all elts are the same. Note that this also correctly covers the case when list is empty.+ then return swe+ else do idx <- getTableIndex st kInd kElt sws+ swi <- sbvToSV st ind+ let len = length xs+ -- NB. No need to worry here that the index might be < 0; as the SMTLib translation takes care of that automatically+ newExpr st kElt (SBVApp (LkUp (idx, kInd, kElt, len) swi swe) [])++-- | Construct a useful error message if we hit an unmergeable case.+cannotMerge :: String -> String -> String -> a+cannotMerge typ why hint = error $ unlines [ ""+ , "*** Data.SBV.Mergeable: Cannot merge instances of " ++ typ ++ "."+ , "*** While trying to do a symbolic if-then-else with incompatible branch results."+ , "***"+ , "*** " ++ why+ , "*** "+ , "*** Hint: " ++ hint+ ]++-- | Merge concrete values that can be checked for equality+concreteMerge :: Show a => String -> String -> (a -> a -> Bool) -> a -> a -> a+concreteMerge t st eq x y+ | x `eq` y = x+ | True = cannotMerge t+ ("Concrete values can only be merged when equal. Got: " ++ show x ++ " vs. " ++ show y)+ ("Use an " ++ st ++ " field if the values can differ.")++-- Mergeable instances for List/Maybe/Either/Array are useful, but can+-- throw exceptions if there is no structural matching of the results+-- It's a question whether we should really keep them..++-- Lists+instance Mergeable a => Mergeable [a] where+ symbolicMerge f t xs ys+ | lxs == lys = zipWith (symbolicMerge f t) xs ys+ | True = cannotMerge "lists"+ ("Branches produce different sizes: " ++ show lxs ++ " vs " ++ show lys ++ ". Must have the same length.")+ "Use the 'SList' type (and Data.SBV.List routines) to model fully symbolic lists."+ where (lxs, lys) = (length xs, length ys)++-- NonEmpty+instance Mergeable a => Mergeable (NonEmpty a) where+ symbolicMerge f t xs ys+ | lxs == lys = NE.zipWith (symbolicMerge f t) xs ys+ | True = cannotMerge "non-empty lists"+ ("Branches produce different sizes: " ++ show lxs ++ " vs " ++ show lys ++ ". Must have the same length.")+ "Use the 'SList' type (and Data.SBV.List routines) to model fully symbolic lists."+ where (lxs, lys) = (length xs, length ys)++-- ZipList+instance Mergeable a => Mergeable (ZipList a) where+ symbolicMerge force test (ZipList xs) (ZipList ys)+ = ZipList (symbolicMerge force test xs ys)++-- Maybe+instance Mergeable a => Mergeable (Maybe a) where+ symbolicMerge _ _ Nothing Nothing = Nothing+ symbolicMerge f t (Just a) (Just b) = Just $ symbolicMerge f t a b+ symbolicMerge _ _ a b = cannotMerge "'Maybe' values"+ ("Branches produce different constructors: " ++ show (k a, k b))+ "Instead of an option type, try using a valid bit to indicate when a result is valid."+ where k Nothing = "Nothing"+ k _ = "Just"++-- Either+instance (Mergeable a, Mergeable b) => Mergeable (Either a b) where+ symbolicMerge f t (Left a) (Left b) = Left $ symbolicMerge f t a b+ symbolicMerge f t (Right a) (Right b) = Right $ symbolicMerge f t a b+ symbolicMerge _ _ a b = cannotMerge "'Either' values"+ ("Branches produce different constructors: " ++ show (k a, k b))+ "Consider using a product type by a tag instead."+ where k (Left _) = "Left"+ k (Right _) = "Right"++-- Arrays+instance (Ix a, Mergeable b) => Mergeable (Array a b) where+ symbolicMerge f t a b+ | ba == bb = DA.listArray ba (zipWith (symbolicMerge f t) (elems a) (elems b))+ | True = cannotMerge "'Array' values"+ ("Branches produce different ranges: " ++ show (k ba, k bb))+ "Consider using SBV's native 'SArray' abstraction."+ where [ba, bb] = map bounds [a, b]+ k = rangeSize++-- Functions+instance Mergeable b => Mergeable (a -> b) where+ symbolicMerge f t g h x = symbolicMerge f t (g x) (h x)+ {- Following definition, while correct, is utterly inefficient. Since the+ application is delayed, this hangs on to the inner list and all the+ impending merges, even when ind is concrete. Thus, it's much better to+ simply use the default definition for the function case.+ -}+ -- select xs err ind = \x -> select (map ($ x) xs) (err x) ind++-- 2-Tuple+instance (Mergeable a, Mergeable b) => Mergeable (a, b) where+ symbolicMerge f t (i0, i1) (j0, j1) = ( symbolicMerge f t i0 j0+ , symbolicMerge f t i1 j1+ )++ select xs (err1, err2) ind = ( select as err1 ind+ , select bs err2 ind+ )+ where (as, bs) = unzip xs++-- 3-Tuple+instance (Mergeable a, Mergeable b, Mergeable c) => Mergeable (a, b, c) where+ symbolicMerge f t (i0, i1, i2) (j0, j1, j2) = ( symbolicMerge f t i0 j0+ , symbolicMerge f t i1 j1+ , symbolicMerge f t i2 j2+ )++ select xs (err1, err2, err3) ind = ( select as err1 ind+ , select bs err2 ind+ , select cs err3 ind+ )++ where (as, bs, cs) = unzip3 xs++-- 4-Tuple+instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d) => Mergeable (a, b, c, d) where+ symbolicMerge f t (i0, i1, i2, i3) (j0, j1, j2, j3) = ( symbolicMerge f t i0 j0+ , symbolicMerge f t i1 j1+ , symbolicMerge f t i2 j2+ , symbolicMerge f t i3 j3+ )++ select xs (err1, err2, err3, err4) ind = ( select as err1 ind+ , select bs err2 ind+ , select cs err3 ind+ , select ds err4 ind+ )+ where (as, bs, cs, ds) = unzip4 xs++-- 5-Tuple+instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e) => Mergeable (a, b, c, d, e) where+ symbolicMerge f t (i0, i1, i2, i3, i4) (j0, j1, j2, j3, j4) = ( symbolicMerge f t i0 j0+ , symbolicMerge f t i1 j1+ , symbolicMerge f t i2 j2+ , symbolicMerge f t i3 j3+ , symbolicMerge f t i4 j4+ )++ select xs (err1, err2, err3, err4, err5) ind = ( select as err1 ind+ , select bs err2 ind+ , select cs err3 ind+ , select ds err4 ind+ , select es err5 ind+ )+ where (as, bs, cs, ds, es) = unzip5 xs++-- 6-Tuple+instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f) => Mergeable (a, b, c, d, e, f) where+ symbolicMerge f t (i0, i1, i2, i3, i4, i5) (j0, j1, j2, j3, j4, j5) = ( symbolicMerge f t i0 j0+ , symbolicMerge f t i1 j1+ , symbolicMerge f t i2 j2+ , symbolicMerge f t i3 j3+ , symbolicMerge f t i4 j4+ , symbolicMerge f t i5 j5+ )++ select xs (err1, err2, err3, err4, err5, err6) ind = ( select as err1 ind+ , select bs err2 ind+ , select cs err3 ind+ , select ds err4 ind+ , select es err5 ind+ , select fs err6 ind+ )+ where (as, bs, cs, ds, es, fs) = unzip6 xs++-- 7-Tuple+instance (Mergeable a, Mergeable b, Mergeable c, Mergeable d, Mergeable e, Mergeable f, Mergeable g) => Mergeable (a, b, c, d, e, f, g) where+ symbolicMerge f t (i0, i1, i2, i3, i4, i5, i6) (j0, j1, j2, j3, j4, j5, j6) = ( symbolicMerge f t i0 j0+ , symbolicMerge f t i1 j1+ , symbolicMerge f t i2 j2+ , symbolicMerge f t i3 j3+ , symbolicMerge f t i4 j4+ , symbolicMerge f t i5 j5+ , symbolicMerge f t i6 j6+ )++ select xs (err1, err2, err3, err4, err5, err6, err7) ind = ( select as err1 ind+ , select bs err2 ind+ , select cs err3 ind+ , select ds err4 ind+ , select es err5 ind+ , select fs err6 ind+ , select gs err7 ind+ )+ where (as, bs, cs, ds, es, fs, gs) = unzip7 xs++-- Base types are mergeable so long as they are equal+instance Mergeable () where symbolicMerge _ _ = concreteMerge "()" "()" (==)+instance Mergeable Integer where symbolicMerge _ _ = concreteMerge "Integer" "SInteger" (==)+instance Mergeable Bool where symbolicMerge _ _ = concreteMerge "Bool" "SBool" (==)+instance Mergeable Char where symbolicMerge _ _ = concreteMerge "Char" "SChar" (==)+instance Mergeable Float where symbolicMerge _ _ = concreteMerge "Float" "SFloat" fpIsEqualObjectH+instance Mergeable Double where symbolicMerge _ _ = concreteMerge "Double" "SDouble" fpIsEqualObjectH+instance Mergeable Word8 where symbolicMerge _ _ = concreteMerge "Word8" "SWord8" (==)+instance Mergeable Word16 where symbolicMerge _ _ = concreteMerge "Word16" "SWord16" (==)+instance Mergeable Word32 where symbolicMerge _ _ = concreteMerge "Word32" "SWord32" (==)+instance Mergeable Word64 where symbolicMerge _ _ = concreteMerge "Word64" "SWord64" (==)+instance Mergeable Int8 where symbolicMerge _ _ = concreteMerge "Int8" "SInt8" (==)+instance Mergeable Int16 where symbolicMerge _ _ = concreteMerge "Int16" "SInt16" (==)+instance Mergeable Int32 where symbolicMerge _ _ = concreteMerge "Int32" "SInt32" (==)+instance Mergeable Int64 where symbolicMerge _ _ = concreteMerge "Int64" "SInt64" (==)++-- Arbitrary product types, using GHC.Generics+--+-- NB: Because of the way GHC.Generics works, the implementation of+-- symbolicMerge' is recursive. The derived instance for @data T a = T a a a a@+-- resembles that for (a, (a, (a, a))), not the flat 4-tuple (a, a, a, a). This+-- difference should have no effect in practice. Note also that, unlike the+-- hand-rolled tuple instances, the generic instance does not provide a custom+-- 'select' implementation, and so does not benefit from the SMT-table+-- implementation in the 'SBV a' instance.++-- | Not exported. Symbolic merge using the generic representation provided by+-- 'G.Generics'.+symbolicMergeDefault :: (G.Generic a, GMergeable (G.Rep a)) => Bool -> SBool -> a -> a -> a+symbolicMergeDefault force t x y = G.to $ symbolicMerge' force t (G.from x) (G.from y)++-- | Not exported. Used only in 'symbolicMergeDefault'. Instances are provided for+-- the generic representations of product types where each element is Mergeable.+class GMergeable f where+ symbolicMerge' :: Bool -> SBool -> f a -> f a -> f a++{-+ - N.B. A V1 instance like the below would be wrong!+ - Why? Because inSBV, we use empty data to mean "uninterpreted" sort; not+ - something that has no constructors. Perhaps that was a bad design+ - decision. So, do not allow merging of such values!+instance GMergeable V1 where+ symbolicMerge' _ _ x _ = x+-}++instance GMergeable U1 where+ symbolicMerge' _ _ _ _ = U1++instance (Mergeable c) => GMergeable (K1 i c) where+ symbolicMerge' force t (K1 x) (K1 y) = K1 $ symbolicMerge force t x y++instance (GMergeable f) => GMergeable (M1 i c f) where+ symbolicMerge' force t (M1 x) (M1 y) = M1 $ symbolicMerge' force t x y++instance (GMergeable f, GMergeable g) => GMergeable (f :*: g) where+ symbolicMerge' force t (x1 :*: y1) (x2 :*: y2) = symbolicMerge' force t x1 x2 :*: symbolicMerge' force t y1 y2++{- A mergeable instance for sum-types isn't possible. Why? It would something like:++instance (GMergeable f, GMergeable g) => GMergeable (f :+: g) where+ symbolicMerge' force t (L1 x) (L1 y) = L1 $ symbolicMerge' force t x y+ symbolicMerge' force t (R1 x) (R1 y) = R1 $ symbolicMerge' force t x y+ symbolicMerge' force t l r+ | Just tv <- unliteral t = if tv then l else r+ | True = ????++There's really no good code to put in ????. We have no way to ask the SMT solver to merge composite values that+have different constructors. Calling "error" here would pass the type-checker, but that simply postpones the problem+to run-time. If you need mergeable on sum-types, you better write one yourself, possibly using the SEither type yourself.+As we have it, you'll get a type-error; which can be hard to read, but is preferable.++NB. This isn't a problem with the generic version of symbolic equality; since we can simply return sFalse if we+see different constructors. Such isn't the case when merging.+-}++-- Bounded instances+instance {-# OVERLAPPABLE #-} (SymVal a, Bounded a) => Bounded (SBV a) where+ minBound = literal minBound+ maxBound = literal maxBound++-- Haskell and SMTLib differ in their default char ranges. In Haskell, maxbound is a lot larger.+-- But in SMTLib, we only go upto 0x2FFFF. So, we adopt the SMTLib variant here. This is hardly+-- an issue in practice, but the discrepancy is disconcerting.+instance {-# OVERLAPPING #-} Bounded SChar where+ minBound = literal (chr 0)+ maxBound = literal (chr 0x2FFFF)++-- | Choose a value that satisfies the given predicate. This is Hillbert's choice, essentially. Note that+-- if the predicate given is not satisfiable (for instance @const sFalse@), then the element returned will be arbitrary.+-- The only guarantee is that if there's at least one element that satisfies the predicate, then the returned+-- element will be one of those that do. The returned element is not guaranteed to be unique, least, greatest etc, unless+-- there happens to be exactly one satisfying element.+some :: forall a. (SymVal a, HasKind a) => String -> (SBV a -> SBool) -> SBV a+some inpName cond = mk f+ where mk = SBV . SVal k . Right . cache++ k = kindOf (Proxy @a)+++ f st = do ctr <- incrementFreshNameCounter st+ let pre = atProxy (Proxy @a) inpName+ nm | ctr == 0 = pre+ | True = pre ++ "_" ++ show ctr+ op <- newUninterpreted st (UIGiven nm) Nothing (SBVType [k]) (UINone False)+ chosen <- newExpr st k $ SBVApp op []+ let ifExists = quantifiedBool $ \(Exists ex) -> cond ex+ internalConstraint st False [] (unSBV (ifExists .=> cond (mk (pure (pure chosen)))))+ pure chosen++-- | Find the final part of a kind that looks like an array+resKind :: Kind -> Kind+resKind (KArray _ k) = resKind k+resKind k = k++-- | SMT definable constants and functions, which can also be uninterpeted.+-- This class captures functions that we can generate standalone-code for+-- in the SMT solver. Note that we also allow uninterpreted constants and+-- functions too. An uninterpreted constant is a value that is indexed by its name. The only+-- property the prover assumes -- about these values are that they are equivalent to themselves; i.e., (for+-- functions) they return the same results when applied to same arguments.+-- We support uninterpreted-functions as a general means of black-box'ing+-- operations that are /irrelevant/ for the purposes of the proof; i.e., when+-- the proofs can be performed without any knowledge about the function itself.+--+-- Minimal complete definition: 'sbvDefineValue'. However, most instances in+-- practice are already provided by SBV, so end-users should not need to define their+-- own instances.+class SMTDefinable a where+ -- | Generate the code for this value as an SMTLib function, instead of+ -- the usual unrolling semantics. This is useful for generating sub-functions+ -- in generated SMTLib problem, or handling recursive (and mutually-recursive)+ -- definitions that wouldn't terminate in an unrolling symbolic simulation context.+ --+ -- __IMPORTANT NOTE__ The string argument names this function. SBV identifies+ -- the function by this name: if you use this function twice (or use it recursively),+ -- it will simply assume this name uniquely identifies the function being defined.+ -- If two calls to 'smtFunction' (or its variants) use the same name but different+ -- bodies, SBV will raise an error at runtime.+ --+ -- Furthermore, if the call to 'smtFunction' happens in the scope of a parameter, you+ -- must make sure the string is chosen to keep it unique per parameter value. For instance,+ -- if you have:+ --+ -- @+ -- bar :: SInteger -> SInteger -> SInteger+ -- bar k = smtFunction "bar" (\x -> x+k) -- Note the capture of k!+ -- @+ --+ -- and you call @bar 2@ and @bar 3@, SBV will detect that the two bodies differ and+ -- raise an error. You should use a concrete argument to make the name unique:+ --+ -- @+ -- bar :: String -> SInteger -> SInteger -> SInteger+ -- bar tag k = smtFunction ("bar_" ++ tag) (\x -> x+k) -- Tag should make the name unique!+ -- @+ --+ -- Then, make sure you use @bar "two" 2@ and @bar "three" 3@ etc. to preserve the invariant.+ --+ -- Additionally, the function argument must not capture any non-constant variables in the context.+ -- You can also define higher-order functions, see 'smtHOFunction' for that purpose.+ smtFunctionDef :: (Typeable a, Lambda Symbolic a) => String -> Measure a -> a -> a++ -- | Register a function. This function is typically not needed as SBV will register functions used+ -- automatically upon first use. However, there are scenarios (in particular query contexts)+ -- where the definition isn't used before query-mode starts, and SBV (for historical reasons)+ -- requires functions to be known before query-mode starts executing. In such cases, use this function+ -- to register them with the system.+ registerFunction :: a -> Symbolic ()++ -- | Uninterpret a value, i.e., add this value as a completely undefined value/function that+ -- the solver is free to instantiate to satisfy other constraints.+ --+ -- __Known issues__+ --+ -- Usually using an uninterpret function will register itself to the solver, but sometimes the laziness+ -- of the evaluation might render this unreliable.+ --+ -- For example, when working with quantifiers and uninterpreted functions with the following code:+ --+ -- > runSMTWith z3 $ do+ -- > let f = uninterpret "f" :: SInteger -> SInteger+ -- > query $ do+ -- > constrain $ \(Forall (b :: SInteger)) -> f b .== f b+ -- > checkSat+ --+ -- The solver will complain about the unknown constant @f (Int)@.+ --+ -- A workaround of this is to explicit register them with 'Data.SBV.Control.registerUISMTFunction':+ --+ -- > runSMTWith z3 $ do+ -- > let f = uninterpret "f" :: SInteger -> SInteger+ -- > registerUISMTFunction f+ -- > query $ do+ -- > constrain $ \(Forall (b :: SInteger)) -> f b .== f b+ -- > checkSat+ --+ -- See https://github.com/LeventErkok/sbv/issues/711 for more info.+ uninterpret :: String -> a++ -- | Uninterpret a value, with named arguments in case of functions. SBV will use these+ -- names when it shows the values for the arguments. If the given names are more than needed+ -- we ignore the excess. If not enough, we add from a stock set of variables.+ uninterpretWithArgs :: String -> [String] -> a++ -- | Uninterpret a value, only for the purposes of code-generation. For execution+ -- and verification the value is used as is. For code-generation, the alternate+ -- definition is used. This is useful when we want to take advantage of native+ -- libraries on the target languages.+ cgUninterpret :: String -> [String] -> a -> a++ -- | More generalized form of uninterpretation that wraps 'sbvDefineValueFun';+ -- this function should not be needed by end-user-code+ sbvDefineValue :: UIName -> Maybe [String] -> UIKind a -> a++ -- | The most generalized form of uninterpretation, that generates an+ -- uninterpreted function over a sequence of 'SBVs' values; this function is+ -- internal-only, and should not be needed by end-user-code+ sbvDefineValueFun :: UIName -> Maybe [String] -> SymValInsts as ->+ UIKind (SBVs as -> a) -> SBVs as -> a++ -- | A synonym for 'uninterpret'. Allows us to create variables without+ -- having to call 'free' explicitly, i.e., without being in the symbolic monad.+ sym :: String -> a++ -- | Like 'sym', but appends the type's kind to the name, ensuring uniqueness across+ -- different type instantiations of the same polymorphic definition. Used internally by sCase.+ symWithKind :: String -> a+ symWithKind = sym++ -- | Render an uninterpeted value as an SMTLib definition+ sbv2smt :: ExtractIO m => a -> m String++ -- | Render an uninterpeted value function as an SMTLib definition+ sbvFun2smt :: (SymVals as, ExtractIO m) => (SBVs as -> a) -> m String++ -- | Make this name a constructor, coming from an ADT. Only used internally+ mkADTConstructor :: HasKind a => String -> a+ mkADTTester :: HasKind a => String -> a+ mkADTAccessor :: HasKind a => String -> a++ {-# MINIMAL sbvDefineValueFun, sbvFun2smt, registerFunction #-}++ -- defaults:+ uninterpret nm = sbvDefineValue (UIGiven nm) Nothing $ UIFree True+ uninterpretWithArgs nm as = sbvDefineValue (UIGiven nm) (Just as) $ UIFree True+ cgUninterpret nm code v = sbvDefineValue (UIGiven nm) Nothing $ UICodeC (v, code)+ sym = uninterpret+ sbv2smt a = sbvFun2smt (\(_ :: SBVs RNil) -> a)++ sbvDefineValue nm mbArgs k =+ sbvDefineValueFun nm mbArgs SymValsNil (fmap const k) SBVsNil++ mkADTConstructor nm = let k = resKind (kindOf v); v = sbvDefineValue (UIADT (ADTConstructor nm k)) Nothing $ UIFree True in v+ mkADTTester nm = let k = resKind (kindOf v); v = sbvDefineValue (UIADT (ADTTester nm k)) Nothing $ UIFree True in v+ mkADTAccessor nm = let k = resKind (kindOf v); v = sbvDefineValue (UIADT (ADTAccessor nm k)) Nothing $ UIFree True in v++ smtFunctionDef nm msr v = sbvDefineValue (UIGiven (atProxy (Proxy @a) nm)) Nothing+ $ UIFun (v, \st fk -> do+ let funcNm = atProxy (Proxy @a) nm+ (def, info) <- lambdaWithInfo st TopLevel fk v+ -- Record LambdaInfo for SCC-aware mutual recursion checking+ modifyIORef' (rFuncLambdaInfos st) (Map.insert funcNm info)+ let barFuncNm = barify funcNm+ isSelfRec = any (\(_, SBVApp op _) -> case op of+ Uninterpreted n -> n == barFuncNm+ _ -> False)+ (liAssignments info)+ hasCrossRefs = any (\(_, SBVApp op _) -> case op of+ Uninterpreted n -> n /= barFuncNm+ _ -> False)+ (liAssignments info)+ case msr of+ AutoMeasure -> do+ when isSelfRec $+ modifyIORef' (rMeasureChecks st)+ ((funcNm, False, \cfg -> autoGuessOrFail cfg funcNm info) :)+ when hasCrossRefs $+ modifyIORef' (rMeasureChecks st)+ ((funcNm, False, \cfg -> checkMutualFromState cfg funcNm st Nothing) :)+ pure def+ HasMeasure eval helpers -> do+ when isSelfRec $+ modifyIORef' (rMeasureChecks st)+ ((funcNm, False, \cfg -> verifyMeasure cfg funcNm info eval helpers) :)+ when hasCrossRefs $+ modifyIORef' (rMeasureChecks st)+ ((funcNm, False, \cfg -> checkMutualFromState cfg funcNm st (Just eval)) :)+ pure def+ HasContract eval ceval helpers -> do+ when hasCrossRefs $+ modifyIORef' (rMeasureChecks st)+ ((funcNm, False, \cfg -> rejectMutualContractFromState cfg funcNm st) :)+ modifyIORef' (rMeasureChecks st)+ ((funcNm, False, \cfg -> verifyMeasureWithContract cfg funcNm info eval ceval helpers) :)+ pure def+ Productive -> do+ when isSelfRec $+ modifyIORef' (rMeasureChecks st)+ ((funcNm, True, \cfg -> verifyGuardedness cfg funcNm info) :)+ when hasCrossRefs $+ modifyIORef' (rMeasureChecks st)+ ((funcNm, True, \cfg -> checkMutualProductiveFromState cfg funcNm st) :)+ pure def+ Unverified -> do modifyIORef' (rNoTermCheckFunctions st) (Set.insert nm)+ debug (stCfg st) ["[MEASURE] " ++ funcNm ++ ": no termination check (smtFunctionNoTermination)"]+ pure def)+++-- | Define an SMT function. If the function is recursive, SBV will automatically try to+-- prove termination by guessing a measure based on argument types. If the guess fails,+-- use 'smtFunctionWithMeasure' to provide an explicit measure.+smtFunction :: (SMTDefinable a, Typeable a, Lambda Symbolic a) => String -> a -> a+smtFunction nm = smtFunctionDef nm AutoMeasure++-- | Define an SMT function with an explicit termination measure. Use this when 'smtFunction'+-- cannot automatically determine a suitable measure. The measure function takes the same+-- arguments as the original function but returns a value that must be non-negative and+-- strictly decrease at each recursive call.+--+-- The pair @(measure, helpers)@ provides the measure function and a list of auxiliary+-- t'MeasureHelper' properties needed to verify the measure. Each helper is first proven+-- (by running its TP proof), then asserted as an axiom in the measure verification session.+-- Use 'Data.SBV.TP.measureLemma' to create helpers from TP proofs. Pass @[]@ when no helpers are needed.+smtFunctionWithMeasure :: forall f r. (SMTDefinable f, Typeable f, Lambda Symbolic f, Zero r, OrdSymbolic (SBV r), SymVal r, ApplyMeasure f r)+ => String -> (MeasureOf f r, [MeasureHelper]) -> f -> f+smtFunctionWithMeasure nm (mf, helpers) = smtFunctionDef nm (HasMeasure (MeasureEval (applyMeasure @f @r mf)) helpers)++-- | Define an SMT function with a termination measure and a contract (post-condition).+-- Use this for nested recursive functions (like McCarthy's 91 function) where the termination+-- argument depends on the function's return value at smaller inputs.+--+-- The triple @(measure, contract, helpers)@ provides:+--+-- * A measure function (same as 'smtFunctionWithMeasure')+-- * A contract: a predicate on the function's inputs and output that is proven simultaneously+-- with the measure decrease via well-founded induction. The inductive hypothesis provides+-- the contract for all inputs with strictly smaller measure.+-- * A list of auxiliary t'MeasureHelper' properties (pass @[]@ when none are needed)+--+-- For example, for McCarthy's 91 function:+--+-- @+-- mcCarthy91 = smtFunctionWithContract \"mcCarthy91\"+-- ( \\n -> 0 \`smax\` (101 - n)+-- , \\n r -> n .<= 100 .=> r .== 91+-- , []+-- )+-- $ \\n -> ite (n .> 100) (n - 10) (mcCarthy91 (mcCarthy91 (n + 11)))+-- @+--+-- Here the contract says \"for inputs ≤ 100, the result is 91\". This is needed because the outer+-- recursive call @mcCarthy91(mcCarthy91(n + 11))@ requires knowing what @mcCarthy91(n + 11)@ returns+-- in order to verify that the measure decreases.+smtFunctionWithContract :: forall f r. (SMTDefinable f, Typeable f, Lambda Symbolic f, Zero r, OrdSymbolic (SBV r), SymVal r, ApplyMeasure f r, ApplyContract f)+ => String -> (MeasureOf f r, ContractOf f, [MeasureHelper]) -> f -> f+smtFunctionWithContract nm (mf, cf, helpers) = smtFunctionDef nm (HasContract (MeasureEval (applyMeasure @f @r mf))+ (ContractEval (applyContract @f cf))+ helpers)++-- | Define a productive (corecursive) SMT function. Use this for functions that intentionally+-- don't terminate but produce output incrementally, such as infinite list generators.+-- SBV verifies that every recursive call is guarded by a data constructor (list cons, ADT+-- constructor, etc.), ensuring the function is productive.+--+-- @+-- go = smtProductiveFunction \"go\" $ \\start delta -> start .: go (start + delta) delta+-- @+smtProductiveFunction :: (SMTDefinable a, Typeable a, Lambda Symbolic a) => String -> a -> a+smtProductiveFunction nm = smtFunctionDef nm Productive++-- | Define a recursive SMT function without any termination check. The function+-- is emitted as @define-fun-rec@ and the user takes responsibility for well-definedness.+-- Use this for functions where termination is believed but cannot be proven, such as+-- the Collatz function. See "Documentation.SBV.Examples.TP.Collatz" for an example use case.+smtFunctionNoTermination :: (SMTDefinable a, Typeable a, Lambda Symbolic a) => String -> a -> a+smtFunctionNoTermination nm = smtFunctionDef nm Unverified++-- | Kind of uninterpretation+data UIKind a = UIFree Bool -- ^ completely uninterpreted. If Bool is true, then this is curried.+ | UIFun (a, State -> Kind -> IO SMTDef) -- ^ has code for SMTLib, with final type of kind (note this is the result+ -- , not the arguments), which can be generated by calling the function on the state.+ | UICodeC (a, [String]) -- ^ has code for code-generation, i.e., C+ deriving Functor++-- Get the code associated with the UI, unless we've already did this once. (To support recursive defs.)+retrieveUICode :: UIName -> State -> Kind -> UIKind a -> IO UICodeKind+retrieveUICode _ _ _ (UIFree c) = pure $ UINone c+retrieveUICode (UIADT _) _ _ _ = pure $ UINone True+retrieveUICode (UIGiven nm) st fk (UIFun (_, f)) = do+ compilingFuncs <- readIORef (rCompilingFuncs st)+ if nm `Set.member` compilingFuncs+ then -- This name is currently being compiled, so this is a recursive (or mutually recursive) self-call.+ -- Break the cycle by skipping code generation.+ pure $ UINone True+ else do userFuncs <- readIORef (rUserFuncs st)+ sn <- hashStableName <$> makeStableName f+ case Map.lookup nm userFuncs of+ Just (knownHashes, origLevel)+ | sn `Set.member` knownHashes+ -> -- Same closure we've seen before; skip immediately.+ pure $ UINone True+ | True+ -> do -- New closure for an already-compiled name. Compile body in an isolated+ -- throwaway state (to avoid side-effects like duplicate measure registrations+ -- and context-dependent body differences), then compare with the existing definition.+ -- We use the SAME lambda level as the original compilation so that SV names+ -- in the body text match exactly; this avoids fragile string normalization.+ throwaway <- mkNewState ((stCfg st) {verbose = False}) (LambdaGen origLevel)+ modifyIORef' (rCompilingFuncs throwaway) (Set.insert nm)+ -- If the body captures SVals from the live state's context, the throwaway+ -- compilation will throw (e.g., context-mismatch). That is a definite conflict:+ -- the body references different state-bound variables.+ mbD <- C.try (f throwaway fk)+ case mbD of+ Left (_ :: C.SomeException)+ -> conflictError nm+ Right d+ -> do defs <- readIORef (rDefns st)+ case Map.lookup (barify nm) defs of+ Just (oldDef, _)+ | not (smtDefEq d oldDef)+ -> conflictError nm+ _ -> pure ()+ -- Body matches; memoize this StableName hash so future calls+ -- with the same closure skip instantly.+ modifyState st rUserFuncs (Map.adjust (first (Set.insert sn)) nm) (pure ())+ pure $ UINone True+ Nothing+ -> do -- First time seeing this name. Record lambda level for future comparison.+ ll <- readIORef (rLambdaLevel st)+ modifyState st rUserFuncs (Map.insert nm (Set.singleton sn, ll)) (pure ())+ modifyState st rCompilingFuncs (Set.insert nm) (pure ())+ d <- UISMT <$> f st fk+ modifyState st rCompilingFuncs (Set.delete nm) (pure ())+ pure d+retrieveUICode _ _ _ (UICodeC (_, c)) = pure $ UICgC c++-- Get the constant value associated with the UI+retrieveConstCode :: UIKind a -> Maybe a+retrieveConstCode UIFree{} = Nothing+retrieveConstCode (UIFun (v, _)) = Just v+retrieveConstCode (UICodeC (v, _)) = Just v++instance SymVal a => SMTDefinable (SBV a) where+ sbvFun2smt (fn :: SBVs as -> SBV a)+ | SymValsNil <- symValInsts :: SymValInsts as+ , a <- fn SBVsNil+ = do st <- mkNewState defaultSMTCfg (LambdaGen (Just 0))+ s <- lambdaStr st TopLevel (kindOf a) a+ pure $ intercalate "\n" [ "; Automatically generated by SBV. Do not modify!"+ , "; Type: " ++ smtType (kindOf a)+ , show s+ ]+ sbvFun2smt fn = defs2smt (\args -> fn args .== fn args)++ sbvDefineValueFun nm mbArgs insts uiKind args+ | Just v <- retrieveConstCode uiKind+ , foldlSymSBVs (\r x -> r && isConcrete x) True insts args+ = v args+ | ka <- kindOf (Proxy @a)+ = SBV $ SVal ka $ Right $ cache $ \st ->+ do isSMT <- inSMTMode st+ case (isSMT, uiKind) of+ (True, UICodeC (v, _)) -> sbvToSV st (v args)+ _ -> do let ks = symValKinds insts ++ [ka]+ ui <- retrieveUICode nm st ka uiKind+ op <- newUninterpreted st nm mbArgs (SBVType ks) ui+ svs <- rlist2list <$> mapMSBVs (sbvToSV st) args+ mapM_ forceSVArg svs+ newExpr st ka $ SBVApp op svs++ registerFunction x = constrain $ x .== x++ symWithKind nm = sym (nm ++ "_" ++ show (kindOf (Proxy @a)))+++instance (SymVal a, SMTDefinable b) => SMTDefinable (SBV a -> b) where+ sbvFun2smt (fn :: SBVs as -> SBV a -> b) =+ sbvFun2smt (\((SBVsCons as a) :: SBVs (as :> a)) -> fn as a)++ sbvDefineValueFun nm mbArgs insts uiKind args a =+ sbvDefineValueFun nm mbArgs (SymValsCons insts)+ (fmap (\f (SBVsCons xs x) -> f xs x) uiKind) (SBVsCons args a)++ registerFunction f = do let k = kindOf (Proxy @a)+ st <- symbolicEnv+ v <- liftIO $ newInternalVariable st k+ let a = SBV $ SVal k $ Right $ cache (const (pure v))+ registerFunction $ f a++-- Mark the UIKind as uncurried+mkUncurried :: UIKind a -> UIKind a+mkUncurried (UIFree _) = UIFree False+mkUncurried (UIFun a) = UIFun a+mkUncurried (UICodeC a) = UICodeC a+++uncurrySBVs2 :: (SBVs as -> (SBV c, SBV b) -> SBV a) ->+ (SBVs (as :> c :> b) -> SBV a)+uncurrySBVs2 fn (SBVsCons (SBVsCons as c) b) = fn as (c,b)++-- Uncurried functions of two arguments+instance (SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs2++ registerFunction = registerFunction . curry2+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry2 <$> sbvDefineValueFun nm mbArgs insts (fmap curry2 <$> mkUncurried uiKind)++-- Uncurried functions of three arguments+instance (SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs3+ where uncurrySBVs3 :: (SBVs as -> (SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> d :> c :> b) -> SBV a)+ uncurrySBVs3 fn (SBVsCons (SBVsCons (SBVsCons as d) c) b) = fn as (d,c,b)+ registerFunction = registerFunction . curry3+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry3 <$> sbvDefineValueFun nm mbArgs insts (fmap curry3 <$> mkUncurried uiKind)++-- Uncurried functions of four arguments+instance (SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs4+ where uncurrySBVs4 :: (SBVs as -> (SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs4 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons as e) d) c) b) = fn as (e,d,c,b)+ registerFunction = registerFunction . curry4+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry4 <$> sbvDefineValueFun nm mbArgs insts (fmap curry4 <$> mkUncurried uiKind)++-- Uncurried functions of five arguments+instance (SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs5+ where uncurrySBVs5 :: (SBVs as -> (SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs5 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as f) e) d) c) b) = fn as (f,e,d,c,b)+ registerFunction = registerFunction . curry5+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry5 <$> sbvDefineValueFun nm mbArgs insts (fmap curry5 <$> mkUncurried uiKind)++-- Uncurried functions of six arguments+instance (SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs6+ where uncurrySBVs6 :: (SBVs as -> (SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> g :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs6 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as g) f) e) d) c) b) = fn as (g,f,e,d,c,b)++ registerFunction = registerFunction . curry6+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry6 <$> sbvDefineValueFun nm mbArgs insts (fmap curry6 <$> mkUncurried uiKind)++-- Uncurried functions of seven arguments+instance (SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs7+ where uncurrySBVs7 :: (SBVs as -> (SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> h :> g :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs7 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as h) g) f) e) d) c) b) = fn as (h,g,f,e,d,c,b)+ registerFunction = registerFunction . curry7+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry7 <$> sbvDefineValueFun nm mbArgs insts (fmap curry7 <$> mkUncurried uiKind)++-- Uncurried functions of eight arguments+instance (SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs8+ where uncurrySBVs8 :: (SBVs as -> (SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs8 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as i) h) g) f) e) d) c) b) = fn as (i,h,g,f,e,d,c,b)+ registerFunction = registerFunction . curry8+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry8 <$> sbvDefineValueFun nm mbArgs insts (fmap curry8 <$> mkUncurried uiKind)++-- Uncurried functions of nine arguments+instance (SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs9+ where uncurrySBVs9 :: (SBVs as -> (SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs9 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as j) i) h) g) f) e) d) c) b) = fn as (j,i,h,g,f,e,d,c,b)+ registerFunction = registerFunction . curry9+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry9 <$> sbvDefineValueFun nm mbArgs insts (fmap curry9 <$> mkUncurried uiKind)++-- Uncurried functions of ten arguments+instance (SymVal k, SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs10+ where uncurrySBVs10 :: (SBVs as -> (SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> k :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs10 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as k) j) i) h) g) f) e) d) c) b) = fn as (k,j,i,h,g,f,e,d,c,b)+ registerFunction = registerFunction . curry10+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry10 <$> sbvDefineValueFun nm mbArgs insts (fmap curry10 <$> mkUncurried uiKind)++-- Uncurried functions of eleven arguments+instance (SymVal l, SymVal k, SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs11+ where uncurrySBVs11 :: (SBVs as -> (SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> l :> k :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs11 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as l) k) j) i) h) g) f) e) d) c) b) = fn as (l,k,j,i,h,g,f,e,d,c,b)+ registerFunction = registerFunction . curry11+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry11 <$> sbvDefineValueFun nm mbArgs insts (fmap curry11 <$> mkUncurried uiKind)++-- Uncurried functions of twelve arguments+instance (SymVal m, SymVal l, SymVal k, SymVal j, SymVal i, SymVal h, SymVal g, SymVal f, SymVal e, SymVal d, SymVal c, SymVal b, SymVal a, HasKind a) => SMTDefinable ((SBV m, SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) where+ sbvFun2smt = sbvFun2smt . uncurrySBVs12+ where uncurrySBVs12 :: (SBVs as -> (SBV m, SBV l, SBV k, SBV j, SBV i, SBV h, SBV g, SBV f, SBV e, SBV d, SBV c, SBV b) -> SBV a) -> (SBVs (as :> m :> l :> k :> j :> i :> h :> g :> f :> e :> d :> c :> b) -> SBV a)+ uncurrySBVs12 fn (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons (SBVsCons as m) l) k) j) i) h) g) f) e) d) c) b) = fn as (m,l,k,j,i,h,g,f,e,d,c,b)+ registerFunction = registerFunction . curry12+ sbvDefineValueFun nm mbArgs insts uiKind = uncurry12 <$> sbvDefineValueFun nm mbArgs insts (fmap curry12 <$> mkUncurried uiKind)++-- | Symbolic computations provide a context for writing symbolic programs.+instance MonadIO m => SolverContext (SymbolicT m) where+ constrain = imposeConstraint False [] . unSBV . quantifiedBool+ softConstrain = imposeConstraint True [] . unSBV . quantifiedBool+ namedConstraint nm = imposeConstraint False [(":named", nm)] . unSBV . quantifiedBool+ constrainWithAttribute atts = imposeConstraint False atts . unSBV . quantifiedBool++ contextState = symbolicEnv+ setOption o = addNewSMTOption o++ internalVariable k = contextState >>= \st -> liftIO $ do+ sv <- newInternalVariable st k+ pure $ SBV $ SVal k (Right (cache (const (pure sv))))++-- | Generalization of 'Data.SBV.assertWithPenalty'+assertWithPenalty :: MonadSymbolic m => String -> SBool -> Penalty -> m ()+assertWithPenalty nm o p = addSValOptGoal $ unSBV `fmap` AssertWithPenalty nm o p++-- | Class of metrics we can optimize for. Currently, booleans,+-- bounded signed/unsigned bit-vectors, unbounded integers,+-- algebraic reals and floats can be optimized. You can add+-- your instances, but bewared that the 'MetricSpace' should+-- map your type to something the backend solver understands, which+-- are limited to unsigned bit-vectors, reals, and unbounded integers+-- for z3.+--+-- A good reference on these features is given in the following paper:+-- <http://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/nbjorner-scss2014.pdf>.+--+-- Minimal completion: None. However, if @MetricSpace@ is not identical to the type, you want+-- to define 'toMetricSpace'/'annotateForMS', and possibly 'minimize'/'maximize' to add extra constraints as necessary.+class Metric a where+ -- | The metric space we optimize the goal over. Usually the same as the type itself, but not always!+ -- For instance, signed bit-vectors are optimized over their unsigned counterparts, floats are+ -- optimized over their 'Word32' comparable counterparts, etc.+ type MetricSpace a :: Type+ type MetricSpace a = a++ -- | Compute the metric value to optimize.+ toMetricSpace :: SBV a -> SBV (MetricSpace a)++ -- | Compute the value itself from the metric corresponding to it.+ fromMetricSpace :: SBV (MetricSpace a) -> SBV a++ -- | Annotate for the metric space, to clarify the new name. If this result is not identity,+ -- we will add an sObserve on the original.+ annotateForMS :: Proxy a -> String -> String++ -- | Minimizing a metric space+ msMinimize :: (MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()+ msMinimize nm o = do let nm' = annotateForMS (Proxy @a) nm+ when (nm' /= nm) $ sObserve nm (unSBV o)+ addSValOptGoal $ unSBV `fmap` Minimize nm' (toMetricSpace o)++ -- | Maximizing a metric space+ msMaximize :: (MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()+ msMaximize nm o = do let nm' = annotateForMS (Proxy @a) nm+ when (nm' /= nm) $ sObserve nm (unSBV o)+ addSValOptGoal $ unSBV `fmap` Maximize nm' (toMetricSpace o)++ -- if MetricSpace is the same, we can give a default definition+ default toMetricSpace :: (a ~ MetricSpace a) => SBV a -> SBV (MetricSpace a)+ toMetricSpace = id++ default fromMetricSpace :: (a ~ MetricSpace a) => SBV (MetricSpace a) -> SBV a+ fromMetricSpace = id++ -- Annotations to indicate if the metric space transition was needed+ default annotateForMS :: (a ~ MetricSpace a) => Proxy a -> String -> String+ annotateForMS _ s = s++-- Booleans assume True is greater than False+instance Metric Bool where+ type MetricSpace Bool = Word8+ toMetricSpace t = ite t 1 0+ fromMetricSpace w = w ./= 0+ annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"++-- | Generalization of 'Data.SBV.minimize'+minimize :: (Metric a, MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()+minimize = msMinimize++-- | Generalization of 'Data.SBV.maximize'+maximize :: (Metric a, MonadSymbolic m, SolverContext m) => String -> SBV a -> m ()+maximize = msMaximize++-- Unsigned types, integers, and reals directly optimize+instance Metric Word8+instance Metric Word16+instance Metric Word32+instance Metric Word64+instance Metric Integer+instance Metric AlgReal++-- To optimize signed bounded values, we have to adjust to the range+instance Metric Int8 where+ type MetricSpace Int8 = Word8+ toMetricSpace x = sFromIntegral x + 128 -- 2^7+ fromMetricSpace x = sFromIntegral x - 128+ annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"++instance Metric Int16 where+ type MetricSpace Int16 = Word16+ toMetricSpace x = sFromIntegral x + 32768 -- 2^15+ fromMetricSpace x = sFromIntegral x - 32768+ annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"++instance Metric Int32 where+ type MetricSpace Int32 = Word32+ toMetricSpace x = sFromIntegral x + 2147483648 -- 2^31+ fromMetricSpace x = sFromIntegral x - 2147483648+ annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"++instance Metric Int64 where+ type MetricSpace Int64 = Word64+ toMetricSpace x = sFromIntegral x + 9223372036854775808 -- 2^63+ fromMetricSpace x = sFromIntegral x - 9223372036854775808+ annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"++-- | Optimizing 'WordN'+instance (KnownNat n, BVIsNonZero n) => Metric (WordN n)++-- | Optimizing 'IntN'+instance (KnownNat n, BVIsNonZero n) => Metric (IntN n) where+ type MetricSpace (IntN n) = WordN n+ toMetricSpace x = sFromIntegral x + 2 ^ (intOfProxy (Proxy @n) - 1)+ fromMetricSpace x = sFromIntegral x - 2 ^ (intOfProxy (Proxy @n) - 1)+ annotateForMS _ s = "toMetricSpace(" ++ s ++ ")"++-- Quickcheck interface on symbolic-booleans..+instance Testable SBool where+ property (SBV (SVal _ (Left b))) = property (cvToBool b)+ property s = cantQuickCheck $ "Result did not evaluate to a concrete boolean: " ++ show s++instance Testable (Symbolic SBool) where+ property prop = QC.monadicIO $ do (cond, r, modelVals) <- QC.run test+ QC.pre cond+ unless (r || null modelVals) $ QC.monitor (QC.counterexample (complain modelVals))+ QC.assert r+ where test = do (r, Result{resTraces=tvals, resObservables=ovals, resConsts=(_, cs), resConstraints=cstrs, resUIConsts=unints}) <- + C.catch (runSymbolic defaultSMTCfg (Concrete Nothing) prop)+ (\(e :: C.SomeException) -> cantQuickCheck (show e))+++ let cval = fromMaybe (cantQuickCheck "A constraint did not evaluate to a concrete boolean") . (`lookup` cs)+ cond = -- Only pick-up "hard" constraints, as indicated by False in the fist component+ and [cvToBool (cval v) | (False, _, v) <- F.toList cstrs]++ getObservable (nm, f, v) = case v `lookup` cs of+ Just cv -> if f cv then Just (nm, cv) else Nothing+ Nothing -> cantQuickCheck "An observable did not evaluate to a concrete value"++ case map fst unints of+ [] -> case unliteral r of+ Nothing -> cantQuickCheck "The result did not evaluate to a concrete value"+ Just b -> return (cond, b, tvals ++ mapMaybe getObservable ovals)+ uis -> cantQuickCheck $ "Uninterpreted constants remain: " ++ unwords uis++ complain qcInfo = showModel defaultSMTCfg (SMTModel [] Nothing qcInfo [])++-- Complain if what we got isn't something we can quick-check+cantQuickCheck :: String -> a+cantQuickCheck why = error $ unlines [ "*** Data.SBV: Cannot quickcheck the given property."+ , "***"+ , "*** Certain SBV properties cannot be quick-checked. In particular,"+ , "*** SBV can't quick-check in the presence of:"+ , "***"+ , "*** - Uninterpreted constants."+ , "*** - Uninterpreted types."+ , "*** - Floating point operations with rounding modes other than RNE."+ , "*** - Floating point FMA operation, regardless of rounding mode."+ , "*** - Quantified booleans, i.e., uses of Forall/Exists/ExistsUnique."+ , "*** - Uses of quantifiedBool"+ , "*** - Calls to 'observe' (use 'sObserve' instead)"+ , "***"+ , "*** If you can't avoid the above features or run into an issue with"+ , "*** quickcheck even though you haven't used these features, please report this as a bug!"+ , "***"+ , "*** Origin:"+ , "***"+ , why+ ]++-- | Quick check an SBV property. Note that a regular @quickCheck@ call will work just as+-- well. Use this variant if you want to receive the boolean result.+sbvQuickCheck :: Symbolic SBool -> IO Bool+sbvQuickCheck prop = QC.isSuccess `fmap` QC.quickCheckResult prop++-- Quickcheck interface on dynamically-typed values. A run-time check+-- ensures that the value has boolean type.+instance Testable (Symbolic SVal) where+ property m = property $ do s <- m+ when (kindOf s /= KBool) $ error "Cannot quickcheck non-boolean value"+ return (SBV s :: SBool)++-- | Explicit sharing combinator. The SBV library has internal caching/hash-consing mechanisms+-- built in, based on Andy Gill's type-safe observable sharing technique (see: <http://ku-fpg.github.io/files/Gill-09-TypeSafeReification.pdf>).+-- However, there might be times where being explicit on the sharing can help, especially in experimental code. The 'slet' combinator+-- ensures that its first argument is computed once and passed on to its continuation, explicitly indicating the intent of sharing. Most+-- use cases of the SBV library should simply use Haskell's @let@ construct for this purpose.+slet :: forall a b. (HasKind a, HasKind b) => SBV a -> (SBV a -> SBV b) -> SBV b+slet x f = SBV $ SVal k $ Right $ cache r+ where k = kindOf (Proxy @b)+ r st = do xsv <- sbvToSV st x+ let xsbv = SBV $ SVal (kindOf x) (Right (cache (const (return xsv))))+ res = f xsbv+ sbvToSV st res++-- | Class of things that we can logically reduce to a boolean, by saturating and then asserting equivalance to itself+class QSaturate m a where+ qSaturate :: a -> m ()++-- | Base case; simple variable in the symbolic monad+instance SolverContext m => QSaturate m SBool where+ qSaturate b = constrain $ b .== b++-- | Saturate over a universal quantifier+instance (HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (Forall nm a -> r) where+ qSaturate f = qSaturate . f . Forall =<< internalVariable (kindOf (Proxy @a))++-- | Saturate over a pair of universal quantifiers+instance (HasKind a, HasKind b, Monad m, SolverContext m, QSaturate m r) => QSaturate m ((Forall na a, Forall nb b) -> r) where+ qSaturate = qSaturate . curry++-- | Saturate over a pair of existential quantifiers+instance (HasKind a, HasKind b, Monad m, SolverContext m, QSaturate m r) => QSaturate m ((Exists na a, Exists nb b) -> r) where+ qSaturate = qSaturate . curry++-- | Saturate over a number of universal quantifiers+instance (KnownNat n, HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (ForallN n nm a -> r) where+ qSaturate f = qSaturate . f . ForallN =<< replicateM (intOfProxy (Proxy @n)) (internalVariable (kindOf (Proxy @a)))++-- | Saturate over an existential quantifier+instance (HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (Exists nm a -> r) where+ qSaturate f = qSaturate . f . Exists =<< internalVariable (kindOf (Proxy @a))++-- | Saturate over an a number of existential quantifiers+instance (KnownNat n, HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (ExistsN n nm a -> r) where+ qSaturate f = qSaturate . f . ExistsN =<< replicateM (intOfProxy (Proxy @n)) (internalVariable (kindOf (Proxy @a)))++-- | Saturate over a unique-exists variable+instance (HasKind a, Monad m, SolverContext m, QSaturate m r) => QSaturate m (ExistsUnique nm a -> r) where+ qSaturate f = qSaturate . f . ExistsUnique =<< internalVariable (kindOf (Proxy @a))++-- | Saturate a predicate, but save/restore observables so they're not messed up.+qSaturateSavingObservables :: (Monad m, MonadIO m, SolverContext m, QSaturate m a) => a -> m ()+qSaturateSavingObservables p = do State{rObservables} <- contextState+ curObservables <- liftIO $ readIORef rObservables+ qSaturate p+ liftIO $ writeIORef rObservables curObservables++-- | Equality as a proof method. Allows for+-- very concise construction of equivalence proofs, which is very typical in+-- bit-precise proofs.+infix 4 ===+class Equality a where+ (===) :: a -> a -> IO ThmResult++instance {-# OVERLAPPABLE #-} (SymVal a, EqSymbolic z) => Equality (SBV a -> z) where+ k === l = prove $ \a -> k a .== l a++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, EqSymbolic z) => Equality (SBV a -> SBV b -> z) where+ k === l = prove $ \a b -> k a b .== l a b++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, EqSymbolic z) => Equality ((SBV a, SBV b) -> z) where+ k === l = prove $ \a b -> k (a, b) .== l (a, b)++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> z) where+ k === l = prove $ \a b c -> k a b c .== l a b c++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c) -> z) where+ k === l = prove $ \a b c -> k (a, b, c) .== l (a, b, c)++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> z) where+ k === l = prove $ \a b c d -> k a b c d .== l a b c d++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d) -> z) where+ k === l = prove $ \a b c d -> k (a, b, c, d) .== l (a, b, c, d)++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> z) where+ k === l = prove $ \a b c d e -> k a b c d e .== l a b c d e++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e) -> z) where+ k === l = prove $ \a b c d e -> k (a, b, c, d, e) .== l (a, b, c, d, e)++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> z) where+ k === l = prove $ \a b c d e f -> k a b c d e f .== l a b c d e f++instance {-# OVERLAPPABLE #-}+ (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f) -> z) where+ k === l = prove $ \a b c d e f -> k (a, b, c, d, e, f) .== l (a, b, c, d, e, f)++instance {-# OVERLAPPABLE #-}+ (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, EqSymbolic z) => Equality (SBV a -> SBV b -> SBV c -> SBV d -> SBV e -> SBV f -> SBV g -> z) where+ k === l = prove $ \a b c d e f g -> k a b c d e f g .== l a b c d e f g++instance {-# OVERLAPPABLE #-} (SymVal a, SymVal b, SymVal c, SymVal d, SymVal e, SymVal f, SymVal g, EqSymbolic z) => Equality ((SBV a, SBV b, SBV c, SBV d, SBV e, SBV f, SBV g) -> z) where+ k === l = prove $ \a b c d e f g -> k (a, b, c, d, e, f, g) .== l (a, b, c, d, e, f, g)++-- | Reading a value from an array.+readArray :: forall key val. (SymVal key, SymVal val, HasKind val) => SArray key val -> SBV key -> SBV val+readArray array key+ | eqCheckIsObjectEq ka, Just (ArrayModel tbl def) <- unliteral array, Just _ <- unliteral key, Just r <- locate (unSBV key) def tbl+ = r+ | True+ = symRes+ where symRes = SBV . SVal kb . Right $ cache g+ ka = kindOf (Proxy @key)+ kb = kindOf (Proxy @val)+ g st = do f <- sbvToSV st array+ k <- sbvToSV st key+ newExpr st kb (SBVApp ReadArray [f, k])++ -- return the first value, since we don't bother deleting previous writes. Note that this might+ -- fail if we don't have equality; but that's OK; in that case we'll go symbolic.+ locate skey def vals = go vals+ where go [] = Just $ literal def+ go ((k, v) : rest) = case unliteral (SBV (svStrongEqual skey (unSBV (literal k)))) of+ Nothing -> Nothing+ Just True -> Just $ literal v+ Just False -> go rest++-- | Writing a value to an array. For the concrete case, we don't bother deleting earlier entries, we keep a history. The earlier a value is in the list, the "later" it happened; in a stack fashion.+writeArray :: forall key val. (HasKind key, SymVal key, SymVal val, HasKind val) => SArray key val -> SBV key -> SBV val -> SArray key val+writeArray array key value+ | Just (ArrayModel tbl def) <- unliteral array, Just keyVal <- unliteral key, Just val <- unliteral value+ = literal $ ArrayModel ((keyVal, val) : tbl) def -- It's important that we "cons" the value here, since it takes precedence in a read+ | True+ = SBV . SVal k . Right $ cache g+ where k = KArray (kindOf (Proxy @key)) (kindOf (Proxy @val))++ g st = do arr <- sbvToSV st array+ keyVal <- sbvToSV st key+ val <- sbvToSV st value+ newExpr st k (SBVApp WriteArray [arr, keyVal, val])++-- | Create a constant array. This is a special case of 'lambdaArray', but it creates a+-- simpler expression in the case of constants.+constArray :: forall key val. (SymVal key, SymVal val) => SBV val -> SArray key val+constArray v+ | Just v' <- unliteral v+ = literal $ ArrayModel [] v'+ | True+ = SBV . SVal k . Right $ cache g+ where ka = kindOf (Proxy @key)+ kb = kindOf (Proxy @val)+ k = KArray ka kb++ g st = do sv <- sbvToSV st v+ newExpr st k (SBVApp (ArrayInit (Left (ka, kb))) [sv])++-- | Create a completely free array, with no constraints on it, as an expression.+-- Note that you can create an array in the symbolic context with the regular 'free'+-- calls. (Or 'sArray' if you prefer.) This variant creates it as an expression, i.e.,+-- without having to be in the monadic context. We take a name identifier here as an+-- argument which uniquely identifies this array. Note that this is necessary, as otherwise+-- there would be no way to distinguish two different calls in the pure context. If you+-- use the same name, then you'll get the same array, much like uninterpreted functions.+freeArray :: forall key val. (SymVal key, SymVal val) => String -> SArray key val+freeArray = lambdaArray . uninterpret++-- | Using a lambda as an array. We can turn a function into an array, relating indexes+-- to their values. (That is, passing @f@ would create an array where entry @i@+-- is initialized to value @f i@.) For the special case of initializing with a constant+-- value, either pass @const val@, or use 'constArray'.+--+-- __Arrays vs. uninterpreted functions:__ The basic array theory provides only+-- @select@ ('readArray'), @store@ ('writeArray'), and @const@ ('constArray'). These operations+-- can only construct arrays that differ from a constant in finitely many positions. For instance,+-- the identity array (where @a[i] = i@ for every @i@) cannot be built from 'constArray' plus+-- finitely many 'writeArray' calls. The @lambdaArray@ function goes beyond this: it uses the+-- solver's ability to identify arrays with function spaces, allowing the creation of arrays like+-- @lambdaArray id@ that correspond to arbitrary functions.+--+-- This identification has a model-theoretic consequence. The pure array theory (with only+-- @select@\/@store@\/@const@) is a weaker theory: it admits models where the array sort does+-- not contain all functions, only those reachable by finitely many stores on constants. This means+-- certain formulas are satisfiable in the pure theory (because the solver has more freedom in choosing+-- what arrays exist) that become unsatisfiable when arrays are identified with functions (because the+-- richer array sort can provide counterexamples). In practice, modern solvers use the stronger+-- identification, so @lambdaArray@, 'constArray', and 'writeArray' all operate in this richer setting.+lambdaArray :: forall a b. (SymVal a, HasKind b) => (SBV a -> SBV b) -> SArray a b+lambdaArray f = SBV . SVal k . Right $ cache g+ where k = KArray (kindOf (Proxy @a)) (kindOf (Proxy @b))++ g st = do def <- lambdaStr st TopLevel (kindOf (Proxy @b)) f+ newExpr st k (SBVApp (ArrayInit (Right def)) [])++-- | Turn a constant association-list and a default into a symbolic array.+listArray :: (SymVal a, SymVal b) => [(a, b)] -> b -> SArray a b+listArray ascs def = literal $ ArrayModel ascs def++-- | Create a closure, wrapping the free variables together with the function. When using higher-order functions+-- in SBV (like map), the function passed must be closed, i.e., not have any free variables. If you need to call+-- such a function with a function capturing a free variable, you should create a closure instead.+data Closure env a = Closure { closureEnv :: env+ , closureFun :: env -> a+ }++-- | Define a higher-order function. Similar to 'smtFunction', but when we have a higher-order argument. Note that+-- the higher-order argument cannot have free variables. Also, if the function is recursive, you should call+-- the first argument of the defining function, which SBV uses to tie the recursive knot. (Note that recursive+-- functions defined via 'smtFunction' don't have this latter requirement as they can figure out the recursion+-- automatically. Higher-order functions, unfortunately, can't do this: They firstify their high-order argument,+-- giving the whole function a unique name; captured via the call to the recursive definition.)+smtHOFunction :: forall a b f.+ ( SMTDefinable (a -> SBV b)+ , Lambda Symbolic f+ , Lambda Symbolic (a -> SBV b)+ , HasKind b+ , HasKind f+ , Typeable a+ , Typeable b+ , Typeable f+ ) => String -- prefix to use+ -> f -- The higher-order argument. We're very generic here!+ -> (a -> SBV b) -- The ho-function we're modeling+ -> a -> SBV b -- The resulting function, that can be used as is, and will be rendered in SMTLib without unfolding+smtHOFunction nm f hof arg = SBV $ SVal (kindOf (Proxy @(SBV b))) $ Right $ cache r+ where r st = do SMTLambda lam <- lambdaStr st HigherOrderArg (resKindOf (kindOf (Proxy @f))) f+ let uniqLen = firstifyUniqueLen $ stCfg st+ uniq = take uniqLen (BC.unpack (B.encode (hash (BC.pack (unwords (words lam))))))+ sbvToSV st (smtFunctionDef (atProxy (Proxy @f) nm <> "_" <> uniq) AutoMeasure hof arg)++ -- we get the functions as arrays here, so chase to find the result+ resKindOf (KArray _ k) = resKindOf k+ resKindOf k = k++-- | Like 'smtHOFunction', but with an explicit termination measure. Use this when the+-- auto-guess measure doesn't work for a higher-order recursive function.+smtHOFunctionWithMeasure :: forall a b f r.+ ( SMTDefinable (a -> SBV b)+ , Lambda Symbolic f+ , Lambda Symbolic (a -> SBV b)+ , HasKind b+ , HasKind f+ , Typeable a+ , Typeable b+ , Typeable f+ , Zero r, OrdSymbolic (SBV r), SymVal r+ , ApplyMeasure (a -> SBV b) r+ ) => String -- ^ prefix to use+ -> f -- ^ The higher-order argument+ -> MeasureOf (a -> SBV b) r -- ^ Termination measure+ -> (a -> SBV b) -- ^ The ho-function we're modeling+ -> a -> SBV b -- ^ The resulting function+smtHOFunctionWithMeasure nm f msr hof arg = SBV $ SVal (kindOf (Proxy @(SBV b))) $ Right $ cache r+ where r st = do SMTLambda lam <- lambdaStr st HigherOrderArg (resKindOf (kindOf (Proxy @f))) f+ let uniqLen = firstifyUniqueLen $ stCfg st+ uniq = take uniqLen (BC.unpack (B.encode (hash (BC.pack (unwords (words lam))))))+ sbvToSV st (smtFunctionDef (atProxy (Proxy @f) nm <> "_" <> uniq)+ (HasMeasure (MeasureEval (applyMeasure @(a -> SBV b) @r msr)) [])+ hof arg)++ -- we get the functions as arrays here, so chase to find the result+ resKindOf (KArray _ k) = resKindOf k+ resKindOf k = k++{- HLint ignore module "Reduce duplication" -}+{- HLint ignore module "Eta reduce" -}+{- HLint ignore module "Avoid NonEmpty.unzip" -}+{- HLint ignore module "Redundant id" -}+{- HLint ignore module "Use second" -}
Data/SBV/Core/Operations.hs view
@@ -283,7 +283,7 @@ isInteger = kindOf x == KUnbounded quot' a b | isInteger = div a (abs b) * signum b- | otherwise = quot a b+ | True = quot a b -- | Remainder: Overloaded operation whose meaning depends on the kind at which -- it is used: For unbounded integers, it corresponds to the SMT-Lib@@ -303,7 +303,7 @@ isInteger = kindOf x == KUnbounded rem' a b | isInteger = mod a (abs b)- | otherwise = rem a b+ | True = rem a b -- | Combination of quot and rem svQuotRem :: SVal -> SVal -> (SVal, SVal)
Data/SBV/Core/SizedFloats.hs view
@@ -113,8 +113,8 @@ -- then the total number of floats is 2^sb*(2^eb-1) + 3: All exponents except 11..11 -- is allowed. So we get, 2^eb-1, different combinations, each with a sign, giving -- us 2^sb*(2^eb-1) totals. Then we have two infinities, and one NaN, adding 3 more.-data FP = FP { fpExponentSize :: Int- , fpSignificandSize :: Int+data FP = FP { fpExponentSize :: !Int+ , fpSignificandSize :: !Int , fpValue :: BigFloat } deriving (Eq, G.Data)
Data/SBV/Core/Symbolic.hs view
@@ -19,6 +19,7 @@ {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-}@@ -36,7 +37,7 @@ , SV(..), swKind, trueSV, falseSV, contextOfSV , Op(..), PBOp(..), OvOp(..), FPOp(..), NROp(..), StrOp(..), RegExOp(..), SeqOp(..), SetOp(..), SpecialRelOp(..), ADTOp(..) , RegExp(..), regExpToSMTString, SMTLambda(..)- , Quantifier(..), needsExistentials, SBVContext(..), checkCompatibleContext, VarContext(..)+ , Quantifier(..), needsExistentials, SBVContext(..), globalSBVContext, checkCompatibleContext, VarContext(..) , SBVType(..), svUninterpreted, svUninterpretedNamedArgs, newUninterpreted, prefixNameToUnique , SVal(..) , svMkSymVar, sWordN, sWordN_, sIntN, sIntN_@@ -48,7 +49,7 @@ , getUserName', getUserName , lookupInput , getSValPathCondition, extendSValPathCondition , getTableIndex, sObserve- , SBVPgm(..), MonadSymbolic(..), SymbolicT, Symbolic, runSymbolic, mkNewState, runSymbolicInState, State(..), SMTDef(..), withNewIncState, IncState(..), incrementInternalCounter, incrementFreshNameCounter+ , SBVPgm(..), MonadSymbolic(..), SymbolicT, Symbolic, runSymbolic, mkNewState, runSymbolicInState, State(..), SMTDef(..), smtDefEq, conflictError, withNewIncState, IncState(..), incrementInternalCounter, incrementFreshNameCounter , inSMTMode, SBVRunMode(..), IStage(..), Result(..), ResultInp(..), UICodeKind(..), UIName(..) , registerKind, registerLabel, recordObservable , addAssertion, addNewSMTOption, imposeConstraint, internalConstraint, newInternalVariable, lambdaVar, quantVar@@ -59,6 +60,7 @@ , MonadQuery(..), QueryT(..), Query, QueryState(..), QueryContext(..) , SMTScript(..), Solver(..), SMTSolver(..), SMTResult(..), SMTModel(..), SMTConfig(..), TPOptions(..), SMTEngine, isEmptyModel , validationRequested, outputSVal, ProgInfo(..), mustIgnoreVar, getRootState+ , LambdaInfo(..) ) where import Control.DeepSeq (NFData(..))@@ -92,10 +94,10 @@ import qualified Data.Generics as G (Data(..)) import qualified Data.Generics.Uniplate.Data as G import qualified Data.IntMap.Strict as IMap (IntMap, empty, lookup, insertWith)-import qualified Data.Map.Strict as Map (Map, empty, toList, lookup, insert, size, notMember)-import qualified Data.Set as Set (Set, empty, toList, insert, member)+import qualified Data.Map.Strict as Map (Map, empty, toList, lookup, insert, size, notMember, keysSet)+import qualified Data.Set as Set (Set, empty, toList, insert, member, notMember) import qualified Data.Foldable as F (toList)-import qualified Data.Sequence as S (Seq, empty, (|>), (<|), lookup, elemIndexL)+import qualified Data.Sequence as S (Seq, empty, (|>), lookup, elemIndexL) import qualified Data.Text as T import Data.Text (Text) @@ -765,7 +767,7 @@ , queryConfig :: SMTConfig , queryTerminate :: Maybe C.SomeException -> IO () , queryTimeOutValue :: Maybe Int- , queryAssertionStackDepth :: Int+ , queryAssertionStackDepth :: !Int } -- | Computations which support query operations.@@ -829,9 +831,9 @@ rnf (ResultLamInps xs) = rnf xs -- | Several data about the program-data ProgInfo = ProgInfo { hasQuants :: Bool- , progSpecialRels :: [SpecialRelOp]- , progTransClosures :: [(String, String)]+data ProgInfo = ProgInfo { hasQuants :: !Bool+ , progSpecialRels :: ![SpecialRelOp]+ , progTransClosures :: ![(String, String)] } deriving G.Data @@ -1098,7 +1100,7 @@ -- | Add a new user input addUserInput :: SV -> Name -> Inputs -> Inputs addUserInput sv nm = goAll . goUser- where new = toNamedSV sv nm+ where !new = toNamedSV sv nm goUser = onUserInputs (S.|> new) -- add to the end of the sequence goAll = onAllInputs (Set.insert nm) @@ -1128,52 +1130,83 @@ -- | For debug purposes instance Show SMTDef where show (SMTDef fk frees p body) = unlines [ "-- User defined function:"- , "-- Final return type : " ++ show fk- , "-- Refers to : " ++ intercalate ", " frees- , "-- Parameters : " ++ fromMaybe "NONE" p- , "-- Body : "- , body 2- ]+ , "-- Final return type : " ++ show fk+ , "-- Refers to : " ++ intercalate ", " frees+ , "-- Parameters : " ++ fromMaybe "NONE" p+ , "-- Body : "+ , body 2+ ] -- | NFData instance for SMTDef instance NFData SMTDef where rnf (SMTDef fk frees params body) = rnf fk `seq` rnf frees `seq` rnf params `seq` rnf body +-- | Compare two SMTDef values for semantic equality.+-- The body is @(Int -> String)@ where @Int@ is indentation; we compare rendered output at indent 0.+smtDefEq :: SMTDef -> SMTDef -> Bool+smtDefEq (SMTDef k1 refs1 params1 body1) (SMTDef k2 refs2 params2 body2)+ = k1 == k2 && refs1 == refs2 && params1 == params2 && body1 0 == body2 0++-- | Error for conflicting smtFunction definitions with the same name.+conflictError :: String -> a+conflictError nm = error $ unlines [ ""+ , "*** Data.SBV: Function '" ++ nm ++ "' defined with conflicting bodies."+ , "***"+ , "*** Two calls to smtFunction (or related) used the name '" ++ nm ++ "'"+ , "*** but with different definitions. This would generate conflicting"+ , "*** SMTLib define-fun-rec declarations."+ , "***"+ , "*** Please use a unique name for each distinct function."+ ]++-- | Information about a compiled lambda body, used for measure verification.+data LambdaInfo = LambdaInfo+ { liAssignments :: S.Seq (SV, SBVExpr) -- ^ The expression DAG+ , liParams :: [(Quantifier, SV)] -- ^ Formal parameters with quantifier+ , liOutput :: SV -- ^ The output node+ , liConsts :: [(SV, CV)] -- ^ Constants used+ }+ -- | The state of the symbolic interpreter-data State = State { sbvContext :: SBVContext- , pathCond :: SVal -- ^ kind KBool- , stCfg :: SMTConfig- , startTime :: UTCTime- , rProgInfo :: IORef ProgInfo- , runMode :: IORef SBVRunMode- , rIncState :: IORef IncState- , rCInfo :: IORef [(String, CV)]- , rObservables :: IORef (S.Seq (Name, CV -> Bool, SV))- , rctr :: IORef Int -- Used for numbering SVs- , freshNameCtr :: IORef Int -- Used for calls to some- , rLambdaLevel :: IORef (Maybe Int) -- If Nothing, then top-level lambda- , rUsedKinds :: IORef KindSet- , rUsedLbls :: IORef (Set.Set String)- , rinps :: IORef Inputs- , rlambdaInps :: IORef LambdaInputs- , rConstraints :: IORef (S.Seq (Bool, [(String, String)], SV))- , rPartitionVars :: IORef [String]- , routs :: IORef [SV]- , rtblMap :: IORef TableMap- , spgm :: IORef SBVPgm- , rconstMap :: IORef CnstMap- , rexprMap :: IORef ExprMap- , rUIMap :: IORef UIMap- , rUserFuncs :: IORef (Set.Set String) -- Functions that the user wanted explicit code generation for- , rCgMap :: IORef CgMap- , rDefns :: IORef [(String, (SMTDef, SBVType))]- , rSMTOptions :: IORef [SMTOption]- , rOptGoals :: IORef [Objective (SV, SV)]- , rAsserts :: IORef [(String, Maybe CallStack, SV)]- , rOutstandingAsserts :: IORef Bool -- Did we send an assert after the last check-sat call?- , rSVCache :: IORef (Cache SV)- , rQueryState :: IORef (Maybe QueryState)- , parentState :: Maybe State -- Pointer to our parent if we're in a sublevel+data State = State { sbvContext :: SBVContext+ , pathCond :: SVal -- ^ kind KBool+ , stCfg :: SMTConfig+ , startTime :: UTCTime+ , rProgInfo :: IORef ProgInfo+ , runMode :: IORef SBVRunMode+ , rIncState :: IORef IncState+ , rCInfo :: IORef [(String, CV)]+ , rObservables :: IORef (S.Seq (Name, CV -> Bool, SV))+ , rctr :: IORef Int -- Used for numbering SVs+ , freshNameCtr :: IORef Int -- Used for calls to some+ , rLambdaLevel :: IORef (Maybe Int) -- If Nothing, then top-level lambda+ , rUsedKinds :: IORef KindSet+ , rUsedLbls :: IORef (Set.Set String)+ , rinps :: IORef Inputs+ , rlambdaInps :: IORef LambdaInputs+ , rConstraints :: IORef (S.Seq (Bool, [(String, String)], SV))+ , rPartitionVars :: IORef [String]+ , routs :: IORef [SV]+ , rtblMap :: IORef TableMap+ , spgm :: IORef SBVPgm+ , rconstMap :: IORef CnstMap+ , rexprMap :: IORef ExprMap+ , rUIMap :: IORef UIMap+ , rUserFuncs :: IORef (Map.Map String (Set.Set Int, Maybe Int)) -- Functions with explicit code generation; maps name to (verified StableName hashes, lambda level at first compilation)+ , rCompilingFuncs :: IORef (Set.Set String) -- Functions currently being compiled (used to detect recursive self-calls vs. genuine conflicts)+ , rCgMap :: IORef CgMap+ , rDefns :: IORef (Map.Map String (SMTDef, SBVType))+ , rMeasureChecks :: IORef [(String, Bool, SMTConfig -> IO ())] -- Measure checks for recursive functions. Bool is True for productive (guarded), False for terminating.+ , rFuncLambdaInfos :: IORef (Map.Map String LambdaInfo) -- LambdaInfo for all smtFunction definitions, used for mutual recursion checking+ , rSkipMeasureChecks :: IORef Bool -- If True, skip measure checking (used by TP and checker itself)+ , rNoTermCheckFunctions :: IORef (Set.Set String) -- Functions defined with smtFunctionNoTermination (no termination check)+ , rSMTOptions :: IORef [SMTOption]+ , rOptGoals :: IORef [Objective (SV, SV)]+ , rAsserts :: IORef [(String, Maybe CallStack, SV)]+ , rOutstandingAsserts :: IORef Bool -- Did we send an assert after the last check-sat call?+ , rSVCache :: IORef (Cache SV)+ , rQueryState :: IORef (Maybe QueryState)+ , parentState :: Maybe State -- Pointer to our parent if we're in a sublevel } -- | Chase to the root state. No infinite chains!@@ -1251,9 +1284,8 @@ R.modifyIORef' (field incState) update -- | Add an observable--- notice that we cons like a list, we should build at the end of the seq, but cons to preserve semantics for now recordObservable :: State -> String -> (CV -> Bool) -> SV -> IO ()-recordObservable st (T.pack -> nm) chk sv = modifyState st rObservables ((nm, chk, sv) S.<|) (return ())+recordObservable st (T.pack -> nm) chk sv = modifyState st rObservables (S.|> (nm, chk, sv)) (return ()) -- | Increment the variable counter incrementInternalCounter :: State -> IO Int@@ -1343,7 +1375,14 @@ isCurried <- case uiCode of UINone c -> pure c- UISMT d -> do modifyState st rDefns (\defs -> (nm, (d, t)) : filter (\(onm, _) -> onm /= nm) defs)+ UISMT d -> do -- Check for conflicting definitions with the same name+ defs <- readIORef (rDefns st)+ case Map.lookup nm defs of+ Just (oldDef, _)+ | not (smtDefEq d oldDef)+ -> conflictError nm+ _ -> pure ()+ modifyState st rDefns (Map.insert nm (d, t)) $ noInteractive [ "Defined functions (smtFunction):" , " Name: " ++ nm ++ extraComment , " Type: " ++ show t@@ -1442,8 +1481,10 @@ existingKinds <- readIORef (rUsedKinds st) -- For ADTs we need to make sure we haven't added it before- let adtExists = case k of- KADT s _ _ -> s `elem` [s' | KADT s' _ _ <- Set.toList existingKinds]+ let adtNameExists s = any (\case KADT s' _ _ -> s == s'; _ -> False) existingKinds++ adtExists = case k of+ KADT s _ _ -> adtNameExists s _ -> False unless adtExists $@@ -1453,9 +1494,9 @@ -- order: In particular, if an uninterpreted kind is already in there, we don't -- want to re-add because double-declaration would be wrong. See 'cvtInc' for details. let needsAdding = case k of- KADT s _ _ -> s `notElem` [s' | KADT s' _ _ <- Set.toList existingKinds]- KList{} -> k `notElem` existingKinds- KTuple nks -> length nks `notElem` [length oks | KTuple oks <- Set.toList existingKinds]+ KADT s _ _ -> not (adtNameExists s)+ KList{} -> k `Set.notMember` existingKinds+ KTuple nks -> not $ any (\case KTuple oks -> length nks == length oks; _ -> False) existingKinds _ -> False when needsAdding $ modifyIncState st rNewKinds (Set.insert k)@@ -1813,10 +1854,15 @@ lambdaInps <- newIORef mempty outs <- newIORef [] tables <- newIORef Map.empty- userFuncs <- newIORef Set.empty+ userFuncs <- newIORef Map.empty+ compilingFuncs <- newIORef Set.empty uis <- newIORef Map.empty cgs <- newIORef Map.empty- defns <- newIORef []+ defns <- newIORef Map.empty+ measureChecks <- newIORef []+ funcLambdaInfos <- newIORef Map.empty+ skipMeasureChecks <- newIORef False+ noTermCheckFuncs <- newIORef Set.empty swCache <- newIORef IMap.empty usedKinds <- newIORef Set.empty usedLbls <- newIORef Set.empty@@ -1829,40 +1875,45 @@ istate <- newIORef =<< newIncState qstate <- newIORef Nothing ctx <- genSBVContext- pure $ State { sbvContext = ctx- , runMode = rm- , stCfg = cfg- , startTime = currTime- , rProgInfo = progInfo- , pathCond = SVal KBool (Left trueCV)- , rIncState = istate- , rCInfo = cInfo- , rObservables = observes- , rctr = ctr- , freshNameCtr = fnctr- , rLambdaLevel = lambda- , rUsedKinds = usedKinds- , rUsedLbls = usedLbls- , rinps = inps- , rlambdaInps = lambdaInps- , routs = outs- , rtblMap = tables- , spgm = pgm- , rconstMap = cmap- , rexprMap = emap- , rUserFuncs = userFuncs- , rUIMap = uis- , rCgMap = cgs- , rDefns = defns- , rSVCache = swCache- , rConstraints = cstrs- , rPartitionVars = pvs- , rSMTOptions = smtOpts- , rOptGoals = optGoals- , rAsserts = asserts- , rOutstandingAsserts = outstandingAsserts- , rQueryState = qstate- , parentState = Nothing+ pure $ State { sbvContext = ctx+ , runMode = rm+ , stCfg = cfg+ , startTime = currTime+ , rProgInfo = progInfo+ , pathCond = SVal KBool (Left trueCV)+ , rIncState = istate+ , rCInfo = cInfo+ , rObservables = observes+ , rctr = ctr+ , freshNameCtr = fnctr+ , rLambdaLevel = lambda+ , rUsedKinds = usedKinds+ , rUsedLbls = usedLbls+ , rinps = inps+ , rlambdaInps = lambdaInps+ , routs = outs+ , rtblMap = tables+ , spgm = pgm+ , rconstMap = cmap+ , rexprMap = emap+ , rUserFuncs = userFuncs+ , rCompilingFuncs = compilingFuncs+ , rUIMap = uis+ , rCgMap = cgs+ , rDefns = defns+ , rMeasureChecks = measureChecks+ , rFuncLambdaInfos = funcLambdaInfos+ , rSkipMeasureChecks = skipMeasureChecks+ , rNoTermCheckFunctions = noTermCheckFuncs+ , rSVCache = swCache+ , rConstraints = cstrs+ , rPartitionVars = pvs+ , rSMTOptions = smtOpts+ , rOptGoals = optGoals+ , rAsserts = asserts+ , rOutstandingAsserts = outstandingAsserts+ , rQueryState = qstate+ , parentState = Nothing } -- | Generalization of 'Data.SBV.runSymbolic'@@ -1952,17 +2003,17 @@ let cnsts = sortBy cmp . map swap . Map.toList $ constMap tbls <- map arrange . sortBy cmp . map swap . Map.toList <$> readIORef tables- ds <- reverse <$> readIORef defns+ defnMap <- readIORef defns+ let ds = Map.toList defnMap+ definedSet = Map.keysSet defnMap unint <- do unints <- Map.toList <$> readIORef uis -- drop those that has a definition associated with it- let defineds = map fst ds- pure [ui | ui@(nm, _) <- unints, nm `notElem` defineds]+ pure [ui | ui@(nm, _) <- unints, nm `Set.notMember` definedSet] knds <- readIORef usedKinds cgMap <- Map.toList <$> readIORef cgs traceVals <- reverse <$> readIORef cInfo- observables <- reverse . fmap (\(n,f,sv) -> (T.unpack n, f, sv)) . F.toList- <$> readIORef observes+ observables <- fmap (\(n,f,sv) -> (T.unpack n, f, sv)) . F.toList <$> readIORef observes extraCstrs <- readIORef cstrs assertions <- reverse <$> readIORef asserts @@ -2225,13 +2276,12 @@ -- | Configuration for TP data TPOptions = TPOptions {- ribbonLength :: Int -- ^ Line length for TP proofs- , quiet :: Bool -- ^ No messages what-so-ever for successful steps. (Will print if something fails)- , printAsms :: Bool -- ^ Print assumptions as they are proven as separate steps.- , printStats :: Bool -- ^ Print time/statistics. If quiet is True, then measureTime is ignored.- , cacheProofs :: Bool -- ^ Treat lemma names as unique, and cache the results. Default: False. Note that this- -- feature is unsound unless you make sure (by some other mechanism) that your lemma names- -- are indeed unique.+ ribbonLength :: Int -- ^ Line length for TP proofs+ , quiet :: Bool -- ^ No messages what-so-ever for successful steps. (Will print if something fails)+ , printAsms :: Bool -- ^ Print assumptions as they are proven as separate steps.+ , printStats :: Bool -- ^ Print time/statistics. If quiet is True, then measureTime is ignored.+ , measuresBeingVerified :: Set.Set String -- ^ Functions whose measures are currently being verified. Used to prevent infinite+ -- recursion when a measureLemma proof uses the function whose measure is being checked. } -- | Ignore internal names and those the user told us to
+ Data/SBV/Core/TH.hs view
@@ -0,0 +1,142 @@+-----------------------------------------------------------------------------+-- |+-- Module : Data.SBV.Core.TH+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer: erkokl@gmail.com+-- Stability : experimental+--+-- Template Haskell utilities for extracting constructor information from+-- algebraic data types. Factored out to avoid circular dependencies.+-----------------------------------------------------------------------------++{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE PackageImports #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TemplateHaskellQuotes #-}+{-# LANGUAGE TupleSections #-}++{-# OPTIONS_GHC -Wall -Werror #-}++module Data.SBV.Core.TH (+ getConstructors+ , bad+ , report+ , sbvName+ ) where++import Data.Maybe (fromMaybe)++import qualified "template-haskell" Language.Haskell.TH as TH+import "template-haskell" Language.Haskell.TH.Syntax as THS (Name(..), OccName(..), NameFlavour(..), PkgName, ModName(..), NameSpace(..))++import Language.Haskell.TH.ExpandSyns as TH++import Data.SBV.Core.Kind (smtType)++-- | Construct a TH name for a value\/function in the @sbv@ package, given+-- the fully qualified module name and the unqualified identifier. This avoids+-- importing the target module (which would create import cycles) while still+-- producing exact 'NameG' names that resolve correctly in generated TH splices.+sbvName :: String -> String -> TH.Name+sbvName modNm fnNm = THS.Name (THS.OccName fnNm) (THS.NameG THS.VarName sbvPkg (THS.ModName modNm))+ where -- Extract the package key from a known cross-module name in the sbv package+ sbvPkg :: THS.PkgName+ sbvPkg = case 'smtType of+ THS.Name _ (THS.NameG _ pkg _) -> pkg+ _ -> error "Data.SBV.Core.TH.sbvName: unexpected name flavour"++bad :: MonadFail m => String -> [String] -> m a+bad what extras = fail $ unlines $ ("mkSymbolic: " ++ what) : map (" " ++) extras++report :: String+report = "Please report this as a feature request."++-- | Collect the constructors+getConstructors :: TH.Name -> TH.Q ([TH.Name], [(TH.Name, [(Maybe TH.Name, TH.Type)])])+getConstructors typeName = do res@(_, cstrs) <- getConstructorsFromType (TH.ConT typeName)++ -- make sure accessors are unique+ let noDup [] = pure ()+ noDup (n:ns)+ | n `elem` ns = bad "Unsupported field accessor definition."+ [ "Multiply used: " ++ TH.nameBase n+ , ""+ , "SBV does not support cases where accessor fields are replicated."+ , "Please use each accessor only once."+ ]+ | True = noDup ns+ noDup [n | (_, fs) <- cstrs, (Just n, _) <- fs]++ pure res++ where getConstructorsFromType :: TH.Type -> TH.Q ([TH.Name], [(TH.Name, [(Maybe TH.Name, TH.Type)])])+ getConstructorsFromType ty = do ty' <- expandSyns ty+ case headCon ty' of+ Just (n, args) -> reifyFromHead n args+ Nothing -> bad "Not a type constructor"+ [ "Name : " ++ show typeName+ , "Type : " ++ show ty+ , "Expanded: " ++ show ty'+ ]++ headCon :: TH.Type -> Maybe (TH.Name, [TH.Type])+ headCon = go []+ where go args (TH.ConT n) = Just (n, reverse args)+ go args (TH.AppT t a) = go (a:args) t+ go args (TH.SigT t _) = go args t+ go args (TH.ParensT t) = go args t+ go _ _ = Nothing++ reifyFromHead :: TH.Name -> [TH.Type] -> TH.Q ([TH.Name], [(TH.Name, [(Maybe TH.Name, TH.Type)])])+ reifyFromHead n args = do info <- TH.reify n+ case info of+ TH.TyConI (TH.DataD _ _ tvs _ cons _) -> (map tvName tvs,) <$> mapM (expandCon (mkSubst tvs args)) cons+ TH.TyConI (TH.NewtypeD _ _ tvs _ con _) -> (map tvName tvs,) <$> mapM (expandCon (mkSubst tvs args)) [con]+ TH.TyConI (TH.TySynD _ tvs rhs) -> getConstructorsFromType (applySubst (mkSubst tvs args) rhs)+ _ -> bad "Unsupported kind"+ [ "Type : " ++ show typeName+ , "Name : " ++ show n+ , "Kind : " ++ show info+ ]++ onSnd f (a, b) = (a,) <$> f b++ expandCon :: [(TH.Name, TH.Type)] -> TH.Con -> TH.Q (TH.Name, [(Maybe TH.Name, TH.Type)])+ expandCon sub (TH.NormalC n fields) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\( _,t) -> (Nothing, t))) fields+ expandCon sub (TH.RecC n fields) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\(fn,_,t) -> (Just fn, t))) fields+ expandCon sub (TH.InfixC (_, t1) n (_, t2)) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub)) [(Nothing, t1), (Nothing, t2)]+ {- These don't have proper correspondences in SMTLib; so ignore.+ expandCon sub (TH.ForallC _ _ c) = expandCon sub c+ expandCon sub (TH.GadtC [n] fields _) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\( _,t) -> (Nothing, t))) fields+ expandCon sub (TH.RecGadtC [n] fields _) = (n,) <$> mapM (onSnd (expandSyns . applySubst sub) . (\(fn,_,t) -> (Just fn, t))) fields+ -}+ expandCon _ c = bad "Unsupported constructor form: "+ [ "Type : " ++ show typeName+ , "Constructor: " ++ show c+ , ""+ , report+ ]++ tvName :: TH.TyVarBndr TH.BndrVis -> TH.Name+ tvName (TH.PlainTV n _) = n+ tvName (TH.KindedTV n _ _) = n++ -- | Make substitution from type variables to actual args+ mkSubst :: [TH.TyVarBndr TH.BndrVis] -> [TH.Type] -> [(TH.Name, TH.Type)]+ mkSubst tvs = zip (map tvName tvs)++ -- | Apply substitution to a Type+ applySubst :: [(TH.Name, TH.Type)] -> TH.Type -> TH.Type+ applySubst sub = go+ where go (TH.VarT n) = fromMaybe (TH.VarT n) (n `lookup` sub)+ go (TH.AppT t1 t2) = TH.AppT (go t1) (go t2)+ go (TH.SigT t k) = TH.SigT (go t) k+ go (TH.ParensT t) = TH.ParensT (go t)+ go (TH.InfixT t1 n t2) = TH.InfixT (go t1) n (go t2)+ go (TH.UInfixT t1 n t2) = TH.UInfixT (go t1) n (go t2)+ go (TH.ForallT bs ctx t) = TH.ForallT bs (map goPred ctx) (go t)+ go t = t++ goPred (TH.AppT t1 t2) = TH.AppT (go t1) (go t2)+ goPred p = p
Data/SBV/Either.hs view
@@ -13,6 +13,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-}@@ -28,6 +29,8 @@ , bimap, first, second -- * Scrutinizing branches of a sum , isLeft, isRight, fromLeft, fromRight+ -- * Case analysis (for sCase quasi-quoter)+ , sCaseEither, getLeft_1, getRight_1 ) where import Prelude hiding (either)@@ -35,7 +38,8 @@ import Data.SBV.Client import Data.SBV.Core.Data-import Data.SBV.Core.Model (ite, OrdSymbolic(..))+import Data.SBV.Core.Model (OrdSymbolic(..))+import Data.SBV.SCase (sCase) #ifdef DOCTEST -- $setup@@ -98,7 +102,10 @@ -> (SBV b -> SBV c) -> SEither a b -> SBV c-either brA brB sab = ite (isLeft sab) (brA (fromLeft sab)) (brB (fromRight sab))+either brA brB sab = [sCase| sab of+ Left x -> brA x+ Right x -> brB x+ |] -- | Map over both sides of a symbolic 'Either' at the same time --
Data/SBV/Lambda.hs view
@@ -20,6 +20,7 @@ module Data.SBV.Lambda ( lambda, lambdaStr+ , lambdaWithInfo, LambdaInfo(..) , constraint, constraintStr , LambdaScope(..) ) where@@ -40,6 +41,7 @@ import Data.IORef (readIORef, modifyIORef') import Data.List import Data.Maybe (fromMaybe)+import qualified Data.Map.Strict as Map import qualified Data.Foldable as F import qualified Data.Set as Set@@ -50,6 +52,8 @@ data LambdaScope = HigherOrderArg -- This lambda will be firstified, hence can't have any free variables | TopLevel -- This lambda is used to represent a quantified axiom, can have free vars +-- LambdaInfo is defined in Data.SBV.Core.Symbolic and re-exported from here for backwards compatibility.+ data Defn = Defn [String] -- The uninterpreted names referred to in the body [String] -- Free variables (i.e., not uninterpreted nor bound in the definition itself) (Maybe [(Quantifier, String)]) -- Param declaration groups, if any@@ -87,46 +91,51 @@ -- don't really impact anything. comp State { -- These are not IORefs; so we share by copying the value; changes won't be copied back- sbvContext = share sbvContext- , pathCond = share pathCond- , startTime = share startTime+ sbvContext = share sbvContext+ , pathCond = share pathCond+ , startTime = share startTime -- These are shared IORef's; and is shared, so they will be copied back to the parent state- , rProgInfo = share rProgInfo- , rIncState = share rIncState- , rCInfo = share rCInfo- , rUsedKinds = share rUsedKinds- , rUsedLbls = share rUsedLbls- , rUIMap = share rUIMap- , rUserFuncs = share rUserFuncs- , rCgMap = share rCgMap- , rDefns = share rDefns- , rSMTOptions = share rSMTOptions- , rOptGoals = share rOptGoals- , rAsserts = share rAsserts- , rOutstandingAsserts = share rOutstandingAsserts- , rPartitionVars = share rPartitionVars+ , rProgInfo = share rProgInfo+ , rIncState = share rIncState+ , rCInfo = share rCInfo+ , rUsedKinds = share rUsedKinds+ , rUsedLbls = share rUsedLbls+ , rUIMap = share rUIMap+ , rUserFuncs = share rUserFuncs+ , rCompilingFuncs = share rCompilingFuncs+ , rCgMap = share rCgMap+ , rDefns = share rDefns+ , rMeasureChecks = share rMeasureChecks+ , rFuncLambdaInfos = share rFuncLambdaInfos+ , rSkipMeasureChecks = share rSkipMeasureChecks+ , rNoTermCheckFunctions = share rNoTermCheckFunctions+ , rSMTOptions = share rSMTOptions+ , rOptGoals = share rOptGoals+ , rAsserts = share rAsserts+ , rOutstandingAsserts = share rOutstandingAsserts+ , rPartitionVars = share rPartitionVars -- Everything else is fresh in the substate; i.e., will not copy back- , stCfg = fresh stCfg- , runMode = fresh runMode- , rctr = fresh rctr- , freshNameCtr = fresh freshNameCtr- , rLambdaLevel = fresh rLambdaLevel- , rtblMap = fresh rtblMap- , rinps = fresh rinps- , rlambdaInps = fresh rlambdaInps- , rConstraints = fresh rConstraints- , rObservables = fresh rObservables- , routs = fresh routs- , spgm = fresh spgm- , rconstMap = fresh rconstMap- , rexprMap = fresh rexprMap- , rSVCache = fresh rSVCache- , rQueryState = fresh rQueryState+ , stCfg = fresh stCfg+ , runMode = fresh runMode+ , rctr = fresh rctr+ , freshNameCtr = fresh freshNameCtr+ , rLambdaLevel = fresh rLambdaLevel+ , rtblMap = fresh rtblMap+ , rinps = fresh rinps+ , rlambdaInps = fresh rlambdaInps+ , rConstraints = fresh rConstraints+ , rObservables = fresh rObservables+ , routs = fresh routs+ , spgm = fresh spgm+ , rconstMap = fresh rconstMap+ , rexprMap = fresh rexprMap+ , rSVCache = fresh rSVCache+ , rQueryState = fresh rQueryState -- keep track of our parent- , parentState = Just inState+ , parentState = Just inState } -- In this case, we expect just one group of parameters, with universal quantification@@ -191,6 +200,38 @@ lambda inState scope fk = lambdaGen scope mkLam inState fk where mkLam (Defn unints _frees params body) = SMTDef fk unints (extractAllUniversals <$> params) body +-- | Like 'lambda', but also returns the sub-state's DAG info for measure verification.+lambdaWithInfo :: (MonadIO m, Lambda (SymbolicT m) a) => State -> LambdaScope -> Kind -> a -> m (SMTDef, LambdaInfo)+lambdaWithInfo inState scope fk f = inSubState scope inState $ \st -> do+ defn <- handleDefn <$> convert st fk (mkLambda st f)+ info <- liftIO $ extractLambdaInfo st+ pure (defn, info)+ where handleDefn d@(Defn _ frees _ _)+ | null frees = mkLam d+ | True = error $ unlines [ ""+ , "*** Data.SBV.Lambda: Detected free variables in a function with a measure."+ , "*** Free vars: " ++ unwords frees+ ]+ mkLam (Defn unints _frees params body) = SMTDef fk unints (extractAllUniversals <$> params) body++-- | Extract DAG information from a lambda sub-state.+extractLambdaInfo :: State -> IO LambdaInfo+extractLambdaInfo st = do+ SBVPgm asgns <- readIORef (spgm st)+ linps <- readIORef (rlambdaInps st)+ outs <- readIORef (routs st)+ cmap <- readIORef (rconstMap st)+ let params = [(q, getSV nsv) | (q, nsv) <- F.toList linps]+ outSV = case F.toList outs of+ [o] -> o+ os -> error $ "Data.SBV.Lambda.extractLambdaInfo: expected exactly one output, got " ++ show (length os)+ pure LambdaInfo { liAssignments = asgns+ , liParams = params+ , liOutput = outSV+ , liConsts = map swap $ Map.toList cmap+ }+ where swap (a, b) = (b, a)+ -- | Create an anonymous lambda, rendered as n SMTLib string. The kind passed is the kind of the final result. lambdaStr :: (MonadIO m, Lambda (SymbolicT m) a) => State -> LambdaScope -> Kind -> a -> m SMTLambda lambdaStr st scope k a = SMTLambda <$> lambdaGen scope mkLam st k a@@ -320,9 +361,9 @@ frees = map show badFrees where (defs, uses) = unzip [(d, u) | (d, SBVApp _ u) <- F.toList asgnsSeq]- allDefs = defs ++ map snd params ++ map fst constants- allUses = concat uses- allFrees = nub allUses \\ nub allDefs+ defSet = Set.fromList (defs ++ map snd params ++ map fst constants)+ useSet = Set.fromList (concat uses)+ allFrees = Set.toList (useSet `Set.difference` defSet) badFrees = filter (not . global . getId . swNodeId) allFrees -- is this a global?
Data/SBV/List.hs view
@@ -22,6 +22,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-}@@ -36,6 +37,9 @@ -- * Deconstructing/Reconstructing , nil, (.:), snoc, head, tail, uncons, init, last, singleton, listToListAt, elemAt, (!!), implode, concat, (++) + -- * Case analysis (for sCase quasi-quoter)+ , list+ -- * Containment , elem, notElem, isInfixOf, isSuffixOf, isPrefixOf @@ -96,7 +100,7 @@ import Data.SBV.Core.Model import Data.SBV.Core.SizedFloats import Data.SBV.Core.Floating-+import Data.SBV.SCase (sCase) import Data.SBV.Tuple import Data.Maybe (isNothing, catMaybes)@@ -107,8 +111,6 @@ import Data.Proxy -import GHC.Exts (IsList(..))- #ifdef DOCTEST -- $setup -- >>> import Prelude hiding (head, tail, init, last, length, take, drop, concat, null, elem, notElem, reverse, (++), (!!), map, foldl, foldr, zip, zipWith, filter, all, any, replicate, lookup, splitAt, concatMap, and, or, sum, product, takeWhile, dropWhile, minimum, maximum)@@ -122,15 +124,6 @@ -- >>> :set -XQuasiQuotes #endif --- | IsList instance allows list literals to be written compactly.-instance SymVal a => IsList (SList a) where- type Item (SList a) = SBV a-- fromList = P.foldr (.:) nil -- Don't use [] here for nil, as this is the very definition of doing overloaded lists- toList x = case unliteral x of- Nothing -> error "IsList.toList used in a symbolic context"- Just xs -> P.map literal xs- -- | Length of a list. -- -- >>> sat $ \(l :: SList Word16) -> length l .== 2@@ -208,6 +201,21 @@ uncons :: SymVal a => SList a -> (SBV a, SList a) uncons l = (head l, tail l) +-- | Case analysis on a symbolic list. If the list is empty, return the first argument.+-- Otherwise, apply the second argument to the head and tail of the list.+--+-- >>> list (0 :: SInteger) (\h _ -> h) ([] :: SList Integer)+-- 0 :: SInteger+-- >>> list (0 :: SInteger) (\h _ -> h) ([3, 4, 5] :: SList Integer)+-- 3 :: SInteger+-- >>> prove $ \(l :: SList Integer) -> null l .|| list sFalse (\_ _ -> sTrue) l+-- Q.E.D.+list :: (SymVal a, SymVal b) => SBV b -> (SBV a -> SList a -> SBV b) -> SList a -> SBV b+list nilCase consCase xs = [sCase| xs of+ [] -> nilCase+ h:ts -> consCase h ts+ |]+ -- | @`init`@ returns all but the last element of the list. Unspecified if the list is empty. -- -- >>> prove $ \(h :: SInteger) t -> init (t ++ [h]) .== t@@ -284,14 +292,6 @@ implode :: SymVal a => [SBV a] -> SList a implode = P.foldr ((++) . \x -> [x]) (literal []) --- | Prepend an element, the traditional @cons@.------ >>> 1 .: 2 .: 3 .: [4, 5, 6 :: SInteger]--- [1,2,3,4,5,6] :: [SInteger]-infixr 5 .:-(.:) :: SymVal a => SBV a -> SList a -> SList a-a .: as = singleton a ++ as -- NB. Don't do "[a] ++ as" here. That type-checks but is recursive due to how overloaded-lists work.- -- | Append an element -- -- >>> [1, 2, 3 :: SInteger] `snoc` 4 `snoc` 5 `snoc` 6@@ -299,15 +299,7 @@ snoc :: SymVal a => SList a -> SBV a -> SList a as `snoc` a = as ++ [a] --- | Empty list. This value has the property that it's the only list with length 0. If you use @OverloadedLists@ extension,--- you can write it as the familiar `[]`.------ >>> prove $ \(l :: SList Integer) -> length l .== 0 .<=> l .== []--- Q.E.D.--- >>> prove $ \(l :: SString) -> length l .== 0 .<=> l .== []--- Q.E.D.-nil :: SymVal a => SList a-nil = literal []+-- nil is defined in Data.SBV.Core.Data and re-exported here. -- | Append two lists. --@@ -378,10 +370,19 @@ -- | @listEq@ is a variant of equality that you can use for lists of floats. It respects @NaN /= NaN@. The reason -- we do not do this automatically is that it complicates proof objectives usually, as it does not simply resolve to -- the native equality check.+--+-- NB. We case-split on @x@ only and use a guard for @y@ being empty, rather than case-splitting on the+-- tuple @(x, y)@. A 4-way tuple match produces a larger and\/or\/not SMTLib tree that z3 struggles with. listEq :: forall a. SymVal a => SList a -> SList a -> SBool listEq | containsFloats (kindOf (Proxy @a))- = smtFunction "listEq" $ \xs ys -> ite (null xs) (null ys) (head xs .== head ys .&& listEq (tail xs) (tail ys))+ = smtFunction "listEq"+ $ \x y -> [sCase| x of+ [] -> null y+ a:xs -> case y of+ [] -> sFalse+ b : ys -> a .== b .&& xs `listEq` ys+ |] | True = (.==) @@ -565,7 +566,11 @@ = literal (P.reverse l') | True = def l- where def = smtFunction "sbv.reverse" $ \xs -> ite (null xs) [] (let (h, t) = uncons xs in def t ++ [h])+ where def = smtFunction "sbv.reverse"+ $ \xs -> [sCase| xs of+ [] -> []+ h:ts -> def ts ++ [h]+ |] -- | A class of mappable functions. In SBV, we make a distinction between closures and regular functions, and -- we instantiate this class appropriately so it can handle both cases.@@ -607,7 +612,11 @@ = literal concResult | True = sbvMap l- where sbvMap = smtHOFunction "sbv.map" f $ \xs -> ite (null xs) [] (let (h, t) = uncons xs in f h .: sbvMap t)+ where sbvMap = smtHOFunction "sbv.map" f+ $ \xs -> [sCase| xs of+ [] -> []+ h : t -> f h .: sbvMap t+ |] -- | Mapping symbolic closures. instance (SymVal env, SymVal a, SymVal b) => SMap (Closure (SBV env) (SBV a -> SBV b)) a b where@@ -617,9 +626,10 @@ | True = sbvMap (tuple (closureEnv, l)) where sbvMap = smtHOFunction "sbv.closureMap" closureFun- $ \envxs -> let (cEnv, xs) = untuple envxs- (h, t) = uncons xs- in ite (null xs) [] (closureFun cEnv h .: sbvMap (tuple (cEnv, t)))+ $ \envxs -> [sCase| envxs of+ (_, []) -> []+ (cEnv, h : t) -> closureFun cEnv h .: sbvMap (tuple (cEnv, t))+ |] -- | @concatMap f xs@ maps f over elements and concats the result. --@@ -640,7 +650,7 @@ -- >>> foldl (\soFar elt -> [elt] ++ soFar) ([] :: SList Integer) [sEnum|1 .. 5|] -- [5,4,3,2,1] :: [SInteger] --- -- Again, we can use 'Data.SBV.List.foldl' in the reverse too:+ -- Again, we can use 'sbv.foldl' in the reverse too: -- -- >>> sat $ \l -> foldl (\soFar elt -> [elt] ++ soFar) ([] :: SList Integer) l .== [5, 4, 3, 2, 1 :: SInteger] -- Satisfiable. Model:@@ -668,11 +678,10 @@ | True = sbvFoldl $ tuple (base, l) where sbvFoldl = smtHOFunction "sbv.foldl" (uncurry f . untuple)- $ \exs -> let (e, xs) = untuple exs- (h, t) = uncons xs- in ite (null xs)- e- (sbvFoldl (tuple (e `f` h, t)))+ $ \exs -> [sCase| exs of+ (e, []) -> e+ (e, h : t) -> sbvFoldl (tuple (e `f` h, t))+ |] -- | Folding left with symbolic closures. instance (SymVal env, SymVal a, SymVal b) => SFoldL (Closure (SBV env) (SBV b -> SBV a -> SBV b)) a b where@@ -682,11 +691,10 @@ | True = sbvFoldl $ tuple (closureEnv, base, l) where sbvFoldl = smtHOFunction "sbv.closureFoldl" closureFun- $ \envxs -> let (cEnv, e, xs) = untuple envxs- (h, t) = uncons xs- in ite (null xs)- e- (sbvFoldl (tuple (cEnv, closureFun closureEnv e h, t)))+ $ \envxs -> [sCase| envxs of+ (_, e, []) -> e+ (cEnv, e, h : t) -> sbvFoldl (tuple (cEnv, closureFun closureEnv e h, t))+ |] -- | A class of right foldable functions. In SBV, we make a distinction between closures and regular functions, and -- we instantiate this class appropriately so it can handle both cases.@@ -722,11 +730,10 @@ | True = sbvFoldr $ tuple (base, l) where sbvFoldr = smtHOFunction "sbv.foldr" (uncurry f . untuple)- $ \exs -> let (e, xs) = untuple exs- (h, t) = uncons xs- in ite (null xs)- e- (h `f` sbvFoldr (tuple (e, t)))+ $ \exs -> [sCase| exs of+ (e, []) -> e+ (e, h : t) -> h `f` sbvFoldr (tuple (e, t))+ |] -- | Folding right with symbolic closures. instance (SymVal env, SymVal a, SymVal b) => SFoldR (Closure (SBV env) (SBV a -> SBV b -> SBV b)) a b where@@ -736,11 +743,10 @@ | True = sbvFoldr $ tuple (closureEnv, base, l) where sbvFoldr = smtHOFunction "sbv.closureFoldr" closureFun- $ \envxs -> let (cEnv, e, xs) = untuple envxs- (h, t) = uncons xs- in ite (null xs)- e- (closureFun closureEnv h (sbvFoldr (tuple (cEnv, e, t))))+ $ \envxs -> [sCase| envxs of+ (_, e, []) -> e+ (cEnv, e, h : t) -> closureFun closureEnv h (sbvFoldr (tuple (cEnv, e, t)))+ |] -- | @`zip` xs ys@ zips the lists to give a list of pairs. The length of the final list is -- the minumum of the lengths of the given lists.@@ -756,7 +762,12 @@ = literal $ P.zip xs' ys' | True = def xs ys- where def = smtFunction "sbv.zip" $ \as bs -> ite (null as .|| null bs) [] (tuple (head as, head bs) .: def (tail as) (tail bs))+ where def = smtFunction "sbv.zip" + $ \x y -> [sCase| tuple (x, y) of+ ([], _ ) -> []+ (_, [] ) -> []+ (a:as, b:bs) -> tuple (a, b) .: def as bs+ |] -- | A class of function that we can zip-with. In SBV, we make a distinction between closures and regular -- functions, and we instantiate this class appropriately so it can handle both cases.@@ -790,10 +801,11 @@ | True = sbvZipWith $ tuple (xs, ys) where sbvZipWith = smtHOFunction "sbv.zipWith" (uncurry f . untuple)- $ \asbs -> let (as, bs) = untuple asbs- in ite (null as .|| null bs)- []- (f (head as) (head bs) .: sbvZipWith (tuple (tail as, tail bs)))+ $ \asbs -> [sCase| asbs of+ ([], _ ) -> []+ (_, [] ) -> []+ (a:as, b:bs) -> f a b .: sbvZipWith (tuple (as, bs))+ |] -- | Zipping with closures. instance (SymVal env, SymVal a, SymVal b, SymVal c) => SZipWith (Closure (SBV env) (SBV a -> SBV b -> SBV c)) a b c where@@ -803,10 +815,11 @@ | True = sbvZipWith $ tuple (closureEnv, xs, ys) where sbvZipWith = smtHOFunction "sbv.closureZipWith" closureFun- $ \envasbs -> let (cEnv, as, bs) = untuple envasbs- in ite (null as .|| null bs)- []- (closureFun cEnv (head as) (head bs) .: sbvZipWith (tuple (cEnv, tail as, tail bs)))+ $ \envasbs -> [sCase| envasbs of+ (_, [], _ ) -> []+ (_, _, [] ) -> []+ (cEnv, a:as, b:bs) -> closureFun cEnv a b .: sbvZipWith (tuple (cEnv, as, bs))+ |] -- | Concatenate list of lists. --@@ -865,7 +878,11 @@ = literal (genericReplicate c' e') | True = def c e- where def = smtFunction "sbv.replicate" $ \count elt -> ite (count .<= 0) [] (elt .: def (count - 1) elt)+ where def = smtFunction "sbv.replicate"+ $ \count elt -> [sCase| count of+ _ | count .<= 0 -> []+ _ -> elt .: def (count - 1) elt+ |] -- | inits of a list. --@@ -879,7 +896,11 @@ = literal (L.inits xs') | True = def xs- where def = smtFunction "sbv.inits" $ \l -> ite (null l) [[]] (def (init l) ++ [l])+ where def = smtFunction "sbv.inits"+ $ \l -> [sCase| l of+ [] -> [[]]+ _ : _ -> def (init l) ++ [l]+ |] -- | tails of a list. --@@ -893,7 +914,11 @@ = literal (L.tails xs') | True = def xs- where def = smtFunction "sbv.tails" $ \l -> ite (null l) [[]] (l .: def (tail l))+ where def = smtFunction "sbv.tails"+ $ \l -> [sCase| l of+ [] -> [[]]+ _ : tl -> l .: def tl+ |] -- | Minimum of a list that has symbolic-ordering. If the list is empty, then -- the result is underspecified, i.e., it is an arbitrary element of the element type.@@ -937,11 +962,12 @@ = literal (xs' L.\\ ys') | True = def xs ys- where def = smtFunction "sbv.diff" $ \x y -> ite (null x)- []- (let (h, t) = uncons x- r = def t y- in ite (h `elem` y) r (h .: r))+ where def = smtFunction "sbv.diff"+ $ \x y -> [sCase| x of+ [] -> []+ h : t -> let r = def t y+ in ite (h `elem` y) r (h .: r)+ |] infix 5 \\ -- CPP: do not eat the final newline -- | A class of filtering-like functions. In SBV, we make a distinction between closures and regular functions,@@ -1025,11 +1051,12 @@ = literal concResult | True = sbvFilter l- where sbvFilter = smtHOFunction "sbv.filter" f $ \xs -> ite (null xs)- []- (let (h, t) = uncons xs- r = sbvFilter t- in ite (f h) (h .: r) r)+ where sbvFilter = smtHOFunction "sbv.filter" f+ $ \xs -> [sCase| xs of+ [] -> []+ h : t -> let r = sbvFilter t+ in ite (f h) (h .: r) r+ |] -- | @partition f xs@ splits the list into two and returns those that satisfy the predicate in the -- first element, and those that don't in the second.@@ -1038,13 +1065,13 @@ = literal concResult | True = sbvPartition l- where sbvPartition = smtHOFunction "sbv.partition" f $ \xs -> ite (null xs)- (tuple ([], []))- (let (h, t) = uncons xs- (as, bs) = untuple $ sbvPartition t- in ite (f h)- (tuple (h .: as, bs))- (tuple (as, h .: bs)))+ where sbvPartition = smtHOFunction "sbv.partition" f+ $ \xs -> [sCase| xs of+ [] -> tuple ([], [])+ h : t -> case sbvPartition t of+ (as, bs) | f h -> tuple (h .: as, bs)+ | True -> tuple (as, h .: bs)+ |] -- | @takeWhile f xs@ takes the prefix of @xs@ that satisfy the predicate. takeWhile f l@@ -1052,10 +1079,12 @@ = literal concResult | True = sbvTakeWhile l- where sbvTakeWhile = smtHOFunction "sbv.takeWhile" f $ \xs -> ite (null xs)- []- (let (h, t) = uncons xs- in ite (f h) (h .: sbvTakeWhile t) [])+ where sbvTakeWhile = smtHOFunction "sbv.takeWhile" f+ $ \xs -> [sCase| xs of+ [] -> []+ h : t | f h -> h .: sbvTakeWhile t+ | True -> []+ |] -- | @dropWhile f xs@ drops the prefix of @xs@ that satisfy the predicate. dropWhile f l@@ -1063,10 +1092,12 @@ = literal concResult | True = sbvDropWhile l- where sbvDropWhile = smtHOFunction "sbv.dropWhile" f $ \xs -> ite (null xs)- []- (let (h, t) = uncons xs- in ite (f h) (sbvDropWhile t) xs)+ where sbvDropWhile = smtHOFunction "sbv.dropWhile" f+ $ \xs -> [sCase| xs of+ [] -> []+ h : t | f h -> sbvDropWhile t+ | True -> xs+ |] -- | Filtering with closures. instance (SymVal env, SymVal a) => SFilter (Closure (SBV env) (SBV a -> SBool)) a where@@ -1076,13 +1107,11 @@ | True = sbvFilter (tuple (closureEnv, l)) where sbvFilter = smtHOFunction "sbv.closureFilter" closureFun- $ \envxs -> let (cEnv, xs) = untuple envxs- (h, t) = uncons xs- r = sbvFilter (tuple (cEnv, t))- in ite (null xs) []- $ ite (closureFun cEnv h)- (h .: r)- r+ $ \envxs -> [sCase| envxs of+ (_, []) -> []+ (cEnv, h : t) -> let r = sbvFilter (tuple (cEnv, t))+ in ite (closureFun cEnv h) (h .: r) r+ |] partition cls@Closure{closureEnv, closureFun} l | Just concResult <- concretePartition cls (closureFun closureEnv) l@@ -1090,13 +1119,12 @@ | True = sbvPartition (tuple (closureEnv, l)) where sbvPartition = smtHOFunction "sbv.closurePartition" closureFun- $ \envxs -> let (cEnv, xs) = untuple envxs- (h, t) = uncons xs- (as, bs) = untuple $ sbvPartition (tuple (cEnv, t))- in ite (null xs) (tuple ([], []))- $ ite (closureFun cEnv h)- (tuple (h .: as, bs))- (tuple (as, h .: bs))+ $ \envxs -> [sCase| envxs of+ (_, []) -> tuple ([], [])+ (cEnv, h : t) -> case sbvPartition (tuple (cEnv, t)) of+ (as, bs) | closureFun cEnv h -> tuple (h .: as, bs)+ | True -> tuple (as, h .: bs)+ |] takeWhile cls@Closure{closureEnv, closureFun} l | Just concResult <- concreteTakeWhile cls (closureFun closureEnv) l@@ -1104,12 +1132,11 @@ | True = sbvTakeWhile (tuple (closureEnv, l)) where sbvTakeWhile = smtHOFunction "sbv.closureTakeWhile" closureFun- $ \envxs -> let (cEnv, xs) = untuple envxs- (h, t) = uncons xs- in ite (null xs) []- $ ite (closureFun cEnv h)- (h .: sbvTakeWhile (tuple (cEnv, t)))- []+ $ \envxs -> [sCase| envxs of+ (_, []) -> []+ (cEnv, h : t) | closureFun cEnv h -> h .: sbvTakeWhile (tuple (cEnv, t))+ | True -> []+ |] dropWhile cls@Closure{closureEnv, closureFun} l | Just concResult <- concreteDropWhile cls (closureFun closureEnv) l@@ -1117,12 +1144,11 @@ | True = sbvDropWhile (tuple (closureEnv, l)) where sbvDropWhile = smtHOFunction "sbv.closureDropWhile" closureFun- $ \envxs -> let (cEnv, xs) = untuple envxs- (h, t) = uncons xs- in ite (null xs) []- $ ite (closureFun cEnv h)- (sbvDropWhile (tuple (cEnv, t)))- xs+ $ \envxs -> [sCase| envxs of+ (_, []) -> []+ (cEnv, lst@(h : t)) | closureFun cEnv h -> sbvDropWhile (tuple (cEnv, t))+ | True -> lst+ |] -- | @`sum` s@. Sum the given sequence. --@@ -1210,14 +1236,18 @@ enumFromTo n = enumFromThenTo n (n+1) enumFromThen x y = go x (y-x)- where go = smtFunction "EnumSymbolic.Integer.enumFromThen" $ \start delta -> start .: go (start+delta) delta+ where go = smtProductiveFunction "EnumSymbolic.Integer.enumFromThen" $ \start delta -> start .: go (start+delta) delta enumFromThenTo x y z = ite (delta .>= 0) (up x delta z) (down x delta z) where delta = y - x up, down :: SInteger -> SInteger -> SInteger -> SList Integer- up = smtFunction "EnumSymbolic.Integer.enumFromThenTo.up" $ \start d end -> ite (start .> end) [] (start .: up (start + d) d end)- down = smtFunction "EnumSymbolic.Integer.enumFromThenTo.down" $ \start d end -> ite (start .< end) [] (start .: down (start + d) d end)+ up = smtFunctionWithMeasure "EnumSymbolic.Integer.enumFromThenTo.up"+ (\start _d end -> 0 `smax` (end - start + 1), [])+ $ \start d end -> ite (start .> end .|| d .<= 0) [] (start .: up (start + d) d end)+ down = smtFunctionWithMeasure "EnumSymbolic.Integer.enumFromThenTo.down"+ (\start _d end -> 0 `smax` (start - end + 1), [])+ $ \start d end -> ite (start .< end .|| d .>= 0) [] (start .: down (start + d) d end) -- | 'EnumSymbolic instance for 'Float'. Note that the termination requirement as defined by the Haskell standard for floats state: -- > For Float and Double, the semantics of the enumFrom family is given by the rules for Int above,@@ -1234,7 +1264,7 @@ enumFromTo n = enumFromThenTo n (n+1) enumFromThen x y = go 0 x (y-x)- where go = smtFunction "EnumSymbolic.Float.enumFromThen" $ \k n d -> (n + k * d) .: go (k+1) n d+ where go = smtProductiveFunction "EnumSymbolic.Float.enumFromThen" $ \k n d -> (n + k * d) .: go (k+1) n d enumFromThenTo x y zIn = ite (delta .>= 0) (up 0 x delta z) (down 0 x delta z) where delta, z :: SFloat@@ -1242,8 +1272,10 @@ z = zIn + delta / 2 up, down :: SFloat -> SFloat -> SFloat -> SFloat -> SList Float- up = smtFunction "EnumSymbolic.Float.enumFromThenTo.up" $ \k n d end -> let c = n + k * d in ite (c .> end) [] (c .: up (k+1) n d end)- down = smtFunction "EnumSymbolic.Float.enumFromThenTo.down" $ \k n d end -> let c = n + k * d in ite (c .< end) [] (c .: down (k+1) n d end)+ up = smtFunctionWithMeasure "EnumSymbolic.Float.enumFromThenTo.up" (\k n d end -> 0 `smax` (end - (n + k * d)), [])+ $ \k n d end -> let c = n + k * d in ite (c .> end) [] (c .: up (k+1) n d end)+ down = smtFunctionWithMeasure "EnumSymbolic.Float.enumFromThenTo.down" (\k n d end -> 0 `smax` ((n + k * d) - end), [])+ $ \k n d end -> let c = n + k * d in ite (c .< end) [] (c .: down (k+1) n d end) -- | 'EnumSymbolic instance for 'Double' instance {-# OVERLAPPING #-} EnumSymbolic Double where@@ -1257,7 +1289,7 @@ enumFromTo n = enumFromThenTo n (n+1) enumFromThen x y = go 0 x (y-x)- where go = smtFunction "EnumSymbolic.Double.enumFromThen" $ \k n d -> (n + k * d) .: go (k+1) n d+ where go = smtProductiveFunction "EnumSymbolic.Double.enumFromThen" $ \k n d -> (n + k * d) .: go (k+1) n d enumFromThenTo x y zIn = ite (delta .>= 0) (up 0 x delta z) (down 0 x delta z) where delta, z :: SDouble@@ -1265,8 +1297,10 @@ z = zIn + delta / 2 up, down :: SDouble -> SDouble -> SDouble -> SDouble -> SList Double- up = smtFunction "EnumSymbolic.Double.enumFromThenTo.up" $ \k n d end -> let c = n + k * d in ite (c .> end) [] (c .: up (k+1) n d end)- down = smtFunction "EnumSymbolic.Double.enumFromThenTo.down" $ \k n d end -> let c = n + k * d in ite (c .< end) [] (c .: down (k+1) n d end)+ up = smtFunctionWithMeasure "EnumSymbolic.Double.enumFromThenTo.up" (\k n d end -> 0 `smax` (end - (n + k * d)), [])+ $ \k n d end -> let c = n + k * d in ite (c .> end) [] (c .: up (k+1) n d end)+ down = smtFunctionWithMeasure "EnumSymbolic.Double.enumFromThenTo.down" (\k n d end -> 0 `smax` ((n + k * d) - end), [])+ $ \k n d end -> let c = n + k * d in ite (c .< end) [] (c .: down (k+1) n d end) -- | 'EnumSymbolic instance for arbitrary floats instance {-# OVERLAPPING #-} ValidFloat eb sb => EnumSymbolic (FloatingPoint eb sb) where@@ -1280,7 +1314,7 @@ enumFromTo n = enumFromThenTo n (n+1) enumFromThen x y = go 0 x (y-x)- where go = smtFunction "EnumSymbolic.FloatingPoint.enumFromThen" $ \k n d -> (n + k * d) .: go (k+1) n d+ where go = smtProductiveFunction "EnumSymbolic.FloatingPoint.enumFromThen" $ \k n d -> (n + k * d) .: go (k+1) n d enumFromThenTo x y zIn = ite (delta .>= 0) (up 0 x delta z) (down 0 x delta z) where delta, z :: SFloatingPoint eb sb@@ -1288,8 +1322,10 @@ z = zIn + delta / 2 up, down :: SFloatingPoint eb sb -> SFloatingPoint eb sb -> SFloatingPoint eb sb -> SFloatingPoint eb sb -> SList (FloatingPoint eb sb)- up = smtFunction "EnumSymbolic.FloatingPoint.enumFromThenTo.up" $ \k n d end -> let c = n + k * d in ite (c .> end) [] (c .: up (k+1) n d end)- down = smtFunction "EnumSymbolic.FloatingPoint.enumFromThenTo.down" $ \k n d end -> let c = n + k * d in ite (c .< end) [] (c .: down (k+1) n d end)+ up = smtFunctionWithMeasure "EnumSymbolic.FloatingPoint.enumFromThenTo.up" (\k n d end -> 0 `smax` (end - (n + k * d)), [])+ $ \k n d end -> let c = n + k * d in ite (c .> end) [] (c .: up (k+1) n d end)+ down = smtFunctionWithMeasure "EnumSymbolic.FloatingPoint.enumFromThenTo.down" (\k n d end -> 0 `smax` ((n + k * d) - end), [])+ $ \k n d end -> let c = n + k * d in ite (c .< end) [] (c .: down (k+1) n d end) -- | 'EnumSymbolic instance for arbitrary AlgReal. We don't have to use the multiplicative trick here -- since alg-reals are precise. But, following rational in Haskell, we do use the stopping point of @z + delta / 2@.@@ -1304,7 +1340,7 @@ enumFromTo n = enumFromThenTo n (n+1) enumFromThen x y = go x (y-x)- where go = smtFunction "EnumSymbolic.AlgReal.enumFromThen" $ \start delta -> start .: go (start+delta) delta+ where go = smtProductiveFunction "EnumSymbolic.AlgReal.enumFromThen" $ \start delta -> start .: go (start+delta) delta enumFromThenTo x y zIn = ite (delta .>= 0) (up x delta z) (down x delta z) where delta, z :: SReal@@ -1312,8 +1348,10 @@ z = zIn + delta / 2 up, down :: SReal -> SReal -> SReal -> SList AlgReal- up = smtFunction "EnumSymbolic.AlgReal.enumFromThenTo.up" $ \start d end -> ite (start .> end) [] (start .: up (start + d) d end)- down = smtFunction "EnumSymbolic.AlgReal.enumFromThenTo.down" $ \start d end -> ite (start .< end) [] (start .: down (start + d) d end)+ up = smtFunctionWithMeasure "EnumSymbolic.AlgReal.enumFromThenTo.up" (\start _d end -> 0 `smax` (end - start + 1), [])+ $ \start d end -> ite (start .> end .|| d .<= 0) [] (start .: up (start + d) d end)+ down = smtFunctionWithMeasure "EnumSymbolic.AlgReal.enumFromThenTo.down" (\start _d end -> 0 `smax` (start - end + 1), [])+ $ \start d end -> ite (start .< end .|| d .>= 0) [] (start .: down (start + d) d end) -- | Lookup. If we can't find, then the result is unspecified. --@@ -1321,13 +1359,15 @@ -- 3 :: SInteger -- >>> prove $ \(x :: SInteger) -> x .== lookup 9 (literal [(5, 12), (4, 3), (2, 6 :: Integer)]) -- Falsifiable. Counter-example:--- Data.SBV.List.lookup_notFound @Integer = 0 :: Integer--- s0 = 1 :: Integer+-- sbv.lookup_notFound @Integer = 0 :: Integer+-- s0 = 1 :: Integer lookup :: (SymVal k, SymVal v) => SBV k -> SList (k, v) -> SBV v-lookup = smtFunction "Data.SBV.List.lookup" $ \k lst -> ite (null lst)- (some "Data.SBV.List.lookup_notFound" (const sTrue))- (let (k', v) = untuple (head lst)- in ite (k .== k') v (lookup k (tail lst)))+lookup = smtFunction "sbv.lookup"+ $ \k lst -> [sCase| lst of+ [] -> some "sbv.lookup_notFound" (const sTrue)+ (k', v) : rest | k .== k' -> v+ | True -> lookup k rest+ |] -- | @`strToNat` s@. Retrieve integer encoded by string @s@ (ground rewriting only). -- Note that by definition this function only works when @s@ only contains digits,@@ -1427,4 +1467,5 @@ r st = do sva <- sbvToSV st a newExpr st k (SBVApp (StrOp w) [sva]) -{- HLint ignore implode "Use :" -}+{- HLint ignore implode "Use :" -}+{- HLint ignore replicate "Use const" -}
Data/SBV/Maybe.hs view
@@ -23,12 +23,18 @@ module Data.SBV.Maybe ( -- * Constructing optional values sJust, sNothing, liftMaybe, SMaybe, sMaybe, sMaybe_, sMaybes+ -- * Destructing optionals , maybe+ -- * Mapping functions , map, map2+ -- * Scrutinizing the branches of an option , isNothing, isJust, fromMaybe, fromJust++ -- * Case analysis (for sCase quasi-quoter)+ , sCaseMaybe, getJust_1 ) where import Prelude hiding (maybe, map)@@ -37,6 +43,7 @@ import Data.SBV.Client import Data.SBV.Core.Data import Data.SBV.Core.Model (ite, OrdSymbolic(..))+import Data.SBV.SCase (sCase) #ifdef DOCTEST -- $setup@@ -155,7 +162,10 @@ -> (SBV a -> SBV b) -> SMaybe a -> SBV b-maybe brNothing brJust ma = ite (isNothing ma) brNothing (brJust (fromJust ma))+maybe brNothing brJust ma = [sCase| ma of+ Nothing -> brNothing+ Just x -> brJust x+ |] -- | Custom 'Num' instance over 'SMaybe' instance (Ord a, SymVal a, Num a, Num (SBV a)) => Num (SBV (Maybe a)) where
Data/SBV/Provers/Prover.hs view
@@ -51,6 +51,8 @@ import Data.Maybe (mapMaybe, listToMaybe) +import qualified Data.Set as Set (empty)+ import qualified Data.Foldable as S (toList) import qualified Data.Text as T @@ -106,11 +108,11 @@ , ignoreExitCode = False , redirectVerbose = Nothing , firstifyUniqueLen = 10- , tpOptions = TPOptions { ribbonLength = 40- , quiet = False- , printAsms = False- , printStats = False- , cacheProofs = False+ , tpOptions = TPOptions { ribbonLength = 40+ , quiet = False+ , printAsms = False+ , printStats = False+ , measuresBeingVerified = Set.empty } }
Data/SBV/RegExp.hs view
@@ -88,7 +88,7 @@ -- >>> let phone = pre * "-" * post -- >>> sat $ \(s :: SString) -> s `match` phone -- Satisfiable. Model:--- s0 = "800-8000" :: String+-- s0 = "400-8000" :: String class RegExpMatchable a where -- | @`match` s r@ checks whether @s@ is in the language generated by @r@. match :: a -> RegExp -> SBool
Data/SBV/SCase.hs view
@@ -9,10 +9,12 @@ -- Add support for symbolic case expressions. Constructed with the help of ChatGPT, -- which was remarkably good at giving me the basic structure. ----- Provides a quasiquoter `[sCase|Expr expr of ... |]` for symbolic cases--- where @Expr@ is the underlying type.+-- Provides a quasiquoter `[sCase| expr of ... |]` for symbolic cases+-- where @Expr@ is the underlying type. Plain @case@ expressions inside+-- @sCase@ are automatically treated as symbolic case-splits, enabling+-- nested symbolic pattern matching. ----- Also provides `[pCase|Expr expr of ... |]` for proof case-splits.+-- Also provides `[pCase| expr of ... |]` for proof case-splits. ----------------------------------------------------------------------------- {-# LANGUAGE LambdaCase #-}@@ -31,25 +33,36 @@ import Control.Monad (unless, when, zipWithM) -import Data.SBV.Client (getConstructors)-import Data.SBV.Core.Model (ite, sym)-import Data.SBV.Core.Data (sTrue, sNot, (.&&), (.||), (.==), literal)+import Data.SBV.Core.TH (getConstructors, sbvName)+import Data.SBV.Core.Model (ite, symWithKind)+import Data.SBV.Core.Data (sTrue, sNot, (.&&), (.||), (.==), (.===), (.:), literal) -import Data.Char (isSpace, isDigit)-import Data.List (intercalate)-import Data.Maybe (isJust, fromMaybe)+import Data.Char (isDigit)+import Data.List (intercalate, stripPrefix)+import Data.Maybe (isJust, fromMaybe, catMaybes) import Prelude hiding (fail) import qualified Prelude as P(fail) import Data.Generics-import qualified Data.Map as Map+import qualified Data.Map.Strict as Map import Data.Map (Map) import qualified Data.Set as Set import Data.Set (Set) import System.FilePath +-- | Conjoin a list of TH boolean expressions with (.&&), filtering out trivially true guards.+sAndAll :: [Exp] -> Exp+sAndAll = go . filter (not . isTriviallyTrue)+ where go [] = VarE 'sTrue+ go [g] = g+ go gs = foldr1 (\a b -> foldl1 AppE [VarE '(.&&), a, b]) gs++ isTriviallyTrue (VarE nm) = nameBase nm == nameBase 'sTrue+ isTriviallyTrue (ConE nm) = nameBase nm == "True"+ isTriviallyTrue _ = False+ -- | TH parse trees don't have location. Let's have a simple mechanism to keep track of them for our use case data Offset = Unknown | OffBy Int Int Int deriving Show@@ -70,6 +83,187 @@ Unknown -> loc OffBy lo co w -> loc {loc_start = (sl + lo, co + 1), loc_end = (sl + lo, co + w)} +-- | Built-in types recognized by sCase/pCase. Maybe and Either do have mkSymbolic-generated+-- infrastructure, but we treat them as built-in so that the generated code uses TH-quoted names+-- (which resolve at SCase.hs compile time) instead of mkName-based references (which would+-- require the user to have the testers/accessors in scope at the splice site).+data BuiltinType = BTBool | BTMaybe | BTEither | BTList | BTTuple Int+ deriving Show++-- | Compare two Names by their base (unqualified) name. This is needed because+-- built-in constructor names (created with mkName) won't match the fully-qualified+-- names that GHC resolves patterns to (e.g., mkName "Nothing" vs GHC.Internal.Maybe.Nothing).+-- Since constructor names are unique within a type, comparing by nameBase is safe.+sameBase :: Name -> Name -> Bool+sameBase a b = nameBase a == nameBase b++-- | Lookup by nameBase instead of Name equality.+lookupBase :: Name -> [(Name, a)] -> Maybe a+lookupBase _ [] = Nothing+lookupBase nm ((k,v):kvs)+ | sameBase nm k = Just v+ | True = lookupBase nm kvs++-- | Recognize built-in type names.+recognizeBuiltin :: String -> Maybe BuiltinType+recognizeBuiltin "Bool" = Just BTBool+recognizeBuiltin "Maybe" = Just BTMaybe+recognizeBuiltin "Either" = Just BTEither+recognizeBuiltin "List" = Just BTList+recognizeBuiltin s+ | Just n <- stripPrefix "Tuple" s, not (null n), all isDigit n, let k = read n, k >= 2, k <= 8+ = Just (BTTuple k)+recognizeBuiltin _ = Nothing++-- | Recognize a constructor name as belonging to a built-in type. Used in flattenPat+-- to generate TH-quoted tester/accessor references for nested built-in constructors.+recognizeBuiltinCon :: String -> Maybe BuiltinType+recognizeBuiltinCon "True" = Just BTBool+recognizeBuiltinCon "False" = Just BTBool+recognizeBuiltinCon "Nothing" = Just BTMaybe+recognizeBuiltinCon "Just" = Just BTMaybe+recognizeBuiltinCon "Left" = Just BTEither+recognizeBuiltinCon "Right" = Just BTEither+recognizeBuiltinCon "[]" = Just BTList+recognizeBuiltinCon ":" = Just BTList+recognizeBuiltinCon _ = Nothing++-- | Infer the type from the constructor names used in the pattern matches.+-- Examines top-level patterns to find the first informative one (i.e., not a wildcard),+-- then resolves the constructor via TH to determine the parent type.+-- Returns 'Nothing' if all branches use wildcards (wildcard-only mode).+inferType :: String -> [Match] -> Q (Maybe (String, Maybe BuiltinType))+inferType label matches = case firstInfo matches of+ Just (Left n) -> pure $ Just ("Tuple" ++ show n, Just (BTTuple n))+ Just (Right Nothing) -> pure $ Just ("List", Just BTList)+ Just (Right (Just name)) -> Just <$> resolveConType name+ Nothing -> pure Nothing+ where+ -- Left n = tuple of arity n, Right Nothing = list, Right (Just name) = constructor name+ firstInfo [] = Nothing+ firstInfo (Match pat _ _ : rest) = case patInfo pat of+ Just info -> Just info+ Nothing -> firstInfo rest++ patInfo (ConP n _ _) = Just (Right (Just n))+ patInfo (RecP n _) = Just (Right (Just n))+ patInfo (InfixP _ n _) | nameBase n == ":" = Just (Right Nothing)+ patInfo (UInfixP _ n _) | nameBase n == ":" = Just (Right Nothing)+ patInfo (TupP ps) = Just (Left (length ps))+ patInfo (ListP _) = Just (Right Nothing)+ patInfo (ParensP p) = patInfo p+ patInfo (AsP _ p) = patInfo p+ patInfo _ = Nothing++ -- Resolve a constructor name to its parent type via TH+ resolveConType conName = do+ let base = nameBase conName+ -- Check if it's a known built-in constructor first (for cases where lookupValueName+ -- might not resolve, e.g., "[]" as a value name)+ case recognizeBuiltinCon base of+ Just bt -> pure (builtinTypeName bt, Just bt)+ Nothing -> do+ mbResolved <- lookupValueName base+ case mbResolved of+ Nothing -> fail Unknown $ unlines [ label ++ ": Unknown constructor: " ++ base+ , ""+ , " Cannot find this constructor in scope."+ , " Make sure the type is declared and mkSymbolic is called."+ ]+ Just resolved -> do+ info <- reify resolved+ case info of+ DataConI _ _ parentName -> let typName = nameBase parentName+ in pure (typName, recognizeBuiltin typName)+ _ -> fail Unknown $ label ++ ": " ++ base ++ " is not a data constructor."++ builtinTypeName BTBool = "Bool"+ builtinTypeName BTMaybe = "Maybe"+ builtinTypeName BTEither = "Either"+ builtinTypeName BTList = "List"+ builtinTypeName (BTTuple n) = "Tuple" ++ show n++-- | Constructor info for a built-in type: (name, arity).+builtinConstructors :: BuiltinType -> [(Name, Int)]+builtinConstructors BTBool = [(mkName "True", 0), (mkName "False", 0)]+builtinConstructors BTMaybe = [(mkName "Nothing", 0), (mkName "Just", 1)]+builtinConstructors BTEither = [(mkName "Left", 1), (mkName "Right", 1)]+builtinConstructors BTList = [(mkName "[]", 0), (mkName ":", 2)]+builtinConstructors (BTTuple n) = [(tupleDataName n, n)]++-- | Generate a tester expression for a built-in type constructor.+builtinTester :: BuiltinType -> Name -> Exp -> Exp+builtinTester BTBool nm scrut+ | nameBase nm == "True" = scrut+ | nameBase nm == "False" = AppE (VarE 'sNot) scrut+builtinTester BTMaybe nm scrut+ | nameBase nm == "Nothing" = AppE (VarE (sbvName "Data.SBV.Maybe" "isNothing")) scrut+ | nameBase nm == "Just" = AppE (VarE (sbvName "Data.SBV.Maybe" "isJust")) scrut+builtinTester BTEither nm scrut+ | nameBase nm == "Left" = AppE (VarE (sbvName "Data.SBV.Either" "isLeft")) scrut+ | nameBase nm == "Right" = AppE (VarE (sbvName "Data.SBV.Either" "isRight")) scrut+builtinTester BTList nm scrut+ | nameBase nm == "[]" = AppE (VarE (sbvName "Data.SBV.List" "null")) scrut+ | nameBase nm == ":" = AppE (VarE 'sNot) (AppE (VarE (sbvName "Data.SBV.List" "null")) scrut)+builtinTester (BTTuple _) _ _ = VarE 'sTrue+builtinTester bt nm _ = error $ "sCase: builtinTester: unexpected constructor " ++ nameBase nm ++ " for " ++ show bt++-- | Generate an accessor expression for a built-in type constructor field.+builtinAccessor :: BuiltinType -> Name -> Int -> Exp -> Exp+builtinAccessor BTBool nm _ _ = error $ "sCase: builtinAccessor: Bool constructor " ++ nameBase nm ++ " has no fields"+builtinAccessor BTMaybe nm i scrut+ | nameBase nm == "Just", i == 1 = AppE (VarE (sbvName "Data.SBV.Maybe" "getJust_1")) scrut+builtinAccessor BTEither nm i scrut+ | nameBase nm == "Left", i == 1 = AppE (VarE (sbvName "Data.SBV.Either" "getLeft_1")) scrut+ | nameBase nm == "Right", i == 1 = AppE (VarE (sbvName "Data.SBV.Either" "getRight_1")) scrut+builtinAccessor BTList nm i scrut+ | nameBase nm == ":", i == 1 = AppE (VarE (sbvName "Data.SBV.List" "head")) scrut+ | nameBase nm == ":", i == 2 = AppE (VarE (sbvName "Data.SBV.List" "tail")) scrut+builtinAccessor (BTTuple _) _ i scrut+ -- Simplify _i (tuple (a, b, ...)) to just the i-th component+ | AppE (VarE f) (TupE components) <- scrut+ , nameBase f == "tuple"+ , let cs = catMaybes components+ , i >= 1, i <= length cs+ = cs !! (i - 1)+ | True+ = AppE (VarE (tupleAccessorName i)) scrut+ where tupleAccessorName 1 = sbvName "Data.SBV.Tuple" "_1"+ tupleAccessorName 2 = sbvName "Data.SBV.Tuple" "_2"+ tupleAccessorName 3 = sbvName "Data.SBV.Tuple" "_3"+ tupleAccessorName 4 = sbvName "Data.SBV.Tuple" "_4"+ tupleAccessorName 5 = sbvName "Data.SBV.Tuple" "_5"+ tupleAccessorName 6 = sbvName "Data.SBV.Tuple" "_6"+ tupleAccessorName 7 = sbvName "Data.SBV.Tuple" "_7"+ tupleAccessorName 8 = sbvName "Data.SBV.Tuple" "_8"+ tupleAccessorName n = error $ "sCase: tupleAccessorName: unsupported index " ++ show n+builtinAccessor bt nm i _ = error $ "sCase: builtinAccessor: unexpected constructor " ++ nameBase nm ++ " field " ++ show i ++ " for " ++ show bt++-- | Generate a tester expression for a constructor, dispatching to builtinTester for+-- recognized built-in constructors or falling back to @is\<Con\>@ for user ADTs.+mkTester :: Name -> Exp -> Exp+mkTester nm scrut = case recognizeBuiltinCon (nameBase nm) of+ Just bt -> builtinTester bt nm scrut+ Nothing -> AppE (VarE (mkName ("is" ++ nameBase nm))) scrut++-- | Generate an accessor expression for a constructor field, dispatching to builtinAccessor for+-- recognized built-in constructors or falling back to @get\<Con\>_i@ for user ADTs.+mkAccessor :: Name -> Int -> Exp -> Exp+mkAccessor nm i scrut = case recognizeBuiltinCon (nameBase nm) of+ Just bt -> builtinAccessor bt nm i scrut+ Nothing -> AppE (VarE (mkName ("get" ++ nameBase nm ++ "_" ++ show i))) scrut++-- | Like 'mkTester', but when the built-in type is already known from the scrutinee type.+-- Used in top-level sCase/pCase code generation.+mkTesterFor :: Maybe BuiltinType -> Name -> Exp -> Exp+mkTesterFor (Just bt) nm scrut = builtinTester bt nm scrut+mkTesterFor Nothing nm scrut = AppE (VarE (mkName ("is" ++ nameBase nm))) scrut++-- | Like 'mkAccessor', but when the built-in type is already known from the scrutinee type.+mkAccessorFor :: Maybe BuiltinType -> Name -> Int -> Exp -> Exp+mkAccessorFor (Just bt) nm i scrut = builtinAccessor bt nm i scrut+mkAccessorFor Nothing nm i scrut = AppE (VarE (mkName ("get" ++ nameBase nm ++ "_" ++ show i))) scrut+ -- | What kind of case-match are we given. In each case, the last maybe exp is the possible guard. data Case = CMatch Offset -- regular match Name -- name of the constructor@@ -164,13 +358,26 @@ -- The above just mimics the defaults. These our extras. extras = [E.DataKinds] --- | Split the quasiquote input into (type, scrutinee) and alternatives-parts :: String -> Maybe ((String, String), String)-parts = go ""- where go _ "" = Nothing- go sofar ('o':'f':rest) = Just (break isSpace (dropWhile isSpace (reverse sofar)), rest)- go sofar (c:cs) = go (c:sofar) cs+-- | Handle a metaParse error by mapping the parse-error column back to the source file.+-- metaParse operates on @"case " <> src@ (5 extra chars), so we subtract 5 from its column.+-- For line 1 errors, we also add the quasi-quote content's starting column since the first+-- line of src is offset from the start of the source line. For subsequent lines, the columns+-- in the quasi-quote content already correspond to source file columns.+handleParseError :: String -> String -> Q a+handleParseError label err = do+ loc <- location+ let qqCol = snd (loc_start loc) -- 1-based column where quasi-quote content starts+ case lines err of+ (_:locLine:res) | ["SrcLoc", _, l, c] <- words locLine, all isDigit l, all isDigit c+ -> let mc = read c+ line = read l+ -- Line 1: column is relative to "case " <> src, need to add quasi-quote offset+ -- Lines 2+: column is already a source file column (verbatim from source)+ col = if line == 1 then qqCol + mc - 7 else mc - 1+ in fail (OffBy (line - 1) col 1) (unlines res)+ _ -> fail Unknown $ label ++ " parse error: " <> err + -- | Extract guards from a match body getGuards :: Body -> [Dec] -> Q [(Maybe Exp, Exp)] getGuards (NormalB rhs) locals = pure [(Nothing, addLocals locals rhs)]@@ -183,7 +390,7 @@ get (PatG stmts, rhs) | all isNoBindS stmts = let guards = [e | NoBindS e <- stmts]- conj = foldr1 (\a b -> foldl1 AppE [VarE '(.&&), a, b]) guards+ conj = sAndAll guards in pure (if isSTrue conj then Nothing else Just conj, addLocals locals rhs) | True = fail Unknown $ unlines $ "sCase/pCase: Pattern guards are not supported: "@@ -215,48 +422,86 @@ rhss <- getGuards grhs locals let allUsed = Set.unions (map (\(mbG, e) -> maybe Set.empty freeVars mbG `Set.union` freeVars e) rhss) - case pat of- ConP conName _ subpats -> do- con <- getReference off conName- -- For each sub-pattern at position i, flatten it against the accessor expression- let accessor i = AppE (VarE (mkName ("get" ++ nameBase con ++ "_" ++ show i))) scrut- flatResults <- zipWithM (flattenPat off . accessor) [(1::Int)..] subpats- let ps = map fstOf3 flatResults- subGrds = concatMap sndOf3 flatResults- subDecs = concatMap thdOf3 flatResults+ -- Common logic for constructor-like patterns: flatten sub-patterns, merge synthetic guards+ flattenAndMerge :: Name -> (Int -> Exp) -> [Pat] -> Q [Case]+ flattenAndMerge con accessor subpats = do+ flatResults <- zipWithM (flattenPat off . accessor) [(1::Int)..] subpats+ let ps = map fstOf3 flatResults+ subGrds = concatMap sndOf3 flatResults+ subDecs = concatMap thdOf3 flatResults - andAll [g] = g- andAll (g:gs) = foldl1 AppE [VarE '(.&&), g, andAll gs]- andAll [] = VarE 'sTrue+ merge (mbG, rhs) =+ let usedInRhs = freeVars rhs+ usedInGrd = maybe Set.empty freeVars mbG+ decsFor s = [ d | d@(ValD (VarP v) _ _) <- subDecs, v `Set.member` s ]+ rhs' = addLocals (decsFor usedInRhs) rhs+ mbG' = case (subGrds, mbG) of+ ([], Nothing) -> Nothing+ ([], Just g ) -> Just (addLocals (decsFor usedInGrd) g)+ (gs, Nothing) -> Just (sAndAll gs)+ (gs, Just g ) -> Just (sAndAll (gs ++ [addLocals (decsFor usedInGrd) g]))+ in (mbG', rhs') - -- Merge synthetic nested-pattern guards and bindings into each (guard, rhs) pair- merge (mbG, rhs) =- let usedInRhs = freeVars rhs- usedInGrd = maybe Set.empty freeVars mbG- decsFor s = [ d | d@(ValD (VarP v) _ _) <- subDecs, v `Set.member` s ]- rhs' = addLocals (decsFor usedInRhs) rhs- mbG' = case (subGrds, mbG) of- ([], Nothing) -> Nothing- ([], Just g ) -> Just (addLocals (decsFor usedInGrd) g)- (gs, Nothing) -> Just (andAll gs)- (gs, Just g ) -> Just (foldl1 AppE [VarE '(.&&), andAll gs, addLocals (decsFor usedInGrd) g])- in (mbG', rhs')+ pure [CMatch off con (Just ps) mbG rhs allUsed | (mbG, rhs) <- map merge rhss] - pure [CMatch off con (Just ps) mbG rhs allUsed | (mbG, rhs) <- map merge rhss]+ case pat of+ ConP conName _ subpats -> do+ con <- getReference off conName+ flattenAndMerge con (\i -> mkAccessor con i scrut) subpats RecP conName [] -> do con <- getReference off conName pure [CMatch off con Nothing mbG rhs allUsed | (mbG, rhs) <- rhss] WildP -> pure [CWild off mbG rhs | (mbG, rhs) <- rhss] + -- List cons pattern: y : ys (InfixP or UInfixP from the parser)+ InfixP p1 conName p2+ | nameBase conName == ":" -> let con = mkName ":" in flattenAndMerge con (\i -> mkAccessorFor (Just BTList) con i scrut) [p1, p2]+ UInfixP p1 conName p2+ | nameBase conName == ":" -> let con = mkName ":" in flattenAndMerge con (\i -> mkAccessorFor (Just BTList) con i scrut) [p1, p2]++ -- Tuple pattern: (a, b, ...)+ TupP subpats -> do+ let n = length subpats+ con = tupleDataName n+ flattenAndMerge con (\i -> mkAccessorFor (Just (BTTuple n)) con i scrut) subpats++ -- List nil pattern: []+ ListP [] -> pure [CMatch off (mkName "[]") (Just []) mbG rhs allUsed | (mbG, rhs) <- rhss]++ -- List pattern with elements: [a], [a, b], etc. Desugar to nested cons: a : (b : [])+ ListP ps -> let desugar [] = ListP []+ desugar (p:rest) = InfixP p (mkName ":") (desugar rest)+ in matchToPair scrut off (Match (desugar ps) grhs locals)++ -- Parenthesized pattern: unwrap and recurse+ ParensP p -> matchToPair scrut off (Match p grhs locals)++ -- Literal pattern at top level: 0, 1, "hello", etc.+ -- Treated as a wildcard with a guard: scrut .== literal+ LitP lit -> do eq <- litToEq off scrut lit+ pure [CWild off (Just (maybe eq (\g -> sAndAll [eq, g]) mbG)) rhs | (mbG, rhs) <- rhss]++ -- Variable pattern at top level: binds the scrutinee (only when used)+ VarP v -> let bindScrut e | v `Set.member` freeVars e = LetE [ValD (VarP v) (NormalB scrut) []] e+ | True = e+ in pure [CWild off (fmap bindScrut mbG) (bindScrut rhs) | (mbG, rhs) <- rhss]++ -- As-pattern at top level: name@subpat — bind name to scrutinee, then process inner pattern+ AsP name subpat -> do+ cases <- matchToPair scrut off (Match subpat grhs locals)+ let bindAs e | name `Set.member` freeVars e = LetE [ValD (VarP name) (NormalB scrut) []] e+ | True = e+ addBind (CMatch o cn ps mbG' rhs' used) = CMatch o cn ps (fmap bindAs mbG') (bindAs rhs') used+ addBind (CWild o mbG' rhs') = CWild o (fmap bindAs mbG') (bindAs rhs')+ pure (map addBind cases)+ _ -> fail Unknown $ unlines [ "sCase/pCase: Unsupported pattern:" , " Saw: " <> pprint pat , ""- , " Only constructors with variables (i.e., Cstr a b _ d)"- , " Empty record matches (i.e., Cstr{})"- , " And wildcards (i.e., _) for default"- , " are supported at the top level."- , " (Integer and string literals are supported in nested positions.)"+ , " Supported patterns: constructors (Cstr a b _ d),"+ , " empty records (Cstr{}), wildcards (_), variables,"+ , " as-patterns (x@pat), and integer/string literals." ] -- | Flatten a sub-pattern against a given accessor expression.@@ -270,7 +515,7 @@ flattenPat off arg (ConP conName _ subpats) = do con <- getReference off conName -- Arity check: reify the constructor to find its actual field count- DataConI _ conType _ <- reify con+ DataConI _ conType parentName <- reify con let arity = countArgs conType unless (arity == length subpats) $ fail off $ unlines [ "sCase/pCase: Arity mismatch in nested pattern."@@ -278,24 +523,83 @@ , " Expected : " ++ show arity , " Given : " ++ show (length subpats) ]- let tester = AppE (VarE (mkName ("is" ++ nameBase con))) arg- accessor i = AppE (VarE (mkName ("get" ++ nameBase con ++ "_" ++ show i))) arg+ -- Check if the parent type has only one constructor; if so, the tester is trivially true+ singleCon <- isSingleConstructorType parentName+ let tester = mkTester con arg+ accessor i = mkAccessor con i arg subResults <- zipWithM (flattenPat off . accessor) [(1::Int)..] subpats let subGrds = concatMap sndOf3 subResults subDecs = concatMap thdOf3 subResults subPats = map fstOf3 subResults patDecs = [ ValD (VarP v) (NormalB (accessor i)) [] | (i, VarP v) <- zip [(1::Int)..] subPats ]- pure (WildP, tester : subGrds, patDecs ++ subDecs)+ -- Skip the tester guard for single-constructor types (it's always true)+ guards = (if singleCon then id else (tester :)) subGrds+ pure (WildP, guards, patDecs ++ subDecs) flattenPat off arg (LitP lit) = do eq <- litToEq off arg lit pure (WildP, [eq], [])+-- Nested list cons pattern: x : xs (InfixP or UInfixP from the parser)+flattenPat off arg (InfixP p1 conName p2)+ | nameBase conName == ":" = flattenCons off arg p1 p2+flattenPat off arg (UInfixP p1 conName p2)+ | nameBase conName == ":" = flattenCons off arg p1 p2+-- Nested empty list pattern: []+flattenPat _ arg (ListP []) =+ pure (WildP, [AppE (VarE (sbvName "Data.SBV.List" "null")) arg], [])+-- Nested list pattern with elements: [a], [a, b], etc. Desugar to nested cons.+flattenPat off arg (ListP (p:ps)) =+ flattenPat off arg (InfixP p (mkName ":") (ListP ps))+-- Nested tuple pattern: (a, b, ...)+flattenPat off arg (TupP pats) = do+ let n = length pats+ accessor i = mkAccessorFor (Just (BTTuple n)) (tupleDataName n) i arg+ subResults <- zipWithM (flattenPat off . accessor) [(1::Int)..] pats+ let subGrds = concatMap sndOf3 subResults+ subDecs = concatMap thdOf3 subResults+ patDecs = [ ValD (VarP v) (NormalB (accessor i)) []+ | (i, VarP v) <- zip [(1::Int)..] (map fstOf3 subResults) ]+ pure (WildP, subGrds, patDecs ++ subDecs)+-- Nested as-pattern: name@subpat — bind name to accessor, then process inner pattern+flattenPat off arg (AsP name subpat) = do+ (pat', guards, decs) <- flattenPat off arg subpat+ let asDec = ValD (VarP name) (NormalB arg) []+ pure (pat', guards, asDec : decs) flattenPat o _ p = fail o $ unlines [ "sCase/pCase: Unsupported complex pattern match." , " Saw: " <> pprint p , ""- , " Only variables, wildcards, nested constructors, and integer/string literals are supported."+ , " Only variables, wildcards, as-patterns, nested constructors, and integer/string literals are supported." ] +-- | Flatten a nested list cons pattern (x : xs) against an accessor expression.+-- We include a destructuring equality (arg .=== head arg .: tail arg) because lists use+-- SMT Seq, not declare-datatypes, so the solver doesn't automatically know this relationship.+-- This is critical for pCase proof progress; harmless for sCase (redundant guard in ite-chain).+-- NB. For top-level list cons patterns in pCase, the same equality is added by processCases.+flattenCons :: Offset -> Exp -> Pat -> Pat -> Q (Pat, [Exp], [Dec])+flattenCons off arg p1 p2 = do+ let headExpr = mkAccessorFor (Just BTList) (mkName ":") 1 arg+ tailExpr = mkAccessorFor (Just BTList) (mkName ":") 2 arg+ tester = mkTesterFor (Just BTList) (mkName ":") arg+ destruct = foldl1 AppE [VarE '(.===), arg, InfixE (Just headExpr) (VarE '(.:)) (Just tailExpr)]+ sub1 <- flattenPat off headExpr p1+ sub2 <- flattenPat off tailExpr p2+ let subGrds = sndOf3 sub1 ++ sndOf3 sub2+ subDecs = thdOf3 sub1 ++ thdOf3 sub2+ patDecs = [ ValD (VarP v) (NormalB headExpr) [] | VarP v <- [fstOf3 sub1] ]+ ++ [ ValD (VarP v) (NormalB tailExpr) [] | VarP v <- [fstOf3 sub2] ]+ pure (WildP, tester : destruct : subGrds, patDecs ++ subDecs)++-- | Check if a type has only one constructor. Used to skip trivially-true tester guards+-- in nested patterns (e.g., @Just (Pocket n3 n5)@ where @Pocket@ is the sole constructor).+isSingleConstructorType :: Name -> Q Bool+isSingleConstructorType tyName = do+ info <- reify tyName+ pure $ case info of+ TyConI (DataD _ _ _ _ [_] _) -> True+ TyConI (NewtypeD {}) -> True+ _ -> False+ fstOf3 :: (a, b, c) -> a fstOf3 (a, _, _) = a @@ -305,6 +609,70 @@ thdOf3 :: (a, b, c) -> c thdOf3 (_, _, c) = c +-- | Get the constructor list for a type. For built-in types, return synthetic entries;+-- for user ADTs, reify via getConstructors.+getCstrs :: Maybe BuiltinType -> String -> Q [(Name, [Type])]+getCstrs (Just bt) _ = pure [(nm, replicate ar WildCardT) | (nm, ar) <- builtinConstructors bt]+getCstrs Nothing typ = let dropFieldNames (c, nts) = (c, map snd nts)+ in map dropFieldNames . snd <$> getConstructors (mkName typ)++-- | Validate wildcard placement: unguarded wildcard must be last.+checkWildcard :: String -> Loc -> [Case] -> Q ()+checkWildcard label loc cs = do go cs; checkExhaustive cs+ where go [] = pure ()+ go (CMatch{} : rest) = go rest+ go (CWild _ Just{} _ : rest) = go rest+ go (CWild o Nothing _ : rest) =+ case rest of+ [] -> pure ()+ red -> fail o $ unlines $ (label ++ ": Wildcard makes the remaining matches redundant:")+ : [" " ++ showCaseGen (Just loc) r | r <- red]++ -- If all cases are wildcards (no CMatch), then we need an unguarded wildcard+ -- as a catch-all. Otherwise, guarded-only wildcards on an infinite domain+ -- (Integer, String, etc.) silently produce a free variable for unmatched cases.+ checkExhaustive cases+ | any isCMatch cases = pure () -- Has constructor patterns; exhaustiveness checked elsewhere+ | any isUnguardedWild cases = pure () -- Has an unguarded catch-all+ | True = fail (headOffset cases) $ unlines+ [ label ++ ": Non-exhaustive pattern match."+ , " All branches are guarded; add an unguarded wildcard or variable"+ , " as the last branch to ensure all cases are covered."+ ]++ isCMatch CMatch{} = True+ isCMatch _ = False++ isUnguardedWild (CWild _ Nothing _) = True+ isUnguardedWild _ = False++ headOffset (c:_) = caseOffset c+ headOffset [] = Unknown++-- | Validate that each constructor exists and has the right arity.+checkArities :: String -> String -> [(Name, [Type])] -> [Case] -> Q ()+checkArities label typ cstrs = mapM_ chk1+ where chk1 c = case c of+ CMatch o nm ps _ _ _ -> isSafe o nm (length <$> ps)+ CWild {} -> pure ()+ isSafe o nm mbLen+ | Just ts <- lookupBase nm cstrs+ = case mbLen of+ Nothing -> pure ()+ Just cnt -> unless (length ts == cnt)+ $ fail o $ unlines [ label ++ ": Arity mismatch."+ , " Type : " ++ typ+ , " Constructor: " ++ nameBase nm+ , " Expected : " ++ show (length ts)+ , " Given : " ++ show cnt+ ]+ | True+ = fail o $ unlines [ label ++ ": Unknown constructor:"+ , " Type : " ++ typ+ , " Saw : " ++ pprint nm+ , " Must be one of: " ++ intercalate ", " (map (pprint . fst) cstrs)+ ]+ -- * sCase -- | Quasi-quoter for symbolic case expressions.@@ -319,95 +687,94 @@ bad ctx _ = fail Unknown $ "sCase: not usable in " <> ctx <> " context" extract :: String -> ExpQ- extract src =- case parts src of- Nothing -> fail Unknown $ unlines [ "sCase: Failed to parse a symbolic case-expression."- , ""- , " Instead of: case expr of alts"- , " Write : [sCase|Type expr of alts|]"- , ""- , " where Type is the underlying concrete type of the expression."- ]- Just ((typ, scrutStr), altsStr) -> do- let fnTok = "sCase" <> typ- fullCase = "case " <> scrutStr <> " of " <> altsStr- offsets = findOffsets src- case metaParse fullCase of- Right (CaseE scrut matches) -> do- fnName <- lookupValueName fnTok >>= \case- Just n -> pure (VarE n)- Nothing -> fail Unknown $ unlines [ "sCase: Unknown symbolic ADT: " <> typ- , ""- , " To use a symbolic case expression, declare your ADT, and then:"- , " mkSymbolic [''" <> typ <> "]"- , " In a template-haskell context."- ]- cases <- zipWithM (matchToPair scrut) (offsets ++ repeat Unknown) matches >>= checkCase scrut typ . concat- buildCase typ fnName scrut cases- Right _ -> fail Unknown "sCase: Parse error, cannot extract a case-expression."- Left err -> case lines err of- (_:loc:res) | ["SrcLoc", _, l, c] <- words loc, all isDigit l, all isDigit c- -> fail (OffBy (read l - 1) (read c - 1) 1) (unlines res)- _ -> fail Unknown $ "sCase parse error: " <> err+ extract src = do+ let fullCase = "case " <> src+ offsets = findOffsets src+ case metaParse fullCase of+ Right (CaseE scrut matches) -> processCaseExp offsets scrut matches+ Right _ -> fail Unknown "sCase: Parse error, cannot extract a case-expression."+ Left err -> handleParseError "sCase" err - buildCase _ caseFunc scrut (Left cases) = pure $ foldl AppE (caseFunc `AppE` scrut) cases- buildCase typ _caseFunc _scrut (Right cases) = do+-- | Core sCase pipeline: given a scrutinee and matches (already in TH AST form),+-- run type inference, match conversion, validation, and code generation.+-- Factored out of 'sCase' so that 'transformNestedCases' can call it for+-- inner @case@ expressions.+processCaseExp :: [Offset] -> Exp -> [Match] -> Q Exp+processCaseExp offsets scrut0 matches0 = do+ -- Transform any nested case expressions in the RHS/guards of each match.+ -- This ensures inner cases become symbolic before the outer case processes them.+ matches <- transformMatches matches0+ scrut <- transformNestedCases scrut0+ mbTypeInfo <- inferType "sCase" matches+ case mbTypeInfo of+ Nothing -> do+ -- Wildcard-only: no type needed, generate ite-chain directly+ allCases <- concat <$> zipWithM (matchToPair scrut) (offsets ++ repeat Unknown) matches+ loc <- location+ checkWildcard "sCase" loc allCases+ let wilds = [(mbG, rhs) | CWild _ mbG rhs <- allCases]+ -- An unguarded wildcard is the base case (no ite wrapper needed).+ -- checkWildcard guarantees an unguarded wildcard is last if present.+ iteChain [] = do uniq <- newName "u"+ let suffix = drop 2 (show uniq)+ pure $ AppE (VarE 'symWithKind) (LitE (StringL ("unmatched_sCase_wildcard_" ++ suffix)))+ iteChain ((Nothing, rhs) : _) = pure rhs+ iteChain ((Just g, rhs) : rest) = do r <- iteChain rest+ pure $ foldl AppE (VarE 'ite) [g, rhs, r]+ iteChain wilds+ Just (typ, mbt) -> do+ mbFnName <- case mbt of+ Just BTBool -> pure Nothing+ Just BTList -> pure Nothing -- Strategy B; see noAnalyzer comment above+ Just BTMaybe -> pure (Just (VarE (sbvName "Data.SBV.Maybe" "sCaseMaybe")))+ Just BTEither -> pure (Just (VarE (sbvName "Data.SBV.Either" "sCaseEither")))+ Just (BTTuple _) -> pure Nothing+ Nothing -> let fnTok = "sCase" <> typ+ in lookupValueName fnTok >>= \case+ Just n -> pure (Just (VarE n))+ Nothing -> fail Unknown $ unlines [ "sCase: Unknown symbolic ADT: " <> typ+ , ""+ , " To use a symbolic case expression, declare your ADT, and then:"+ , " mkSymbolic [''" <> typ <> "]"+ , " In a template-haskell context."+ ]+ let anyUserGuards = any (\(Match _ grhs _) -> case grhs of { GuardedB{} -> True; _ -> False }) matches+ cases <- zipWithM (matchToPair scrut) (offsets ++ repeat Unknown) matches >>= checkCase scrut typ mbt anyUserGuards . concat+ buildCase typ mbFnName scrut cases+ where+ buildCase :: String -> Maybe Exp -> Exp -> Either [Exp] [(Exp, Exp)] -> ExpQ+ buildCase _ (Just caseFunc) s (Left cases) = pure $ AppE (foldl AppE caseFunc cases) s+ buildCase _ Nothing _ (Left _) = error "sCase: impossible: Strategy A without case function"+ buildCase typ _ _scrut (Right cases) = do uniq <- newName "u" let suffix = drop 2 (show uniq)- iteChain [] = pure $ AppE (VarE 'sym) (LitE (StringL ("unmatched_sCase_" ++ typ ++ "_" ++ suffix)))- iteChain ((t, e) : rest) = do r <- iteChain rest- pure $ foldl AppE (VarE 'ite) [t, e, r]+ fallback = AppE (VarE 'symWithKind) (LitE (StringL ("unmatched_sCase_" ++ typ ++ "_" ++ suffix)))++ iteChain [] = pure fallback+ iteChain ((t, e) : rest)+ -- Last branch with a trivially-true guard (e.g., unguarded wildcard, or the last+ -- constructor in a complete match): use its rhs directly as the default,+ -- avoiding an unreachable fallback variable.+ | null rest, isTriviallyTrue t = pure e+ | True = do r <- iteChain rest+ pure $ foldl AppE (VarE 'ite) [t, e, r]++ isTriviallyTrue (VarE nm) = nameBase nm == nameBase 'sTrue+ isTriviallyTrue (ConE nm) = nameBase nm == "True"+ isTriviallyTrue _ = False iteChain cases -- Make sure things are in good-shape and decide if we have guards- checkCase :: Exp -> String -> [Case] -> Q (Either [Exp] [(Exp, Exp)])- checkCase scrut typ cases = do+ checkCase :: Exp -> String -> Maybe BuiltinType -> Bool -> [Case] -> Q (Either [Exp] [(Exp, Exp)])+ checkCase s typ mbt anyUserGuards cases = do loc <- location-- cstrs <- -- We don't need the field names if user supplied them; so drop them here- let dropFieldNames (c, nts) = (c, map snd nts)- in map dropFieldNames . snd <$> getConstructors (mkName typ)+ cstrs <- getCstrs mbt typ -- Is there a catch all clause? let hasCatchAll = or [True | CWild _ Nothing _ <- cases] - -- Step 0: If there's an unguarded wild-card, make sure nothing else follows it.- -- Note that this also handles wild-card being present twice.- let checkWild [] = pure ()- checkWild (CMatch{} : rest) = checkWild rest- checkWild (CWild _ Just{} _ : rest) = checkWild rest- checkWild (CWild o Nothing _ : rest) =- case rest of- [] -> pure ()- red -> fail o $ unlines $ "sCase: Wildcard makes the remaining matches redundant:"- : [" " ++ showCaseGen (Just loc) r | r <- red]- checkWild cases-- -- Step 2: Make sure every constructor listed actually exists and matches in arity.- let chk1 :: Case -> Q ()- chk1 c = case c of- CMatch o nm ps _ _ _ -> isSafe o nm (length <$> ps)- CWild {} -> pure ()- where isSafe :: Offset -> Name -> Maybe Int -> Q ()- isSafe o nm mbLen- | Just ts <- nm `lookup` cstrs- = case mbLen of- Nothing -> pure ()- Just cnt -> unless (length ts == cnt)- $ fail o $ unlines [ "sCase: Arity mismatch."- , " Type : " ++ typ- , " Constructor: " ++ nameBase nm- , " Expected : " ++ show (length ts)- , " Given : " ++ show cnt- ]- | True- = fail o $ unlines [ "sCase: Unknown constructor:"- , " Type : " ++ typ- , " Saw : " ++ pprint nm- , " Must be one of: " ++ intercalate ", " (map (pprint . fst) cstrs)- ]-- mapM_ chk1 cases+ checkWildcard "sCase" loc cases+ checkArities "sCase" typ cstrs cases -- Step 2: Make sure constructor matches are not overlapping let problem w extras x = fail (caseOffset x) $ unlines $ [ "sCase: " ++ w ++ ":"@@ -431,41 +798,47 @@ , " You can use a '_' to match multiple cases." ] -- We're done- chk2 [] = pure ()+ chk2 _ [] = pure () -- If we have a non-guarded match, then there must be no matches for this constructor later on. If so, they're redundant.- chk2 (c@(CMatch _ nm _ Nothing _ _) : rest)- = case filter (\oc -> getCaseConstructor oc == Just nm) rest of- [] -> chk2 rest+ chk2 seen (c@(CMatch _ nm _ Nothing _ _) : rest)+ = case filter (maybe False (sameBase nm) . getCaseConstructor) rest of+ [] -> chk2 (Set.insert (nameBase nm) seen) rest os -> overlap (last os) (c : init os) -- If we have a guarded match, then this guard can fail. So either there must be a match- -- for it later on, or there must be a catch-all. Note that if it exists later, we don't- -- care if that occurrence is guarded or not; because if it is guarded, we'll fail on the last one.- chk2 (c@(CMatch _ nm _ Just{} _ _) : rest)- | hasCatchAll || Just nm `elem` map getCaseConstructor rest- = chk2 rest+ -- for it later on, or there must be a catch-all. We also accept it if the same constructor+ -- was seen earlier (e.g., multiple nested-pattern alternatives like Left (x:_) / Left []).+ chk2 seen (c@(CMatch _ nm _ Just{} _ _) : rest)+ | hasCatchAll || any (maybe False (sameBase nm) . getCaseConstructor) rest || nameBase nm `Set.member` seen+ = chk2 (Set.insert (nameBase nm) seen) rest | True = unmatched c -- If there's a guarded wildcard, must make sure there's a catch all afterwards- chk2 (c@(CWild _ Just{} _) : rest)+ chk2 seen (c@(CWild _ Just{} _) : rest) | hasCatchAll- = chk2 rest+ = chk2 seen rest | True = unmatched c -- No need to worry about anything following catch-all, since we already covered that before- chk2 (CWild _ Nothing _ : rest) = chk2 rest+ chk2 seen (CWild _ Nothing _ : rest) = chk2 seen rest - chk2 cases+ chk2 Set.empty cases -- At this point, we either have a simple case with no guards, in which case -- we translate this to an sCase for that type. So find all alternatives.- -- Otherwise, this will become an ite-chain- let hasGuards = any isGuarded cases+ -- Otherwise, this will become an ite-chain.+ -- Bool, List, and Tuple use the ite-chain path (Strategy B) directly.+ -- List is excluded from Strategy A because the case-analysis combinator 'list' is itself+ -- a candidate for sCase rewriting; calling it here would create a circular dependency.+ -- Maybe, Either, and user ADTs can use Strategy A (calling sCaseMaybe/sCaseEither/sCaseADT).+ let hasGuards = any isGuarded cases+ noAnalyzer = case mbt of { Just BTBool -> True; Just BTList -> True; Just (BTTuple _) -> True; _ -> False }+ useIteChain = hasGuards || noAnalyzer - if not hasGuards+ if not useIteChain then do defaultCase <- case [((e, mbg), c) | c@(CWild _ mbg e) <- cases] of [] -> pure Nothing [((e, Nothing), c)] -> pure $ Just (caseOffset c, e)@@ -477,11 +850,11 @@ ] let find _ [] = Nothing find w (c:cs)- | matches = Just c- | True = find w cs- where matches = case c of- CMatch _ nm _ _ _ _ -> nm == w- CWild {} -> False+ | mtches = Just c+ | True = find w cs+ where mtches = case c of+ CMatch _ nm _ _ _ _ -> sameBase nm w+ CWild {} -> False case2rhs :: Case -> [Type] -> (Maybe Exp, Exp) case2rhs cs ts = (LamE pats <$> mbGuard, LamE pats e)@@ -523,9 +896,9 @@ -- Collect, for each constructor, the corresponding cases: let cstrMatches :: [(Name, ([Type], [Case]))]- cstrMatches = map (\(cstr, ts) -> (cstr, (ts, concatMap (matches cstr) cases))) cstrs- where matches cstr c | Just n <- getCaseConstructor c, n == cstr = [c]- | True = []+ cstrMatches = map (\(cstr, ts) -> (cstr, (ts, concatMap (mtches cstr) cases))) cstrs+ where mtches cstr c | Just n <- getCaseConstructor c, sameBase n cstr = [c]+ | True = [] -- Make sure we have a match for every constructor or a catch-all unless hasCatchAll $ case [nm | (nm, (_, [])) <- cstrMatches] of@@ -544,14 +917,13 @@ let collect :: Case -> Q (Exp, Exp) collect (CWild _ mbG rhs ) = pure (fromMaybe (VarE 'sTrue) mbG, rhs) collect (CMatch o nm mbp mbG rhs allUsed) = do- case nm `lookup` cstrs of+ case lookupBase nm cstrs of Nothing -> fail o $ unlines [ "sCase: Impossible happened." , " Unable to determine params for: " <> pprint nm ] Just ts -> do let pats = fromMaybe (map (const WildP) ts) mbp- args = [ AppE (VarE (mkName ("get" ++ nameBase nm ++ "_" ++ show i))) scrut- | (i, _) <- zip [(1 :: Int) ..] ts]- rec = VarE $ mkName $ "is" ++ nameBase nm+ args = [mkAccessorFor mbt nm i s | (i, _) <- zip [(1 :: Int) ..] ts]+ testerExpr = mkTesterFor mbt nm s -- What are the free variables in the guard and the rhs that we bind? used = Set.fromList [n | VarP n <- pats] `Set.intersection` allUsed@@ -563,13 +935,71 @@ grd :: Exp grd = case mbG of- Nothing -> AppE rec scrut- Just g -> foldl1 AppE [VarE '(.&&), AppE rec scrut, mkApp (close g)]+ Nothing -> testerExpr+ Just g -> sAndAll [testerExpr, mkApp (close g)] pure (grd, mkApp (close rhs)) - Right <$> mapM collect cases+ pairs <- mapM collect cases + -- When every constructor has at least one unguarded match, the pattern+ -- is exhaustive. The last entry's tester is then redundant — replace it+ -- with sTrue so buildCase uses it as the default, avoiding an unreachable+ -- fallback variable.+ -- For single-constructor types (tuples), all branches match the sole+ -- constructor, with guards from nested patterns only. When there are no+ -- user-provided guards, the nested patterns partition the space and the+ -- last branch is the default.+ let allCovered = all hasUnguarded cstrs+ || (length cstrs == 1 && not anyUserGuards)+ hasUnguarded (cstr, _) = any (\case CMatch _ nm _ Nothing _ _ -> sameBase nm cstr; _ -> False) cases+ optimize ps | allCovered, not (null ps)+ = init ps ++ [(VarE 'sTrue, snd (last ps))]+ | True = ps++ pure $ Right (optimize pairs)++-- | Transform nested @case@ expressions inside a TH 'Exp' into symbolic case expressions.+-- Walks the expression bottom-up: inner cases are transformed before outer ones.+-- This is what enables @case@ expressions inside @[sCase| ... |]@ to work as symbolic cases.+transformNestedCases :: Exp -> Q Exp+transformNestedCases = everywhereM (mkM go)+ where go :: Exp -> Q Exp+ go (CaseE s ms) = processCaseExp (repeat Unknown) s ms+ go e = pure e++-- | Transform the matches of an outer sCase expression, resolving any nested+-- @case@ expressions in the RHS and guards before the outer case processes them.+transformMatches :: [Match] -> Q [Match]+transformMatches = mapM transformMatch+ where transformMatch (Match pat body locals) = do+ body' <- transformBody body+ locals' <- mapM transformDec locals+ pure (Match pat body' locals')++ transformBody (NormalB e) = NormalB <$> transformNestedCases e+ transformBody (GuardedB gs) = GuardedB <$> mapM transformGuarded gs++ transformGuarded (g, e) = do g' <- transformGuard g+ e' <- transformNestedCases e+ pure (g', e')++ transformGuard (NormalG e) = NormalG <$> transformNestedCases e+ transformGuard (PatG ss) = PatG <$> mapM transformStmt ss++ transformStmt (NoBindS e) = NoBindS <$> transformNestedCases e+ transformStmt s = pure s++ transformDec (ValD p b ls) = do b' <- transformBody b+ ls' <- mapM transformDec ls+ pure (ValD p b' ls')+ transformDec (FunD n cs) = FunD n <$> mapM transformClause cs+ transformDec d = pure d++ transformClause (Clause ps b ls) = do b' <- transformBody b+ ls' <- mapM transformDec ls+ pure (Clause ps b' ls')+ -- * pCase -- | Quasi-quoter for proof case-splits.@@ -593,47 +1023,42 @@ bad ctx _ = fail Unknown $ "pCase: not usable in " <> ctx <> " context" extractProof :: String -> ExpQ- extractProof src =- case parts src of- Nothing -> fail Unknown $ unlines [ "pCase: Failed to parse a proof case-expression."- , ""- , " Instead of: case expr of alts"- , " Write : [pCase|Type expr of alts|]"- , ""- , " where Type is the underlying concrete type of the expression."- ]- Just ((typ, scrutStr), altsStr) -> do- let fullCase = "case " <> scrutStr <> " of " <> altsStr- offsets = findOffsets src- case metaParse fullCase of- Right (CaseE scrut matches) -> do+ extractProof src = do+ let fullCase = "case " <> src+ offsets = findOffsets src+ case metaParse fullCase of+ Right (CaseE scrut0 matches0) -> do+ -- Transform any nested case expressions in the RHS/guards of each match.+ -- This ensures inner cases become symbolic before the outer case processes them.+ matches <- transformMatches matches0+ scrut <- transformNestedCases scrut0+ mbTypeInfo <- inferType "pCase" matches+ case mbTypeInfo of+ Nothing -> do+ -- Wildcard-only: no type needed, build proof cases directly+ allCases <- concat <$> zipWithM (matchToPair scrut) (offsets ++ repeat Unknown) matches+ loc <- location+ checkWildcard "pCase" loc allCases+ allPairs <- processCases scrut [] Nothing Map.empty [] allCases+ let casesName = mkName "cases"+ impliesName = mkName "==>"+ mkPair (g, r) = InfixE (Just g) (VarE impliesName) (Just r)+ pure $ AppE (VarE casesName) (ListE (map mkPair allPairs))+ Just (typ, mbt) -> do cs <- zipWithM (matchToPair scrut) (offsets ++ repeat Unknown) matches- validated <- checkProofCase typ (concat cs)- buildProofCase scrut typ validated- Right _ -> fail Unknown "pCase: Parse error, cannot extract a case-expression."- Left err -> case lines err of- (_:loc:res) | ["SrcLoc", _, l, c] <- words loc, all isDigit l, all isDigit c- -> fail (OffBy (read l - 1) (read c - 1) 1) (unlines res)- _ -> fail Unknown $ "pCase parse error: " <> err+ validated <- checkProofCase typ mbt (concat cs)+ buildProofCase scrut typ mbt validated+ Right _ -> fail Unknown "pCase: Parse error, cannot extract a case-expression."+ Left err -> handleParseError "pCase" err -- | Validate cases for proof context- checkProofCase :: String -> [Case] -> Q [Case]- checkProofCase typ cases = do+ checkProofCase :: String -> Maybe BuiltinType -> [Case] -> Q [Case]+ checkProofCase typ mbt cases = do loc <- location-- cstrs <- let dropFieldNames (c, nts) = (c, map snd nts)- in map dropFieldNames . snd <$> getConstructors (mkName typ)+ cstrs <- getCstrs mbt typ - -- Validate wildcard placement: unguarded wildcard must be last, nothing after it- let checkWild [] = pure ()- checkWild (CMatch{} : rest) = checkWild rest- checkWild (CWild _ Just{} _ : rest) = checkWild rest- checkWild (CWild o Nothing _ : rest) =- case rest of- [] -> pure ()- red -> fail o $ unlines $ "pCase: Wildcard makes the remaining matches redundant:"- : [" " ++ showCaseGen (Just loc) r | r <- red]- checkWild cases+ checkWildcard "pCase" loc cases+ checkArities "pCase" typ cstrs cases -- Wildcards must come after all explicit constructor matches let checkWildBeforeCstr [] = pure ()@@ -644,35 +1069,10 @@ checkWildBeforeCstr (_ : rest) = checkWildBeforeCstr rest checkWildBeforeCstr cases - -- Check arity and constructor validity- let chk1 :: Case -> Q ()- chk1 c = case c of- CMatch o nm ps _ _ _ -> isSafe o nm (length <$> ps)- CWild {} -> pure ()- where isSafe o nm mbLen- | Just ts <- nm `lookup` cstrs- = case mbLen of- Nothing -> pure ()- Just cnt -> unless (length ts == cnt)- $ fail o $ unlines [ "pCase: Arity mismatch."- , " Type : " ++ typ- , " Constructor: " ++ nameBase nm- , " Expected : " ++ show (length ts)- , " Given : " ++ show cnt- ]- | True- = fail o $ unlines [ "pCase: Unknown constructor:"- , " Type : " ++ typ- , " Saw : " ++ pprint nm- , " Must be one of: " ++ intercalate ", " (map (pprint . fst) cstrs)- ]-- mapM_ chk1 cases- -- Check overlap: unguarded constructor match followed by same constructor let chk2 [] = pure () chk2 (c@(CMatch _ nm _ Nothing _ _) : rest)- = case filter (\oc -> getCaseConstructor oc == Just nm) rest of+ = case filter (maybe False (sameBase nm) . getCaseConstructor) rest of [] -> chk2 rest os -> overlap loc (last os) (c : init os) chk2 (_ : rest) = chk2 rest@@ -681,7 +1081,7 @@ -- If every constructor has an unguarded match, any wildcard is redundant let fullyCovered = [ cstr | (cstr, _) <- cstrs- , any (\c -> getCaseConstructor c == Just cstr && not (isGuarded c)) cases+ , any (\c -> maybe False (sameBase cstr) (getCaseConstructor c) && not (isGuarded c)) cases ] case [c | c@CWild{} <- cases] of [] -> pure ()@@ -700,17 +1100,16 @@ ++ [ " " ++ showCaseGen (Just loc) p | p <- xs] -- | Build the proof case expression- buildProofCase :: Exp -> String -> [Case] -> ExpQ- buildProofCase scrut typ cases = do- cstrs <- let dropFieldNames (c, nts) = (c, map snd nts)- in map dropFieldNames . snd <$> getConstructors (mkName typ)+ buildProofCase :: Exp -> String -> Maybe BuiltinType -> [Case] -> ExpQ+ buildProofCase scrut typ mbt cases = do+ cstrs <- getCstrs mbt typ -- Collect guard variables for each constructor across all arms -- (needed to suppress false "unused binding" warnings for guard-only variables) let allGrdVars :: Map Name (Set Name) allGrdVars = Map.fromListWith Set.union [ (nm, maybe Set.empty freeVars mbG) | CMatch _ nm _ mbG _ _ <- cases ]- allPairs <- processCases scrut cstrs allGrdVars [] cases+ allPairs <- processCases scrut cstrs mbt allGrdVars [] cases let casesName = mkName "cases" impliesName = mkName "==>" mkPair (g, r) = InfixE (Just g) (VarE impliesName) (Just r)@@ -722,35 +1121,50 @@ -- fullGuard = the complete guard expression (used for wildcard De Morgan negation) -- userGuardOnly = Just the user guard part (used for same-constructor negation) -- Nothing if unguarded (same-constructor arms don't negate unguarded matches)- processCases :: Exp -> [(Name, [Type])] -> Map Name (Set Name) -> [(Maybe Name, Exp, Maybe Exp)] -> [Case] -> Q [(Exp, Exp)]- processCases _ _ _ _ [] = pure []- processCases scrut cstrs allGrdVars priorGuards (c:rest) = case c of+ processCases :: Exp -> [(Name, [Type])] -> Maybe BuiltinType -> Map Name (Set Name) -> [(Maybe Name, Exp, Maybe Exp)] -> [Case] -> Q [(Exp, Exp)]+ processCases _ _ _ _ _ [] = pure []+ processCases scrut cstrs mbt allGrdVars priorGuards (c:rest) = case c of CWild _ mbG rhs -> do -- Wildcard: negate the disjunction of ALL prior full guards (De Morgan) let allGuards = [g | (_, g, _) <- priorGuards] baseGuard = negateAll allGuards finalGuard = case mbG of Nothing -> baseGuard- Just g -> foldl1 AppE [VarE '(.&&), baseGuard, g]- rest' <- processCases scrut cstrs allGrdVars (priorGuards ++ [(Nothing, finalGuard, Nothing)]) rest+ Just g -> sAndAll [baseGuard, g]+ rest' <- processCases scrut cstrs mbt allGrdVars (priorGuards ++ [(Nothing, finalGuard, Nothing)]) rest pure $ (finalGuard, rhs) : rest' CMatch _o nm mbp mbG rhs _allUsed -> do- let ts = case lookup nm cstrs of+ let ts = case lookupBase nm cstrs of Just t -> t Nothing -> error $ "pCase: impossible: unknown constructor " ++ nameBase nm pats = fromMaybe (map (const WildP) ts) mbp -- Build let-bindings for pattern variables- args = [ (i, AppE (VarE (mkName ("get" ++ nameBase nm ++ "_" ++ show i))) scrut)- | (i, _) <- zip [(1 :: Int) ..] ts ]+ args = [(i, mkAccessorFor mbt nm i scrut) | (i, _) <- zip [(1 :: Int) ..] ts] bindings = [ ValD (VarP v) (NormalB acc) [] | (i, acc) <- args, VarP v <- [pats !! (i - 1)] ] - testerGuard = AppE (VarE (mkName ("is" ++ nameBase nm))) scrut+ testerGuard = mkTesterFor mbt nm scrut + -- For list cons patterns in pCase, add a destructuring equality:+ -- scrut .=== head scrut .: tail scrut+ -- Lists use SMT Seq (not declare-datatypes), so the solver doesn't automatically+ -- know that xs = head xs .: tail xs from sNot (null xs). We must add an explicit+ -- equality to give the solver this information, mirroring what 'split' does.+ -- All other types (ADTs, Maybe, Either, Tuple) use declare-datatypes and get+ -- these axioms for free.+ -- NB. For nested list cons patterns, the same equality is added by 'flattenCons'.+ destructEq+ | Just BTList <- mbt, nameBase nm == ":"+ = let hd = AppE (VarE (sbvName "Data.SBV.List" "head")) scrut+ tl = AppE (VarE (sbvName "Data.SBV.List" "tail")) scrut+ in [foldl1 AppE [VarE '(.===), scrut, InfixE (Just hd) (VarE '(.:)) (Just tl)]]+ | True+ = []+ -- Only negate prior USER guards for the SAME constructor (others are mutually exclusive)- sameUserGuards = [ ug | (Just cn, _, Just ug) <- priorGuards, cn == nm ]+ sameUserGuards = [ ug | (Just cn, _, Just ug) <- priorGuards, sameBase cn nm ] negPriors = map (AppE (VarE 'sNot)) sameUserGuards -- Build the final guard (wrap user guard in bindings so pattern vars are in scope)@@ -758,11 +1172,8 @@ grdBindings = filter (\case ValD (VarP v) _ _ -> v `Set.member` grdVars _ -> True) bindings- guardParts = [testerGuard] ++ negPriors ++ maybe [] (pure . addLocals grdBindings) mbG- finalGuard = case guardParts of- [] -> VarE 'sTrue- [g] -> g- gs -> foldl1 (\a b -> foldl1 AppE [VarE '(.&&), a, b]) gs+ guardParts = [testerGuard] ++ destructEq ++ negPriors ++ maybe [] (pure . addLocals grdBindings) mbG+ finalGuard = sAndAll guardParts -- Wrap RHS with let-bindings; include all bindings except those -- used in any guard of the same constructor but not in this RHS@@ -779,7 +1190,7 @@ Nothing -> Nothing priorGuards' = priorGuards ++ [(Just nm, finalGuard, userGuardOnly)] - rest' <- processCases scrut cstrs allGrdVars priorGuards' rest+ rest' <- processCases scrut cstrs mbt allGrdVars priorGuards' rest pure $ (finalGuard, rhs') : rest' -- | Negate the disjunction of all given guards using De Morgan: sNot (g1 .|| g2 .|| ...)@@ -817,12 +1228,12 @@ -- | Generate a symbolic equality guard for a literal pattern. -- @litToEq off arg lit@ produces the expression @arg .== litVal@. -- For integers, the literal is used directly (relying on @fromInteger@).--- For strings, the literal is wrapped with @literal@ to convert @String@ to @SString@.--- Only integer and string literals are supported; others produce a compile error.+-- For characters and strings, the literal is wrapped with @literal@. litToEq :: Offset -> Exp -> Lit -> Q Exp litToEq _ arg (IntegerL n) = pure $ foldl1 AppE [VarE '(.==), arg, LitE (IntegerL n)]+litToEq _ arg (CharL c) = pure $ foldl1 AppE [VarE '(.==), arg, AppE (VarE 'literal) (LitE (CharL c))] litToEq _ arg (StringL s) = pure $ foldl1 AppE [VarE '(.==), arg, AppE (VarE 'literal) (LitE (StringL s))] litToEq off _ lit = fail off $ unlines [ "sCase/pCase: Unsupported literal in pattern: " ++ show lit- , " Only integer and string literals are supported."+ , " Only integer, character, and string literals are supported." ]
Data/SBV/SMT/SMT.hs view
@@ -9,6 +9,7 @@ -- Abstraction of SMT solvers ----------------------------------------------------------------------------- +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE NamedFieldPuns #-}@@ -109,10 +110,10 @@ deriving NFData -- | An 'Data.SBV.allSat' call results in a t'AllSatResult'-data AllSatResult = AllSatResult { allSatMaxModelCountReached :: Bool -- ^ Did we reach the user given model count limit?- , allSatSolverReturnedUnknown :: Bool -- ^ Did the solver report unknown at the end?- , allSatSolverReturnedDSat :: Bool -- ^ Did the solver report delta-satisfiable at the end?- , allSatResults :: [SMTResult] -- ^ All satisfying models+data AllSatResult = AllSatResult { allSatMaxModelCountReached :: !Bool -- ^ Did we reach the user given model count limit?+ , allSatSolverReturnedUnknown :: !Bool -- ^ Did the solver report unknown at the end?+ , allSatSolverReturnedDSat :: !Bool -- ^ Did the solver report delta-satisfiable at the end?+ , allSatResults :: ![SMTResult] -- ^ All satisfying models } -- | A 'Data.SBV.safe' call results in a t'SafeResult'@@ -825,7 +826,7 @@ go isFirst i sofar = do errln <- safeGetLine isFirst outh `C.catch` (\(e :: C.SomeException) -> handleAsync e (return (SolverException (show e)))) case errln of- SolverRegular ln -> let need = i + parenDeficit ln+ SolverRegular ln -> let !need = i + parenDeficit ln -- make sure we get *something* empty = case dropWhile isSpace ln of [] -> True
Data/SBV/SMT/SMTLib2.hs view
@@ -224,7 +224,7 @@ = case ctx of QueryExternal -> ["(set-logic ALL) ; external query, using all logics."] QueryInternal -> if supportsBitVectors solverCaps- then ["(set-logic " <> T.pack (T.unpack qs <> T.unpack as <> T.unpack ufs) <> "BV)"]+ then ["(set-logic " <> qs <> as <> ufs <> "BV)"] else ["(set-logic ALL)"] -- fall-thru where qs | not needsQuantifiers = "QF_" | True = ""
Data/SBV/SMT/Utils.hs view
@@ -35,7 +35,6 @@ import qualified Control.Exception as C -import Control.Monad (zipWithM_) import Control.Monad.Trans (MonadIO, liftIO) import Data.SBV.Core.Data@@ -278,7 +277,7 @@ xs -> (ts ++ "] Received: ") : map ("; " ++) xs DebugMsg msg -> let tag = ts ++ "] " emp = ';' : drop 1 (map (const ' ') tag)- in zipWithM_ (\t l -> appendFile f (t ++ l ++ "\n")) (tag : repeat emp) (lines msg)+ in appendFile f $ unlines $ zipWith (++) (tag : repeat emp) (lines msg) where to Nothing = "" to (Just i) = "[Timeout: " ++ showTimeoutValue i ++ "] " {-# INLINE recordTranscript #-}
Data/SBV/TP.hs view
@@ -48,8 +48,11 @@ , sorry -- * Running TP proofs- , TP, runTP, runTPWith, tpQuiet, tpRibbon, tpStats, tpAsms, tpCache+ , TP, runTP, runTPWith, tpQuiet, tpRibbon, tpStats, tpAsms + -- * Measure helpers for smtFunctionWithMeasure+ , measureLemma, measureLemmaWith+ -- * Starting a calculation proof , (|-), (⊢), (|->) @@ -71,7 +74,7 @@ -- * Displaying intermediate values of expressions , disp - -- * Recall an old proof, quietly proving it+ -- * Recall an old proof, using the cache , recall, recallWith ) where
Data/SBV/TP/Kernel.hs view
@@ -26,9 +26,10 @@ , inductiveLemma, inductiveLemmaWith , internalAxiom , TPProofContext (..), smtProofStep, HasInductionSchema(..)- , tpMergeCfg+ , tpMergeCfg, checkNewMeasures ) where +import Control.Monad (unless) import Control.Monad.Trans (liftIO, MonadIO) import Data.List (intercalate)@@ -36,7 +37,7 @@ import Data.SBV.Core.Data hiding (None) import Data.SBV.Trans.Control hiding (getProof)-import Data.SBV.Core.Symbolic (MonadSymbolic)+import Data.SBV.Core.Symbolic (MonadSymbolic(..), rSkipMeasureChecks, rMeasureChecks, rNoTermCheckFunctions) import Data.SBV.SMT.SMT import Data.SBV.Core.Model@@ -48,11 +49,11 @@ import Data.SBV.Utils.TDiff import Data.Dynamic+import Data.IORef (readIORef, writeIORef, modifyIORef')+import qualified Data.Set as Set import Type.Reflection (typeRep) -import qualified Data.SBV.List as SL ((.:))- -- | A proposition is something SBV is capable of proving/disproving in TP. type Proposition a = ( QNot a , QuantifiedBool a@@ -123,7 +124,7 @@ instance SymVal x => HasInductionSchema (Forall nm [x] -> SBool) where inductionSchema p = proofOf $ internalAxiom ("induct" ++ show (typeRep @[x])) ax where pf = p . Forall- ax = sAnd [pf [], quantifiedBool (\(Forall x) (Forall xs) -> pf xs .=> pf (x SL..: xs))]+ ax = sAnd [pf [], quantifiedBool (\(Forall x) (Forall xs) -> pf xs .=> pf (x .: xs))] .=> quantifiedBool (\(Forall xs) -> pf xs) -- | Induction schema for lists with one extra argument@@ -131,7 +132,7 @@ inductionSchema p = proofOf $ internalAxiom ("induct" ++ show (typeRep @[x]) ++ "1") ax where pf xs a = p (Forall xs) (Forall a) ax = sAnd [ quantifiedBool (\ (Forall a) -> pf [] a)- , quantifiedBool (\(Forall x) (Forall xs) (Forall a) -> pf xs a .=> pf (x SL..: xs) a)]+ , quantifiedBool (\(Forall x) (Forall xs) (Forall a) -> pf xs a .=> pf (x .: xs) a)] .=> quantifiedBool (\(Forall xs) (Forall a) -> pf xs a) -- | Induction schema for lists with two extra arguments@@ -139,7 +140,7 @@ inductionSchema p = proofOf $ internalAxiom ("induct" ++ show (typeRep @[x]) ++ "2") ax where pf xs a b = p (Forall xs) (Forall a) (Forall b) ax = sAnd [ quantifiedBool (\ (Forall a) (Forall b) -> pf [] a b)- , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) -> pf xs a b .=> pf (x SL..: xs) a b)]+ , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) -> pf xs a b .=> pf (x .: xs) a b)] .=> quantifiedBool (\(Forall xs) (Forall a) (Forall b) -> pf xs a b) -- | Induction schema for lists with three extra arguments@@ -147,7 +148,7 @@ inductionSchema p = proofOf $ internalAxiom ("induct" ++ show (typeRep @[x]) ++ "3") ax where pf xs a b c = p (Forall xs) (Forall a) (Forall b) (Forall c) ax = sAnd [ quantifiedBool (\ (Forall a) (Forall b) (Forall c) -> pf [] a b c)- , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) (Forall c) -> pf xs a b c .=> pf (x SL..: xs) a b c)]+ , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) (Forall c) -> pf xs a b c .=> pf (x .: xs) a b c)] .=> quantifiedBool (\(Forall xs) (Forall a) (Forall b) (Forall c) -> pf xs a b c) -- | Induction schema for lists with four extra arguments@@ -155,7 +156,7 @@ inductionSchema p = proofOf $ internalAxiom ("induct" ++ show (typeRep @[x]) ++ "4") ax where pf xs a b c d = p (Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) ax = sAnd [ quantifiedBool (\ (Forall a) (Forall b) (Forall c) (Forall d) -> pf [] a b c d)- , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) -> pf xs a b c d .=> pf (x SL..: xs) a b c d)]+ , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) -> pf xs a b c d .=> pf (x .: xs) a b c d)] .=> quantifiedBool (\(Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) -> pf xs a b c d) -- | Induction schema for lists with five extra arguments@@ -163,7 +164,7 @@ inductionSchema p = proofOf $ internalAxiom ("induct" ++ show (typeRep @[x]) ++ "5") ax where pf xs a b c d e = p (Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) (Forall e) ax = sAnd [ quantifiedBool (\ (Forall a) (Forall b) (Forall c) (Forall d) (Forall e) -> pf [] a b c d e)- , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) (Forall e) -> pf xs a b c d e .=> pf (x SL..: xs) a b c d e)]+ , quantifiedBool (\(Forall x) (Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) (Forall e) -> pf xs a b c d e .=> pf (x .: xs) a b c d e)] .=> quantifiedBool (\(Forall xs) (Forall a) (Forall b) (Forall c) (Forall d) (Forall e) -> pf xs a b c d e) -- | Accept the given definition as a fact. Usually used to introduce definitial axioms,@@ -185,13 +186,14 @@ , getProp = toDyn p , proofName = nm , uniqId = TPInternal- , isCached = False+ , aliases = []+ , wasCached = False } -- | Propagate the settings for ribbon/timing from top to current. Because in any subsequent configuration -- in a lemmaWith, inductWith etc., we just want to change the solver, not the actual settings for TP. tpMergeCfg :: SMTConfig -> SMTConfig -> SMTConfig-tpMergeCfg cur top = cur{tpOptions = tpOptions top}+tpMergeCfg cur top = cur{verbose = verbose top, tpOptions = tpOptions top} -- | Prove a given statement, using auxiliaries as helpers. Using the default solver. lemma :: Proposition a => String -> a -> [ProofObj] -> TP (Proof a)@@ -200,27 +202,47 @@ -- | Prove a lemma, using the given configuration. lemmaWith :: Proposition a => SMTConfig -> String -> a -> [ProofObj] -> TP (Proof a)-lemmaWith cfgIn nm inputProp by = withProofCache nm $ do+lemmaWith cfgIn nm inputProp by = do+ cached <- lookupProofCache inputProp topCfg <- getTPConfig- let cfg@SMTConfig{tpOptions = TPOptions{printStats}} = cfgIn `tpMergeCfg` topCfg- tpSt <- getTPState- u <- tpGetNextUnique- liftIO $ getTimeStampIf printStats >>= runSMTWith cfg . go tpSt cfg u- where go tpSt cfg u mbStartTime = do qSaturateSavingObservables inputProp+ case cached of+ Just prf -> do let cfg = cfgIn `tpMergeCfg` topCfg+ returnCachedProof cfg nm prf+ Nothing -> do let cfg@SMTConfig{tpOptions = TPOptions{printStats}} = cfgIn `tpMergeCfg` topCfg+ tpSt <- getTPState+ u <- tpGetNextUnique+ result <- liftIO $ getTimeStampIf printStats >>= runSMTWith cfg . go tpSt cfg u+ addToProofCache inputProp (proofOf result)+ pure result+ where go tpSt cfg u mbStartTime = do st <- symbolicEnv+ -- Skip measure checks in the normal runWithQuery path; we handle them here+ liftIO $ writeIORef (rSkipMeasureChecks st) True+ qSaturateSavingObservables inputProp mapM_ (constrain . getObjProof) by- query $ smtProofStep cfg tpSt "Lemma" 0 (TPProofOneShot nm by) Nothing inputProp [] (good cfg mbStartTime u) + -- Run measure checks for any newly encountered recursive functions+ liftIO $ checkNewMeasures cfg st tpSt++ -- Read no-term-check functions from this proof's State (not TPState, which accumulates)+ noTermFns <- liftIO $ readIORef (rNoTermCheckFunctions st)++ query $ smtProofStep cfg tpSt "Lemma" 0 (TPProofOneShot nm by) Nothing inputProp [] (good noTermFns cfg mbStartTime u)+ -- What to do if all goes well- good cfg mbStart u d = do mbElapsed <- getElapsedTime mbStart- liftIO $ finishTP cfg ("Q.E.D." ++ concludeModulo by) d $ catMaybes [mbElapsed]- pure $ Proof $ ProofObj { dependencies = by- , isUserAxiom = False- , getObjProof = label nm (quantifiedBool inputProp)- , getProp = toDyn inputProp- , proofName = nm- , uniqId = u- , isCached = False- }+ good noTermFns cfg mbStart u d = do+ mbElapsed <- getElapsedTime mbStart+ let ntcDeps = map noTermCheckProof (Set.toList noTermFns)+ allBy = by ++ ntcDeps+ liftIO $ finishTP cfg ("Q.E.D." ++ concludeModulo allBy) d $ catMaybes [mbElapsed]+ pure $ Proof $ ProofObj { dependencies = allBy+ , isUserAxiom = False+ , getObjProof = label nm (quantifiedBool inputProp)+ , getProp = toDyn inputProp+ , proofName = nm+ , uniqId = u+ , aliases = []+ , wasCached = False+ } -- | Prove a given statement, using the induction schema for the proposition. Using the default solver. inductiveLemma :: Inductive a => String -> a -> [ProofObj] -> TP (Proof a)@@ -230,6 +252,41 @@ -- | Prove a given statement, using the induction schema for the proposition. Using the default solver. inductiveLemmaWith :: Inductive a => SMTConfig -> String -> a -> [ProofObj] -> TP (Proof a) inductiveLemmaWith cfg nm f by = lemmaWith cfg nm f (inductionSchema f : by)++-- | Check any newly encountered recursive function measures. This reads deferred checks+-- from 'rMeasureChecks', runs those not yet verified, and records them as verified.+-- Skips functions in 'measuresBeingVerified' to prevent infinite recursion when a+-- measureLemma proof uses the function whose measure is currently being checked.+checkNewMeasures :: SMTConfig -> State -> TPState -> IO ()+checkNewMeasures cfg@SMTConfig{tpOptions = TPOptions{measuresBeingVerified}} st tpSt = do+ checks <- readIORef (rMeasureChecks st)+ verified <- readIORef (measuresVerified tpSt)+ productive <- readIORef (productiveVerified tpSt)+ let allVerified = verified `Set.union` productive+ allNames = Set.fromList (map (\(n, _, _) -> n) checks)+ new = [(n, p, c) | (n, p, c) <- checks, n `Set.notMember` allVerified, n `Set.notMember` measuresBeingVerified]+ skipped = [n | (n, _, _) <- checks, n `Set.notMember` allVerified, n `Set.member` measuresBeingVerified]++ msg s | not (verbose cfg)+ = pure ()+ | Just f <- redirectVerbose cfg+ = appendFile f (s ++ "\n")+ | True+ = putStrLn s++ unless (null new && null skipped) $+ msg $ "[MEASURE] checkNewMeasures: " ++ show (length new) ++ " to verify"+ ++ (if null skipped then "" else ", " ++ show (length skipped) ++ " skipped (being verified): " ++ show skipped)++ modifyIORef' (measuresEncountered tpSt) (Set.union allNames)+ let verify (n, isProductive, c) = do+ msg $ "[MEASURE] checkNewMeasures: verifying " ++ n+ () <- c cfg+ msg $ "[MEASURE] checkNewMeasures: " ++ n ++ " verified"+ if isProductive+ then modifyIORef' (productiveVerified tpSt) (Set.insert n)+ else modifyIORef' (measuresVerified tpSt) (Set.insert n)+ mapM_ verify new -- | Capture the general flow of a proof-step. Note that this is the only point where we call the backend solver -- in a TP proof.
Data/SBV/TP/TP.hs view
@@ -31,7 +31,8 @@ , induct, inductWith , sInduct, sInductWith , sorry- , TP, runTP, runTPWith, tpQuiet, tpRibbon, tpStats, tpAsms, tpCache+ , TP, runTP, runTPWith, tpQuiet, tpRibbon, tpStats, tpAsms+ , measureLemma, measureLemmaWith , (|-), (|->), (⊢), (=:), (≡), (??), (∵), split, split2, cases, (==>), (⟹), qed, trivial, contradiction , qc, qcWith , disp@@ -43,6 +44,7 @@ import Data.SBV.Core.Data (SBV(..), SVal(..)) import qualified Data.SBV.Core.Symbolic as S (sObserve) +import Data.SBV.Core.Symbolic (rSkipMeasureChecks, rNoTermCheckFunctions) import Data.SBV.Core.Operations (svEqual) import Data.SBV.Control hiding (getProof, (|->)) @@ -53,7 +55,10 @@ import Control.Monad (when) import Control.Monad.Trans (liftIO)+import Data.IORef (readIORef, writeIORef, modifyIORef') +import qualified Data.Set as Set+ import Data.Char (isSpace) import Data.List (intercalate, isPrefixOf, isSuffixOf) import Data.Maybe (catMaybes, maybeToList)@@ -160,25 +165,37 @@ calcWith cfg nm p steps = getTPConfig >>= \cfg' -> calcGeneric False (tpMergeCfg cfg cfg') nm p steps calcGeneric :: (SymVal t, EqSymbolic (SBV t), Proposition a) => Bool -> SMTConfig -> String -> a -> StepArgs a t -> TP (Proof a)- calcGeneric tagTheorem cfg nm result steps = withProofCache nm $ do- tpSt <- getTPState- u <- tpGetNextUnique+ calcGeneric tagTheorem cfg nm result steps = do+ cached <- lookupProofCache result+ case cached of+ Just prf -> returnCachedProof cfg nm prf+ Nothing -> do+ tpSt <- getTPState+ u <- tpGetNextUnique - (_, CalcStrategy {calcQCInstance}) <- liftIO $ runSMTWith cfg (calcSteps result steps)+ (_, CalcStrategy {calcQCInstance}) <- liftIO $ runSMTWith cfg (calcSteps result steps) - liftIO $ runSMTWith cfg $ do+ proof <- liftIO $ runSMTWith cfg $ do - qSaturateSavingObservables result -- make sure we saturate the result, i.e., get all it's UI's, types etc. pop out+ qSaturateSavingObservables result -- make sure we saturate the result, i.e., get all it's UI's, types etc. pop out - message cfg $ (if tagTheorem then "Theorem" else "Lemma") ++ ": " ++ nm ++ "\n"+ message cfg $ (if tagTheorem then "Theorem" else "Lemma") ++ ": " ++ nm ++ "\n" - (calcGoal, strategy@CalcStrategy {calcIntros, calcProofTree}) <- calcSteps result steps+ (calcGoal, strategy@CalcStrategy {calcIntros, calcProofTree}) <- calcSteps result steps - -- Collect all subterms and saturate them- mapM_ qSaturateSavingObservables $ getCalcStrategySaturatables strategy+ -- Collect all subterms and saturate them+ mapM_ qSaturateSavingObservables $ getCalcStrategySaturatables strategy - query $ proveProofTree cfg tpSt nm (result, calcGoal) calcIntros calcProofTree u calcQCInstance+ -- Run measure checks for any newly encountered recursive functions+ st <- symbolicEnv+ liftIO $ do writeIORef (rSkipMeasureChecks st) True+ checkNewMeasures cfg st tpSt + query $ proveProofTree cfg tpSt nm (result, calcGoal) calcIntros calcProofTree u calcQCInstance++ addToProofCache result (proofOf proof)+ pure proof+ -- | In the proof tree, what's the next node label? nextProofStep :: [Int] -> [Int] nextProofStep bs = case reverse bs of@@ -220,21 +237,26 @@ queryDebug [nm ++ ": Proof end: proving the result:"] mbStartTime <- getTimeStampIf printStats+ st <- symbolicEnv+ noTermFns <- liftIO $ readIORef (rNoTermCheckFunctions st)+ let ntcDeps = map noTermCheckProof (Set.toList noTermFns) smtProofStep cfg tpSt "Result" 1 (TPProofStep False nm [] [""]) (Just (initialHypotheses .=> sAnd results)) resultBool [] $ \d -> do mbElapsed <- getElapsedTime mbStartTime- let modulo = concludeModulo (concatMap getHelperProofs (getAllHelpers calcProofTree))+ let allDeps = getDependencies calcProofTree ++ ntcDeps+ modulo = concludeModulo (concatMap getHelperProofs (getAllHelpers calcProofTree) ++ ntcDeps) finishTP cfg ("Q.E.D." ++ modulo) d (catMaybes [mbElapsed]) - pure $ Proof $ ProofObj { dependencies = getDependencies calcProofTree+ pure $ Proof $ ProofObj { dependencies = allDeps , isUserAxiom = False , getObjProof = label nm (quantifiedBool result) , getProp = toDyn result , proofName = nm , uniqId = uniq- , isCached = False+ , aliases = []+ , wasCached = False } where SMTConfig{tpOptions = TPOptions{printStats, printAsms}} = cfg@@ -544,29 +566,6 @@ {-# MINIMAL inductionStrategy #-} inductionStrategy :: (Proposition a, SymVal t, EqSymbolic (SBV t)) => a -> (Proof (IHType a) -> IHArg a -> IStepArgs a t) -> Symbolic InductionStrategy --- | A class of values, capturing the zero of a measure value-class OrdSymbolic (SBV a) => Zero a where- zero :: SBV a---- | An integer as a measure-instance Zero Integer where- zero = literal 0---- | A tuple of integers as a measure-instance Zero (Integer, Integer) where- zero = literal (0, 0)---- | A triple of integers as a measure-instance Zero (Integer, Integer, Integer) where- zero = literal (0, 0, 0)---- | A quadruple of integers as a measure-instance Zero (Integer, Integer, Integer, Integer) where- zero = literal (0, 0, 0, 0)--instance Zero (Integer, Integer, Integer, Integer, Integer) where- zero = literal (0, 0, 0, 0, 0)- -- | A class for doing generalized measure based strong inductive proofs. class SInductive a where -- | Inductively prove a lemma, using measure based induction, using the default config.@@ -588,53 +587,65 @@ -- | Do an inductive proof, based on the given strategy inductionEngine :: Proposition a => InductionStyle -> Bool -> SMTConfig -> String -> a -> Symbolic InductionStrategy -> TP (Proof a)-inductionEngine style tagTheorem cfg nm result getStrategy = withProofCache nm $ do- tpSt <- getTPState- u <- tpGetNextUnique+inductionEngine style tagTheorem cfg nm result getStrategy = do+ cached <- lookupProofCache result+ case cached of+ Just prf -> returnCachedProof cfg nm prf+ Nothing -> do+ tpSt <- getTPState+ u <- tpGetNextUnique - liftIO $ runSMTWith cfg $ do+ proof <- liftIO $ runSMTWith cfg $ do - qSaturateSavingObservables result -- make sure we saturate the result, i.e., get all it's UI's, types etc. pop out+ qSaturateSavingObservables result -- make sure we saturate the result, i.e., get all it's UI's, types etc. pop out - let qual = case style of- RegularInduction -> ""- GeneralInduction -> " (strong)"+ let qual = case style of+ RegularInduction -> ""+ GeneralInduction -> " (strong)" - message cfg $ "Inductive " ++ (if tagTheorem then "theorem" else "lemma") ++ qual ++ ": " ++ nm ++ "\n"+ message cfg $ "Inductive " ++ (if tagTheorem then "theorem" else "lemma") ++ qual ++ ": " ++ nm ++ "\n" - strategy@InductionStrategy { inductionIntros- , inductionMeasure- , inductionBaseCase- , inductionProofTree- , inductiveStep- , inductiveQCInstance- } <- getStrategy+ strategy@InductionStrategy { inductionIntros+ , inductionMeasure+ , inductionBaseCase+ , inductionProofTree+ , inductiveStep+ , inductiveQCInstance+ } <- getStrategy - mapM_ qSaturateSavingObservables $ getInductionStrategySaturatables strategy+ mapM_ qSaturateSavingObservables $ getInductionStrategySaturatables strategy - query $ do+ -- Run measure checks for any newly encountered recursive functions+ st <- symbolicEnv+ liftIO $ do writeIORef (rSkipMeasureChecks st) True+ checkNewMeasures cfg st tpSt - case inductionMeasure of- Nothing -> queryDebug [nm ++ ": Induction" ++ qual ++ ", there is no custom measure to show non-negativeness."]- Just (m, hs) -> do queryDebug [nm ++ ": Induction, proving measure is always non-negative:"]- smtProofStep cfg tpSt "Step" 1- (TPProofStep False nm [] ["Measure is non-negative"])- (Just (sAnd (inductionIntros : map getObjProof hs)))- m- []- (\d -> finishTP cfg "Q.E.D." d [])- case inductionBaseCase of- Nothing -> queryDebug [nm ++ ": Induction" ++ qual ++ ", there is no base case to prove."]- Just bc -> do queryDebug [nm ++ ": Induction, proving base case:"]- smtProofStep cfg tpSt "Step" 1- (TPProofStep False nm [] ["Base"])- (Just inductionIntros)- bc- []- (\d -> finishTP cfg "Q.E.D." d [])+ query $ do - proveProofTree cfg tpSt nm (result, inductiveStep) inductionIntros inductionProofTree u inductiveQCInstance+ case inductionMeasure of+ Nothing -> queryDebug [nm ++ ": Induction" ++ qual ++ ", there is no custom measure to show non-negativeness."]+ Just (m, hs) -> do queryDebug [nm ++ ": Induction, proving measure is always non-negative:"]+ smtProofStep cfg tpSt "Step" 1+ (TPProofStep False nm [] ["Measure is non-negative"])+ (Just (sAnd (inductionIntros : map getObjProof hs)))+ m+ []+ (\d -> finishTP cfg "Q.E.D." d [])+ case inductionBaseCase of+ Nothing -> queryDebug [nm ++ ": Induction" ++ qual ++ ", there is no base case to prove."]+ Just bc -> do queryDebug [nm ++ ": Induction, proving base case:"]+ smtProofStep cfg tpSt "Step" 1+ (TPProofStep False nm [] ["Base"])+ (Just inductionIntros)+ bc+ []+ (\d -> finishTP cfg "Q.E.D." d []) + proveProofTree cfg tpSt nm (result, inductiveStep) inductionIntros inductionProofTree u inductiveQCInstance++ addToProofCache result (proofOf proof)+ pure proof+ -- Induction strategy helper mkIndStrategy :: (SymVal a, EqSymbolic (SBV a)) => Maybe (SBool, [ProofObj]) -> Maybe SBool -> (SBool, TPProofRaw (SBV a)) -> SBool -> ([Int] -> Symbolic SBool) -> Symbolic InductionStrategy mkIndStrategy mbMeasure mbBaseCase indSteps step indQCInstance = do@@ -1039,7 +1050,7 @@ let ih = internalAxiom "IH" (\(Forall a' :: Forall na a) -> measure a' .< measure a .=> result (Forall a')) conc = result (Forall a) - mkIndStrategy (Just (measure a .>= zero, helpers))+ mkIndStrategy (Just (nonNeg (measure a), helpers)) Nothing (steps ih a) (indResult [na] conc)@@ -1054,7 +1065,7 @@ let ih = internalAxiom "IH" (\(Forall a' :: Forall na a) (Forall b' :: Forall nb b) -> measure a' b' .< measure a b .=> result (Forall a') (Forall b')) conc = result (Forall a) (Forall b) - mkIndStrategy (Just (measure a b .>= zero, helpers))+ mkIndStrategy (Just (nonNeg (measure a b), helpers)) Nothing (steps ih a b) (indResult [na, nb] conc)@@ -1070,7 +1081,7 @@ let ih = internalAxiom "IH" (\(Forall a' :: Forall na a) (Forall b' :: Forall nb b) (Forall c' :: Forall nc c) -> measure a' b' c' .< measure a b c .=> result (Forall a') (Forall b') (Forall c')) conc = result (Forall a) (Forall b) (Forall c) - mkIndStrategy (Just (measure a b c .>= zero, helpers))+ mkIndStrategy (Just (nonNeg (measure a b c), helpers)) Nothing (steps ih a b c) (indResult [na, nb, nc] conc)@@ -1087,7 +1098,7 @@ let ih = internalAxiom "IH" (\(Forall a' :: Forall na a) (Forall b' :: Forall nb b) (Forall c' :: Forall nc c) (Forall d' :: Forall nd d) -> measure a' b' c' d' .< measure a b c d .=> result (Forall a') (Forall b') (Forall c') (Forall d')) conc = result (Forall a) (Forall b) (Forall c) (Forall d) - mkIndStrategy (Just (measure a b c d .>= zero, helpers))+ mkIndStrategy (Just (nonNeg (measure a b c d), helpers)) Nothing (steps ih a b c d) (indResult [na, nb, nc, nd] conc)@@ -1105,7 +1116,7 @@ let ih = internalAxiom "IH" (\(Forall a' :: Forall na a) (Forall b' :: Forall nb b) (Forall c' :: Forall nc c) (Forall d' :: Forall nd d) (Forall e' :: Forall ne e) -> measure a' b' c' d' e' .< measure a b c d e .=> result (Forall a') (Forall b') (Forall c') (Forall d') (Forall e')) conc = result (Forall a) (Forall b) (Forall c) (Forall d) (Forall e) - mkIndStrategy (Just (measure a b c d e .>= zero, helpers))+ mkIndStrategy (Just (nonNeg (measure a b c d e), helpers)) Nothing (steps ih a b c d e) (indResult [na, nb, nc, nd, ne] conc)@@ -1518,24 +1529,37 @@ (⟹) = (==>) infix 0 ⟹ --- | Recalling a proof. This essentially sets the verbose output off during this proof. Note that--- if we're doing stats, we ignore this as the whole point of doing stats is to see steps in detail.-recall :: String -> TP (Proof a) -> TP (Proof a)-recall nm prf = getTPConfig >>= \cfg -> recallWith cfg nm prf+-- | Recalling a proof. If the proposition was previously proved and cached, the cached result+-- is returned without re-proving. The output is kept brief: a single "Q.E.D." line.+-- If stats mode is on, we show the full proof steps as the point of stats is to see detail.+recall :: TP (Proof a) -> TP (Proof a)+recall prf = getTPConfig >>= \cfg -> recallWith cfg prf --- | Recalling a proof, using a given config. We keep the stat field as the or of the current and the context--- configuration.-recallWith :: SMTConfig -> String -> TP (Proof a) -> TP (Proof a)-recallWith cfgIn nm prf = do+-- | Recalling a proof, using a given config. Sets the recall context flag so that+-- proof engines check the cache before proving.+recallWith :: SMTConfig -> TP (Proof a) -> TP (Proof a)+recallWith cfgIn prf = do topCfg <- getTPConfig+ tpSt <- getTPState let cfg@SMTConfig{tpOptions = TPOptions{printStats}} = cfgIn `tpMergeCfg` topCfg+ -- Set recall context so proof engines check the cache+ liftIO $ modifyIORef' (inRecallContext tpSt) (+1)+ let cleanup = liftIO $ modifyIORef' (inRecallContext tpSt) (subtract 1) if printStats- then do restoring cfg topCfg prf- else do tab <- liftIO $ startTP cfg (verbose cfg) "Lemma" 0 (TPProofOneShot nm [])- let new = cfg{tpOptions = (tpOptions cfg) {quiet = True}}+ then restoring cfg topCfg $ do r <- prf+ cleanup+ pure r+ else do let new = cfg{tpOptions = (tpOptions cfg) {quiet = True}} restoring new topCfg $ do- r@Proof{proofOf = ProofObj{dependencies}} <- prf- liftIO $ finishTP cfg ("Q.E.D." ++ concludeModulo dependencies) (tab, Nothing) []+ r@Proof{proofOf = po@ProofObj{dependencies, aliases = aka, wasCached = cached}} <- prf+ cleanup+ let nm = proofName po+ akaStr | null aka = ""+ | True = " (a.k.a. " ++ intercalate ", " aka ++ ")"+ what | cached = "Cached"+ | True = "Lemma"+ tab <- liftIO $ startTP cfg (verbose cfg) what 0 (TPProofOneShot nm [])+ liftIO $ finishTP cfg ("Q.E.D." ++ concludeModulo dependencies ++ akaStr) (tab, Nothing) [] pure r where restoring new old act = do setTPConfig new res <- act
Data/SBV/TP/Utils.hs view
@@ -23,17 +23,21 @@ {-# OPTIONS_GHC -Wall -Werror #-} module Data.SBV.TP.Utils (- TP, runTP, runTPWith, Proof(..), ProofObj(..), assumptionFromProof, sorry, quickCheckProof+ TP, runTP, runTPWith, Proof(..), ProofObj(..), assumptionFromProof, sorry, quickCheckProof, noTermCheckProof , startTP, finishTP, getTPState, getTPConfig, setTPConfig, tpGetNextUnique, TPState(..), TPStats(..), RootOfTrust(..) , TPProofContext(..), message, updStats, rootOfTrust, concludeModulo , ProofTree(..), TPUnique(..), showProofTree, showProofTreeHTML- , withProofCache- , tpQuiet, tpRibbon, tpAsms, tpStats, tpCache+ , addToProofCache, lookupProofCache, returnCachedProof+ , tpQuiet, tpRibbon, tpAsms, tpStats+ , measureLemma, measureLemmaWith ) where +import Control.Monad (unless) import Control.Monad.Reader (ReaderT, runReaderT, MonadReader, ask, liftIO) import Control.Monad.Trans (MonadIO) +import Data.Generics (everywhere, mkT)+ import Data.Time (NominalDiffTime) import Data.Tree@@ -43,7 +47,7 @@ import Data.Typeable (typeOf, TypeRep) import Data.Char (isSpace)-import Data.List (intercalate, isPrefixOf, isSuffixOf, isInfixOf, nubBy, partition, sort)+import Data.List (intercalate, isPrefixOf, isSuffixOf, isInfixOf, nub, nubBy, sort, dropWhileEnd) import Data.Int (Int64) import Data.SBV.Utils.Lib (unQuote)@@ -51,57 +55,122 @@ import System.IO (hFlush, stdout) import System.Random (randomIO) -import Data.SBV.Core.Data (SBool, Forall(..), quantifiedBool)-import Data.SBV.Core.Model (label)-import Data.SBV.Core.Symbolic (SMTConfig, TPOptions(..))+import Data.SBV.Core.Data (SBool, sTrue, Forall(..), QuantifiedBool, quantifiedBool, SBV(..), SV(..), NodeId(..), SBVExpr(..), SBVPgm(..), Op(..), CV(..))+import Data.SBV.Core.Model (label, MeasureHelper(..))+import Data.SBV.Core.Symbolic (SMTConfig, TPOptions(..), State(..), mkNewState, svToSV, SBVRunMode(..), globalSBVContext) import Data.SBV.Provers.Prover (defaultSMTCfg, SMTConfig(..)) import Data.SBV.Utils.TDiff (showTDiff, timeIf) import Control.DeepSeq (NFData(rnf)) +import Data.Foldable (toList) import Data.IORef import GHC.Generics import Data.Dynamic -import qualified Data.Map as Map+import qualified Data.Map.Strict as Map import Data.Map (Map) +import qualified Data.Set as Set+import Data.Set (Set)+ -- | Various statistics we collect-data TPStats = TPStats { noOfCheckSats :: Int- , solverElapsed :: NominalDiffTime- , qcElapsed :: NominalDiffTime+data TPStats = TPStats { noOfCheckSats :: !Int+ , solverElapsed :: !NominalDiffTime+ , qcElapsed :: !NominalDiffTime } -- | Extra state we carry in a TP context-data TPState = TPState { stats :: IORef TPStats- , proofCache :: IORef (Map (String, TypeRep) ProofObj)- , config :: IORef SMTConfig+data TPState = TPState { stats :: IORef TPStats+ , proofCache :: IORef (Map (PropFingerprint, TypeRep) [ProofObj])+ , config :: IORef SMTConfig+ , inRecallContext :: IORef Int+ , measuresVerified :: IORef (Set String)+ , productiveVerified :: IORef (Set String)+ , measuresEncountered :: IORef (Set String) } -- | Monad for running TP proofs in. newtype TP a = TP (ReaderT TPState IO a) deriving newtype (Applicative, Functor, Monad, MonadIO, MonadReader TPState, MonadFail) --- | If caches are enabled, see if we cached this proof and return it; otherwise generate it, cache it, and return it-withProofCache :: forall a. Typeable a => String -> TP (Proof a) -> TP (Proof a)-withProofCache nm genProof = do- TPState{proofCache, config} <- getTPState- cfg@SMTConfig {tpOptions = TPOptions {cacheProofs}} <- liftIO $ readIORef config+-- | Extract the integer node ID from an SV.+svIntId :: SV -> Int+svIntId (SV _ (NodeId (_, _, i))) = i - let key = (nm, typeOf (Proxy @a))+-- | Zero out the SBVContext in an SV, keeping only the kind and integer node ID.+-- Used to normalize 'Op' values for fingerprinting.+zeroSV :: SV -> SV+zeroSV (SV k (NodeId (_, mb, i))) = SV k (NodeId (globalSBVContext, mb, i)) - if not cacheProofs- then genProof- else do cache <- liftIO $ readIORef proofCache- case key `Map.lookup` cache of- Just prf -> do liftIO $ do tab <- startTP cfg False "Cached" 0 (TPProofOneShot nm [])- finishTP cfg "Q.E.D." (tab, Nothing) []- pure $ Proof prf{isCached = True}- Nothing -> do p <- genProof- liftIO $ modifyIORef' proofCache (Map.insert key (proofOf p))- pure p+-- | Zero out all embedded SBVContext values inside an 'Op' using SYB generic traversal.+-- This automatically handles all current and future Op constructors that embed SV's.+zeroContextInOp :: Op -> Op+zeroContextInOp = everywhere (mkT zeroSV) +-- | Fingerprint of a proposition's symbolic expression DAG.+-- Computed by evaluating 'quantifiedBool' in a fresh State and extracting+-- the expression program (with embedded SV contexts zeroed out via SYB),+-- the constant map (mapping constant values to their SV int IDs), and the final result SV.+-- Two identical propositions evaluated in identically-initialized States produce+-- identical fingerprints. Different propositions diverge somewhere in variable creation,+-- expression construction, or hash-consing, producing different fingerprints.+newtype PropFingerprint = PropFingerprint ([(CV, Int)], [(Int, Op, [Int])], Int)+ deriving (Eq, Ord)++-- | Compute the fingerprint of a proposition by evaluating it in a fresh+-- lightweight State (no solver connection needed). The State is created via+-- 'mkNewState' with 'LambdaGen' mode, which initializes all counters identically+-- without starting a solver process.+propFingerprint :: QuantifiedBool a => a -> IO PropFingerprint+propFingerprint prop = do+ st <- mkNewState defaultSMTCfg (LambdaGen Nothing)+ sv <- svToSV st (unSBV (quantifiedBool prop))+ pgm <- readIORef (spgm st)+ cm <- readIORef (rconstMap st)+ let entries = [ (svIntId target, zeroContextInOp op, map svIntId args)+ | (target, SBVApp op args) <- toList (pgmAssignments pgm)+ ]+ consts = [(c, svIntId s) | (c, s) <- Map.toAscList cm]+ pure $ PropFingerprint (consts, entries, svIntId sv)++-- | After proving a proposition, add the proof to the cache for future recall lookups.+addToProofCache :: forall a. (Typeable a, QuantifiedBool a) => a -> ProofObj -> TP ()+addToProofCache prop prf = do+ TPState{proofCache} <- getTPState+ fp <- liftIO $ propFingerprint prop+ let key = (fp, typeOf (Proxy @a))+ liftIO $ modifyIORef' proofCache $ Map.insertWith (\_ old -> prf : old) key [prf]++-- | Look up a cached proof for the given proposition. Only succeeds when in recall context+-- (i.e., called from within a recall wrapper). On cache hit, the returned ProofObj has+-- its 'aliases' field populated with the names of other proofs of the same proposition.+lookupProofCache :: forall a. (Typeable a, QuantifiedBool a) => a -> TP (Maybe ProofObj)+lookupProofCache prop = do+ TPState{proofCache, inRecallContext} <- getTPState+ inRecall <- liftIO $ readIORef inRecallContext+ if inRecall == 0+ then pure Nothing+ else do fp <- liftIO $ propFingerprint prop+ let key = (fp, typeOf (Proxy @a))+ cache <- liftIO $ readIORef proofCache+ pure $ case reverse <$> Map.lookup key cache of+ Nothing -> Nothing+ Just [] -> Nothing+ Just (p:ps) -> Just p { aliases = [proofName q | q <- ps] }++-- | Return a cached proof, printing a brief "Q.E.D." line with optional "a.k.a." annotation.+returnCachedProof :: SMTConfig -> String -> ProofObj -> TP (Proof a)+returnCachedProof cfg nm prf = do+ let aka = filter (/= nm) $ nub $ proofName prf : aliases prf+ prf' = prf { proofName = nm, wasCached = True, aliases = aka }+ akaStr | null aka = ""+ | True = " (a.k.a. " ++ intercalate ", " aka ++ ")"+ tab <- liftIO $ startTP cfg False "Cached" 0 (TPProofOneShot nm [])+ liftIO $ finishTP cfg ("Q.E.D." ++ concludeModulo (dependencies prf) ++ akaStr) (tab, Nothing) []+ pure $ Proof prf'+ -- | The context in which we make a check-sat call data TPProofContext = TPProofOneShot String -- ^ A one shot proof, with string containing its name [ProofObj] -- ^ Helpers used (latter only used for cex generation)@@ -117,10 +186,40 @@ -- | Run a TP proof, using the given configuration. runTPWith :: SMTConfig -> TP a -> IO a runTPWith cfg@SMTConfig{tpOptions = TPOptions{printStats}} (TP f) = do- rStats <- newIORef $ TPStats { noOfCheckSats = 0, solverElapsed = 0, qcElapsed = 0 }- rCache <- newIORef Map.empty- rCfg <- newIORef cfg- (mbT, r) <- timeIf printStats $ runReaderT f TPState {config = rCfg, stats = rStats, proofCache = rCache}+ rStats <- newIORef $ TPStats { noOfCheckSats = 0, solverElapsed = 0, qcElapsed = 0 }+ rCache <- newIORef Map.empty+ rCfg <- newIORef cfg+ rRecall <- newIORef (0 :: Int)+ rMeasures <- newIORef Set.empty+ rProductive <- newIORef Set.empty+ rEncountered <- newIORef Set.empty+ (mbT, r) <- timeIf printStats $ runReaderT f TPState { config = rCfg+ , stats = rStats+ , proofCache = rCache+ , inRecallContext = rRecall+ , measuresVerified = rMeasures+ , productiveVerified = rProductive+ , measuresEncountered = rEncountered+ }++ -- Print verified measures and productive functions+ verified <- readIORef rMeasures+ productive <- readIORef rProductive+ encountered <- readIORef rEncountered++ unless (Set.null verified) $ printMeasures cfg (Set.toAscList verified)+ unless (Set.null productive) $ printProductive cfg (Set.toAscList productive)++ -- Belt-and-suspenders: make sure all encountered measures have been verified.+ -- Exclude functions in measuresBeingVerified: those are being verified by an outer caller+ -- (e.g., when a measureLemma proof uses the function whose measure is being checked).+ let beingVerified = measuresBeingVerified (tpOptions cfg)+ missed = encountered `Set.difference` verified `Set.difference` productive `Set.difference` beingVerified++ unless (Set.null missed) $+ error $ "SBV.runTP: Internal error: The following functions have termination measures that were encountered but not verified: "+ ++ intercalate ", " (Set.toAscList missed)+ case mbT of Nothing -> pure () Just t -> do TPStats noOfCheckSats solverTime qcElapsed <- readIORef rStats@@ -159,10 +258,47 @@ -- | Display the message if not quiet. Note that we don't print a newline; so the message must have it if needed. message :: MonadIO m => SMTConfig -> String -> m ()-message SMTConfig{tpOptions = TPOptions{quiet}} s- | quiet = pure ()- | True = liftIO $ putStr s+message SMTConfig{tpOptions = TPOptions{quiet}, redirectVerbose} s+ | quiet+ = pure ()+ | Just f <- redirectVerbose+ = liftIO $ appendFile f s+ | True+ = liftIO $ putStr s +-- | Print the list of functions whose termination measures have been verified.+printMeasures :: SMTConfig -> [String] -> IO ()+printMeasures = printFunctions "Functions proven terminating"++-- | Print the list of functions whose productivity (guardedness) has been verified.+printProductive :: SMTConfig -> [String] -> IO ()+printProductive = printFunctions "Functions proven productive"++-- | Print a list of function names under a header, wrapping lines to avoid excessively long output.+-- If the list fits on one line, it follows the header directly. Otherwise, it starts on a new line.+printFunctions :: String -> SMTConfig -> [String] -> IO ()+printFunctions header cfg names+ | length oneLine <= limit = message cfg $ header ++ ": " ++ oneLine ++ "\n"+ | True = message cfg $ header ++ ":\n " ++ wrapped ++ "\n"+ where cleaned = nub (sort (map strip names))+ strip = dropWhileEnd (== ' ') . takeWhile (/= '@')++ limit = 90++ oneLine = intercalate ", " cleaned++ wrapped = go limit cleaned++ go _ [] = ""+ go _ [n] = n+ go r (n:ns) = let len = length n + 2 -- account for ", "+ rest = go (r - len) ns+ in if r - len < 0 && r /= limit+ then "\n " ++ go limit (n:ns)+ else case rest of+ '\n':_ -> n ++ "," ++ rest+ _ -> n ++ ", " ++ rest+ -- | Start a proof. We return the number of characters we printed, so the finisher can align the result. startTP :: SMTConfig -> Bool -> String -> Int -> TPProofContext -> IO Int startTP cfg newLine what level ctx = do message cfg $ line ++ if newLine then "\n" else ""@@ -189,10 +325,11 @@ mkTiming t = '[' : showTDiff t ++ "]" -- | Unique identifier for each proof.-data TPUnique = TPInternal -- IH's- | TPSorry -- sorry- | TPQC -- qc (quick-check)- | TPUser Int64 -- user given+data TPUnique = TPInternal -- IH's+ | TPSorry -- sorry+ | TPQC -- qc (quick-check)+ | TPNoTermCheck -- no termination check (smtFunctionNoTermination)+ | TPUser Int64 -- user given deriving (NFData, Generic, Eq) -- | Proof for a property. This type is left abstract, i.e., the only way to create on is via a@@ -214,7 +351,8 @@ , getProp :: Dynamic -- ^ The actual proposition , proofName :: String -- ^ User given name , uniqId :: TPUnique -- ^ Unique identifier- , isCached :: Bool -- ^ Was this a cached proof?+ , aliases :: [String] -- ^ Other names for proofs of the same proposition (populated on cache hit)+ , wasCached :: Bool -- ^ Was this proof retrieved from the cache? } -- | Drop the instantiation part@@ -252,12 +390,13 @@ -- | NFData ignores the getProp field instance NFData ProofObj where- rnf (ProofObj dependencies isUserAxiom getObjProof _getProp proofName uniqId isCached) = rnf dependencies- `seq` rnf isUserAxiom- `seq` rnf getObjProof- `seq` rnf proofName- `seq` rnf uniqId- `seq` rnf isCached+ rnf (ProofObj dependencies isUserAxiom getObjProof _getProp proofName uniqId aliases wasCached) = rnf dependencies+ `seq` rnf isUserAxiom+ `seq` rnf getObjProof+ `seq` rnf proofName+ `seq` rnf uniqId+ `seq` rnf aliases+ `seq` rnf wasCached -- | Dependencies of a proof, in a tree format. data ProofTree = ProofTree ProofObj [ProofTree]@@ -284,10 +423,11 @@ -- Don't show internal axioms, not interesting interesting (ProofTree p _) = case uniqId p of- TPInternal -> False- TPSorry -> True- TPQC -> True- TPUser{} -> True+ TPInternal -> False+ TPSorry -> True+ TPQC -> True+ TPNoTermCheck -> True+ TPUser{} -> True -- If a proof is used twice in the same proof, compress it compress :: [ProofTree] -> [(Int, ProofTree)]@@ -326,20 +466,13 @@ -- | Show instance for t'Proof' instance Typeable a => Show (Proof a) where- show p@(Proof po@ProofObj{proofName = nm}) = '[' : sh (rootOfTrust p) ++ "] " ++ nm ++ " :: " ++ pretty (show (typeOf p))- where sh (RootOfTrust Nothing) = "Proven" ++ cacheInfo- sh (RootOfTrust (Just ps)) = "Modulo: " ++ shortProofNames ps ++ cacheInfo-- cacheInfo = case cachedProofs po of- [] -> ""- cs -> ". Cached: " ++ shortProofNames (nubBy (\p1 p2 -> uniqId p1 == uniqId p2) cs)-- cachedProofs prf@ProofObj{isCached} = if isCached then prf : rest else rest- where rest = concatMap cachedProofs (dependencies prf)+ show p@(Proof ProofObj{proofName = nm}) = '[' : sh (rootOfTrust p) ++ "] " ++ nm ++ " :: " ++ pretty (show (typeOf p))+ where sh (RootOfTrust Nothing) = "Proven"+ sh (RootOfTrust (Just ps)) = "Modulo: " ++ shortProofNames ps -- More mathematical notation for types. pretty :: String -> String- pretty = compress . unwords . walk . words . concatMap (\c -> if c == ',' then " , " else [c]) . clean+ pretty = charToString . compress . unwords . walk . words . concatMap (\c -> if c == ',' then " , " else [c]) . clean where fa v = ['Ɐ' : unQuote v, "∷"] ex v = ['∃' : unQuote v, "∷"] @@ -348,6 +481,11 @@ compress (c : rest) = c : compress rest compress [] = [] + -- Replace [Char] with String everywhere+ charToString ('[':'C':'h':'a':'r':']':rest) = "String" ++ charToString rest+ charToString (c:rest) = c : charToString rest+ charToString [] = []+ walk ("SBV" : "Bool" : rest) = walk $ "Bool" : rest walk ("Forall" : xs : rest) = walk $ fa xs ++ rest walk ("Exists" : xs : rest) = walk $ ex xs ++ rest@@ -386,7 +524,8 @@ , getProp = toDyn p , proofName = "sorry" , uniqId = TPSorry- , isCached = False+ , aliases = []+ , wasCached = False } where -- ideally, I'd rather just use -- p = sFalse@@ -404,7 +543,8 @@ , getProp = toDyn p , proofName = "quickCheck" , uniqId = TPQC- , isCached = False+ , aliases = []+ , wasCached = False } where -- ideally, I'd rather just use -- p = sFalse@@ -414,16 +554,32 @@ -- solver to determine as false, we avoid the constant folding. p (Forall @"__sbvTP_quickCheck" (x :: SBool)) = label "QUICKCHECK: TP, proof uses \"qc\"" x +-- | A proof object representing a function whose termination was not checked.+-- When a function is defined with 'Data.SBV.smtFunctionNoTermination', its termination+-- is assumed but not proven. Any proof that depends on such a function will be+-- marked as modulo this assumption in its root of trust.+noTermCheckProof :: String -> ProofObj+noTermCheckProof nm = ProofObj { dependencies = []+ , isUserAxiom = False+ , getObjProof = sTrue+ , getProp = toDyn True+ , proofName = nm ++ " termination"+ , uniqId = TPNoTermCheck+ , aliases = []+ , wasCached = False+ }+ -- | Calculate the root of trust. The returned list of proofs, if any, will need to be sorry and quickcheck free to -- have the given proof to be sorry-free. rootOfTrust :: Proof a -> RootOfTrust rootOfTrust = rot True . proofOf where rot atTop p@ProofObj{uniqId = curUniq, dependencies} = compress res where res = case curUniq of- TPInternal -> RootOfTrust Nothing- TPQC -> RootOfTrust $ Just [quickCheckProof]- TPSorry -> RootOfTrust $ Just [sorry]- TPUser {} -> self <> foldMap (rot False) dependencies+ TPInternal -> RootOfTrust Nothing+ TPQC -> RootOfTrust $ Just [quickCheckProof]+ TPSorry -> RootOfTrust $ Just [sorry]+ TPNoTermCheck -> RootOfTrust $ Just [p]+ TPUser {} -> self <> foldMap (rot False) dependencies -- if sorry or quickcheck is one of our direct dependencies, then we trust this proof. -- Note that we skip this at the top. Why? at that level, we want to see the direct@@ -434,14 +590,11 @@ isUnsafe ProofObj{uniqId = u} = u `elem` [TPSorry, TPQC] - -- If we have any dependency that is not sorry itself, then we can skip all the sorries.- -- Why? Because "sorry" will implicitly be coming from one of these anyhow. (In other- -- words, we do not need to (or want to) distinguish between different uses of sorry.+ -- If sorry is present, it dominates everything else. Otherwise keep all. compress (RootOfTrust mbps) = RootOfTrust $ reduce <$> mbps- where reduce ps = case partition isUnsafe ps of- (l, []) | TPSorry `elem` map uniqId l -> [sorry]- | True -> [quickCheckProof]- (_, os) -> os+ where reduce ps+ | any (\o -> uniqId o == TPSorry) ps = [sorry]+ | True = ps -- | Calculate the modulo string for dependencies concludeModulo :: [ProofObj] -> String@@ -467,18 +620,39 @@ tpStats :: SMTConfig -> SMTConfig tpStats cfg = cfg{tpOptions = (tpOptions cfg) { printStats = True }} --- | Make TP proofs use proof-cache. Note that if you use this option then you are obligated to ensure all--- lemma\/theorem names\/type pairs you use are unique for the whole run. (That is, we will reuse proofs if they have the--- same name and type; hence if you prove two theorems that share name and type will be considered the same.)--- If you don't ensure this uniqueness, the results are not guaranteed to be sound. A good tip is to run the proof at--- least once to completion, and use cache for regression purposes to avoid re-runs. Also, this setting will be effective--- with the call to 'runTP'\/'runTPWith', i.e., if you -- the solver in a call to 'Data.SBV.TP.lemmaWith'\/'Data.SBV.TP.theoremWith', we will--- inherit the caching behavior settings from the surrounding environment.-tpCache :: SMTConfig -> SMTConfig-tpCache cfg = cfg{tpOptions = (tpOptions cfg) { cacheProofs = True }} -- | When proving assumptions for each step, print them as well. Normally, SBV doesn't -- print assumptions in each proof step, though it does prove them as they are typically trivial. -- But in certain cases seeing them would be helpful. tpAsms :: SMTConfig -> SMTConfig tpAsms cfg = cfg{tpOptions = (tpOptions cfg) { printAsms = True }}++-- | Create a t'MeasureHelper' from a TP proof action. During measure verification,+-- the proof is run to confirm the property holds, and the proven property is extracted+-- and asserted as an axiom in the measure verification session. The solver configuration+-- is inherited from the measure verification context, with output suppressed.+--+-- Example usage with 'Data.SBV.smtFunctionWithMeasure':+--+-- @+-- normalize = smtFunctionWithMeasure "normalize"+-- (\\f -> tuple (ifComplexity f, ifDepth f)+-- , [measureLemma ifDepthNonNeg, measureLemma ifComplexityPos]+-- )+-- $ \\f -> ...+-- @+measureLemma :: forall a. (QuantifiedBool a, Typeable a) => TP (Proof a) -> MeasureHelper+measureLemma tp = MeasureHelper $ \cfg -> do+ proof <- runTPWith (tpQuiet True cfg) tp+ case fromDynamic @a (getProp (proofOf proof)) of+ Just prop -> pure (quantifiedBool prop)+ Nothing -> error "Data.SBV.measureLemma: impossible type mismatch in measure helper"++-- | Like 'measureLemma', but using the given solver configuration, ignoring the+-- one from the measure verification context.+measureLemmaWith :: forall a. (QuantifiedBool a, Typeable a) => SMTConfig -> TP (Proof a) -> MeasureHelper+measureLemmaWith userCfg tp = MeasureHelper $ \_cfg -> do+ proof <- runTPWith (tpQuiet True userCfg) tp+ case fromDynamic @a (getProp (proofOf proof)) of+ Just prop -> pure (quantifiedBool prop)+ Nothing -> error "Data.SBV.measureLemmaWith: impossible type mismatch in measure helper"
Data/SBV/Tools/Polynomial.hs view
@@ -9,6 +9,7 @@ -- Implementation of polynomial arithmetic ----------------------------------------------------------------------------- +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} @@ -20,7 +21,11 @@ ) where import Data.Bits (Bits(..))-import Data.List (genericTake)+import Data.List (genericTake+#if !MIN_VERSION_base(4,20,0)+ , foldl'+#endif+ ) import Data.Maybe (fromJust, fromMaybe) import Data.Word (Word8, Word16, Word32, Word64) @@ -145,7 +150,7 @@ = fromBitsLE $ genericTake sz $ r ++ repeat sFalse where (_, r) = mdp ms rs ms = genericTake (2*sz) $ mul (blastLE x) (blastLE y) [] ++ repeat sFalse- rs = genericTake (2*sz) $ [fromBool (i `elem` red) | i <- [0 .. foldr max 0 red] ] ++ repeat sFalse+ rs = genericTake (2*sz) $ [fromBool (i `elem` red) | i <- [0 .. foldl' max 0 red] ] ++ repeat sFalse sz = intSizeOf x mul _ [] ps = ps mul as (b:bs) ps = mul (sFalse:as) bs (ites b (as `addPoly` ps) ps)
Data/SBV/Tools/WeakestPreconditions.hs view
@@ -25,7 +25,7 @@ Program(..), Stmt(..), assert, stable -- * Invariants, measures, and stability- , Invariant, Measure, Stable+ , Invariant, WPMeasure, Stable -- * Verification conditions , VC(..)@@ -93,18 +93,18 @@ -- | A measure takes the state and returns a sequence of integers. The ordering -- will be done lexicographically over the elements.-type Measure st = st -> [SInteger]+type WPMeasure st = st -> [SInteger] -- | A statement in our imperative program, parameterized over the state.-data Stmt st = Skip -- ^ Skip, do nothing.- | Abort String -- ^ Abort execution. The name is for diagnostic purposes.- | Assign (st -> st) -- ^ Assignment: Transform the state by a function.- | If (st -> SBool) (Stmt st) (Stmt st) -- ^ Conditional: @If condition thenBranch elseBranch@.- | While String (Invariant st) (Maybe (Measure st)) (st -> SBool) (Stmt st) -- ^ A while loop: @While name invariant measure condition body@.- -- The string @name@ is merely for diagnostic purposes.- -- If the measure is 'Nothing', then only partial correctness- -- of this loop will be proven.- | Seq [Stmt st] -- ^ A sequence of statements.+data Stmt st = Skip -- ^ Skip, do nothing.+ | Abort String -- ^ Abort execution. The name is for diagnostic purposes.+ | Assign (st -> st) -- ^ Assignment: Transform the state by a function.+ | If (st -> SBool) (Stmt st) (Stmt st) -- ^ Conditional: @If condition thenBranch elseBranch@.+ | While String (Invariant st) (Maybe (WPMeasure st)) (st -> SBool) (Stmt st) -- ^ A while loop: @While name invariant measure condition body@.+ -- The string @name@ is merely for diagnostic purposes.+ -- If the measure is 'Nothing', then only partial correctness+ -- of this loop will be proven.+ | Seq [Stmt st] -- ^ A sequence of statements. -- | An 'assert' is a quick way of ensuring some condition holds. If it does, -- then it's equivalent to 'Skip'. Otherwise, it is equivalent to 'Abort'.@@ -306,7 +306,7 @@ let noMeasure = isNothing mm m = fromJust mm curM = m st'- zero = map (const 0) curM+ zeroM = map (const 0) curM iterates = inv st' .&& cond st' terminates = inv st' .&& sNot (cond st')@@ -324,7 +324,7 @@ -- Condition 4: If we iterate, measure must always be non-negative measureNonNegative <- if noMeasure then return (const [])- else wp st' Skip (const [(iterates .=> curM .>= zero, MeasureBound nm (st', curM))])+ else wp st' Skip (const [(iterates .=> curM .>= zeroM, MeasureBound nm (st', curM))]) -- Condition 5: If we iterate, the measure must decrease measureDecreases <- if noMeasure@@ -476,14 +476,14 @@ = step loc is $ tag "condition fails, terminating" | not (currentInvariant is) = stop loc (InvariantMaintain loopName prevST is) $ tag "invariant fails to hold in iteration " ++ show c- | hasMeasure && mCur < zero+ | hasMeasure && mCur < zeroM = stop loc (MeasureBound loopName (is, mCur)) $ tag "measure must be non-negative, evaluated to: " ++ show mCur | hasMeasure, Just mPrev <- mbPrev, mCur >= mPrev = stop loc (MeasureDecrease loopName (prevST, mPrev) (is, mCur)) $ tag $ "measure failed to decrease, prev = " ++ show mPrev ++ ", current = " ++ show mCur | True = do nextState <- go (Iteration c : loc) body =<< step loc is (tag "condition holds, executing the body") while (c+1) is (Just mCur) nextState- where mCur = currentMeasure is- zero = map (const 0) mCur+ where mCur = currentMeasure is+ zeroM = map (const 0) mCur {- HLint ignore traceExecution "Use fromMaybe" -}
Data/SBV/Trans.hs view
@@ -49,7 +49,7 @@ , sBools, sWord8s, sWord16s, sWord32s, sWord64s, sWords, sInt8s, sInt16s, sInt32s, sInt64s, sInts, sIntegers, sReals, sFloats, sDoubles, sChars, sStrings, sLists, sArrays -- * Symbolic Equality and Comparisons- , EqSymbolic(..), OrdSymbolic(..), Equality(..)+ , EqSymbolic(..), OrdSymbolic(..), Zero(..), MeasureOf, Equality(..) -- * Conditionals: Mergeable values , Mergeable(..), ite, iteLazy @@ -86,7 +86,7 @@ , blastSFloatingPoint -- * Symbolic types- , mkSymbolic, SMTDefinable(..)+ , mkSymbolic, SMTDefinable(..), smtFunction, smtFunctionWithMeasure -- * Properties, proofs, and satisfiability , Predicate, ConstraintSet, ProvableM(..), Provable, SatisfiableM(..), Satisfiable
Data/SBV/Utils/CrackNum.hs view
@@ -76,7 +76,7 @@ -- Convert bits to the corresponding integer. getVal :: [Bool] -> Integer-getVal = foldl (\s b -> 2 * s + if b then 1 else 0) 0+getVal = foldl' (\s b -> 2 * s + if b then 1 else 0) 0 -- Show in hex, but pay attention to how wide a field it should be in mkHex :: [Bool] -> String
Documentation/SBV/Examples/ADT/Expr.hs view
@@ -69,30 +69,35 @@ isValid = go [] where isId s = s `match` (asciiLower * KStar (asciiLetter + digit)) go :: SList String -> SExpr -> SBool- go = smtFunction "valid" $ \env expr -> [sCase|Expr expr of- Var s -> isId s .&& s `SL.elem` env- Val _ -> sTrue- Add l r -> go env l .&& go env r- Mul l r -> go env l .&& go env r- Let s a b -> isId s .&& go env a .&& go (s SL..: env) b- |]+ go = smtFunction "valid"+ $ \env expr -> [sCase| expr of+ Var s -> isId s .&& s `SL.elem` env+ Val _ -> sTrue+ Add l r -> go env l .&& go env r+ Mul l r -> go env l .&& go env r+ Let s a b -> isId s .&& go env a .&& go (s SL..: env) b+ |] -- | Evaluate an expression. eval :: SExpr -> SInteger eval = go [] where go :: SList (String, Integer) -> SExpr -> SInteger- go = smtFunction "eval" $ \env expr -> [sCase|Expr expr of- Val i -> i- Var s -> get env s- Add l r -> go env l + go env r- Mul l r -> go env l * go env r- Let s e r -> go (tuple (s, go env e) SL..: env) r- |]+ go = smtFunction "eval"+ $ \env expr -> [sCase| expr of+ Val i -> i+ Var s -> get env s+ Add l r -> go env l + go env r+ Mul l r -> go env l * go env r+ Let s e r -> go (tuple (s, go env e) SL..: env) r+ |] get :: SList (String, Integer) -> SString -> SInteger- get = smtFunction "get" $ \env s -> ite (SL.null env) 0- $ let (k, v) = untuple (SL.head env)- in ite (s .== k) v (get (SL.tail env) s)+ get = smtFunction "get"+ $ \env s -> [sCase| env of+ [] -> 0+ (k, v) : es | s .== k -> v+ | True -> get es s+ |] -- | A basic theorem about 'eval'. -- >>> evalPlus5@@ -105,9 +110,9 @@ -- -- >>> evalSat -- Satisfiable. Model:--- e = Let "f" (Val 1) (Var "f") :: Expr--- a = 9 :: Integer--- b = 10 :: Integer+-- e = Let "k" (Val 2) (Mul (Val 1) (Var "k")) :: Expr+-- a = 18 :: Integer+-- b = 10 :: Integer evalSat :: IO SatResult evalSat = sat $ do e :: SExpr <- free "e" constrain $ isValid e@@ -124,8 +129,8 @@ -- -- >>> genE -- Satisfiable. Model:--- e1 = Let "p" (Val 4) (Let "k" (Val 6) (Let "w" (Val 8) (Val 3))) :: Expr--- e2 = Val (-2) :: Expr+-- e1 = Let "p" (Val 5) (Val 3) :: Expr+-- e2 = Val (-2) :: Expr genE :: IO SatResult genE = sat $ do e1 :: SExpr <- free "e1" e2 :: SExpr <- free "e2"@@ -141,7 +146,7 @@ -- | Query mode example. -- -- >>> queryE--- e1: (let p = 4 in (let k = 6 in (let w = 8 in 3)))+-- e1: (let p = 5 in 3) -- e2: -2 queryE :: IO () queryE = runSMT $ do
Documentation/SBV/Examples/ADT/Param.hs view
@@ -76,28 +76,33 @@ -- variable referenced is introduced by an enclosing let expression. isValid :: (SymVal nm, Eq nm, SymVal val) => (SBV nm -> SBool) -> SExpr nm val -> SBool isValid nmChk = go []- where go = smtFunction "valid" $ \env expr -> [sCase|Expr expr of- Var s -> nmChk s .&& s `SL.elem` env- Val _ -> sTrue- Add l r -> go env l .&& go env r- Mul l r -> go env l .&& go env r- Let s a b -> nmChk s .&& go env a .&& go (s SL..: env) b- |]+ where go = smtFunction "valid"+ $ \env expr -> [sCase| expr of+ Var s -> nmChk s .&& s `SL.elem` env+ Val _ -> sTrue+ Add l r -> go env l .&& go env r+ Mul l r -> go env l .&& go env r+ Let s a b -> nmChk s .&& go env a .&& go (s SL..: env) b+ |] -- | Evaluate an expression. eval :: (SymVal nm, SymVal val, Num (SBV val)) => SExpr nm val -> SBV val eval = go []- where go = smtFunction "eval" $ \env expr -> [sCase|Expr expr of- Val i -> i- Var s -> get env s- Add l r -> go env l + go env r- Mul l r -> go env l * go env r- Let s e r -> go (tuple (s, go env e) SL..: env) r- |]+ where go = smtFunction "eval"+ $ \env expr -> [sCase| expr of+ Val i -> i+ Var s -> get env s+ Add l r -> go env l + go env r+ Mul l r -> go env l * go env r+ Let s e r -> go (tuple (s, go env e) SL..: env) r+ |] - get = smtFunction "get" $ \env s -> ite (SL.null env) 0- $ let (k, v) = untuple (SL.head env)- in ite (s .== k) v (get (SL.tail env) s)+ get = smtFunction "get"+ $ \env s -> [sCase| env of+ [] -> 0+ (k, v) : es | s .== k -> v+ | True -> get es s+ |] -- | A basic theorem about 'eval'. -- >>> evalPlus5@@ -114,9 +119,9 @@ -- -- >>> evalSat -- Satisfiable. Model:--- e = Let "p" (Val 1) (Var "p") :: Expr String Integer--- a = 9 :: Integer--- b = 10 :: Integer+-- e = Let "k" (Val (-2)) (Mul (Val (-1)) (Var "k")) :: Expr String Integer+-- a = 18 :: Integer+-- b = 10 :: Integer evalSat :: IO SatResult evalSat = sat $ do e :: SExpr String Integer <- free "e" constrain $ isValid isId e@@ -133,7 +138,7 @@ -- -- >>> genE -- Satisfiable. Model:--- e1 = Let "h" (Val 4) (Val 3) :: Expr String Integer+-- e1 = Let "p" (Val 5) (Val 3) :: Expr String Integer -- e2 = Val (-2) :: Expr String Integer genE :: IO SatResult genE = sat $ do e1 :: SExpr String Integer <- free "e1"@@ -150,9 +155,9 @@ -- | Query mode example. -- -- >>> queryE--- e1: (let c = (1 * -1) in (-3 * c))--- e2: (let p = -2 in (0 + p))--- e3: (let h = 90 % 91 in h)+-- e1: (let p = (-3 * 1) in (-1 * p))+-- e2: -2+-- e3: (let p = 314 % 315 in p) queryE :: IO () queryE = runSMT $ do e1 :: SExpr String Integer <- free "e1"
Documentation/SBV/Examples/ADT/Types.hs view
@@ -54,7 +54,7 @@ -- | Given a term and a type, check that the term has that type. tc :: SM -> ST -> SBool tc = smtFunction "constraints" $ \m t ->- [sCase|M m of+ [sCase| m of -- Var case. The environment must match the type we expect. Var s -> env s .== t
Documentation/SBV/Examples/BitPrecise/PrefixSum.hs view
@@ -68,13 +68,13 @@ -- | The Ladner-Fischer (@lf@) implementation of prefix-sum. lf :: (a, a -> a -> a) -> PowerList a -> PowerList a-lf _ [] = error "lf: malformed (empty) powerlist"-lf _ [x] = [x]-lf (zero, f) pl = zipPL (zipWith f (rsh lfpq) p) lfpq+lf _ [] = error "lf: malformed (empty) powerlist"+lf _ [x] = [x]+lf (zeroE, f) pl = zipPL (zipWith f (rsh lfpq) p) lfpq where (p, q) = unzipPL pl pq = zipWith f p q- lfpq = lf (zero, f) pq- rsh xs = zero : init xs+ lfpq = lf (zeroE, f) pq+ rsh xs = zeroE : init xs ----------------------------------------------------------------------
Documentation/SBV/Examples/Misc/Definitions.hs view
@@ -12,6 +12,7 @@ ----------------------------------------------------------------------------- {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# OPTIONS_GHC -Wall -Werror #-} @@ -19,7 +20,6 @@ import Data.SBV import Data.SBV.Tuple-import qualified Data.SBV.List as L ------------------------------------------------------------------------- -- * Simple functions@@ -46,11 +46,13 @@ -- | Sum of numbers from 0 to the given number. Since this is a recursive -- definition, we cannot simply symbolically simulate it as it wouldn't--- terminat. So, we use the function generation facilities to define it--- directly in SMTLib. Note how the function itself takes a "recursive version"--- of itself, and all recursive calls are made with this name.+-- terminate. So, we use the function generation facilities to define it+-- directly in SMTLib. sumToN :: SInteger -> SInteger-sumToN = smtFunction "sumToN" $ \x -> ite (x .<= 0) 0 (x + sumToN (x - 1))+sumToN = smtFunction "sumToN" $ \x -> [sCase| x of+ _ | x .<= 0 -> 0+ _ -> x + sumToN (x - 1)+ |] -- | Prove that sumToN works as expected. --@@ -65,7 +67,10 @@ -- | Coding list-length recursively. Again, we map directly to an SMTLib function. len :: SList Integer -> SInteger-len = smtFunction "list_length" $ \xs -> ite (L.null xs) 0 (1 + len (L.tail xs))+len = smtFunction "list_length" $ \xs -> [sCase| xs of+ [] -> 0+ _:ts -> 1 + len ts+ |] -- | Calculate the length of a list, using recursive functions. --@@ -90,26 +95,56 @@ pingPong :: IO SatResult pingPong = sat $ \x -> x .> 0 .&& ping x sTrue .> x where ping :: SInteger -> SBool -> SInteger- ping = smtFunction "ping" $ \x y -> ite y (pong (x+1) (sNot y)) (x - 1)+ ping = smtFunctionWithMeasure "ping" (\_ y -> ite y 1 (0 :: SInteger), [])+ $ \x y -> [sCase| y of+ True -> pong (x+1) (sNot y)+ False -> x - 1+ |] pong :: SInteger -> SBool -> SInteger- pong = smtFunction "pong" $ \a b -> ite b (ping (a-1) (sNot b)) a+ pong = smtFunctionWithMeasure "pong" (\_ b -> ite b 1 (0 :: SInteger), [])+ $ \a b -> [sCase| b of+ True -> ping (a-1) (sNot b)+ False -> a+ |] --- | Usual way to define even-odd mutually recursively. Unfortunately, while this goes through,--- the backend solver does not terminate on this example. See 'evenOdd2' for an alternative--- technique to handle such definitions, which seems to be more solver friendly.+-- | Usual way to define even-odd mutually recursively. While the termination measure+-- is verified, current SMT solvers do not terminate when evaluating mutually recursive+-- @define-funs-rec@ definitions. See 'isEvenOdd' for a single-function alternative+-- that is more solver-friendly.+--+-- >>> evenOdd+-- Unknown.+-- Reason: timeout evenOdd :: IO SatResult-evenOdd = satWith z3{verbose=True} $ \a r -> a .== 20 .&& r .== isE a+evenOdd = sat $ do setTimeOut 5000+ a <- sInteger "a"+ r <- sBool "r"+ constrain $ a .== 20 .&& r .== isE a where isE, isO :: SInteger -> SBool- isE = smtFunction "isE" $ \x -> ite (x .< 0) (isE (-x)) (x .== 0 .|| isO (x - 1))- isO = smtFunction "isO" $ \x -> ite (x .< 0) (isO (-x)) (x .== 0 .|| isE (x - 1))+ isE = smtFunctionWithMeasure "isE" (\x -> tuple (abs x, ite (x .< 0) (1 :: SInteger) 0), [])+ $ \x -> [sCase| x of+ _ | x .< 0 -> isE (-x)+ _ -> x .== 0 .|| isO (x - 1)+ |]+ isO = smtFunctionWithMeasure "isO" (\x -> tuple (abs x, ite (x .< 0) (1 :: SInteger) 0), [])+ $ \x -> [sCase| x of+ _ | x .< 0 -> isO (-x)+ _ -> x .== 0 .|| isE (x - 1)+ |] -- | Another technique to handle mutually definitions is to define the functions together, and pull the results out individually.--- This usually works better than defining the functions separately, from a solver perspective.+--+-- The measure @(abs x, ite (x < 0) 1 0)@ ensures termination: when @x < 0@, the call @isEvenOdd(-x)@+-- keeps @abs x@ the same but drops the second component from 1 to 0. When @x > 0@, the call+-- @isEvenOdd(x-1)@ decreases @abs x@. isEvenOdd :: SInteger -> STuple Bool Bool-isEvenOdd = smtFunction "isEvenOdd" $ \x -> ite (x .< 0) (isEvenOdd (-x))- $ ite (x .== 0) (tuple (sTrue, sFalse))- (swap (isEvenOdd (x - 1)))+isEvenOdd = smtFunctionWithMeasure "isEvenOdd" (\x -> tuple (abs x, ite (x .< 0) (1 :: SInteger) 0), [])+ $ \x -> [sCase| x of+ _ | x .< 0 -> isEvenOdd (-x)+ _ | x .== 0 -> tuple (sTrue, sFalse)+ _ -> swap (isEvenOdd (x - 1))+ |] -- | Extract the isEven function for easier use. isEven :: SInteger -> SBool@@ -135,9 +170,12 @@ -- | Ackermann function, demonstrating nested recursion. ack :: SInteger -> SInteger -> SInteger-ack = smtFunction "ack" $ \x y -> ite (x .== 0) (y + 1)- $ ite (y .== 0) (ack (x - 1) 1)- (ack (x - 1) (ack x (y - 1)))+ack = smtFunction "ack"+ $ \x y -> [sCase| x of+ _ | x .<= 0 -> y + 1+ _ | y .<= 0 -> ack (x - 1) 1+ _ -> ack (x - 1) (ack x (y - 1))+ |] -- | We can prove constant-folding instances of the equality @ack 1 y == y + 2@: --
Documentation/SBV/Examples/Misc/LambdaArray.hs view
@@ -29,17 +29,17 @@ -- Q.E.D. memsetExample :: IO ThmResult memsetExample = prove $ do- mem <- sArray "mem"- lo <- sInteger "lo"- hi <- sInteger "hi"- zero <- sInteger "zero"+ mem <- sArray "mem"+ lo <- sInteger "lo"+ hi <- sInteger "hi"+ zeroV <- sInteger "zero" -- Get an index within lo/hi idx <- sInteger "idx" constrain $ idx .>= lo .&& idx .<= hi -- It must be the case that we get zero back after mem-setting- pure $ readArray (memset mem lo hi zero) idx .== zero+ pure $ readArray (memset mem lo hi zeroV) idx .== zeroV -- | Get an example of reading a value out of range. The value returned should be out-of-range for lo/hi --@@ -53,10 +53,10 @@ -- Read = 1 :: Integer outOfInit :: IO SatResult outOfInit = sat $ do- mem <- sArray "mem"- lo <- sInteger "lo"- hi <- sInteger "hi"- zero <- sInteger "zero"+ mem <- sArray "mem"+ lo <- sInteger "lo"+ hi <- sInteger "hi"+ zeroV <- sInteger "zero" -- Get a meaningful range: constrain $ lo .<= hi@@ -65,6 +65,6 @@ idx <- sInteger "idx" -- Let read produce non-zero- constrain $ observe "Read" (readArray (memset mem lo hi zero) idx) ./= zero+ constrain $ observe "Read" (readArray (memset mem lo hi zeroV) idx) ./= zeroV {- HLint ignore module "Reduce duplication" -}
Documentation/SBV/Examples/Puzzles/SquareBirthday.hs view
@@ -70,7 +70,7 @@ symDate :: String -> Symbolic SDate symDate nm = do dt <- free nm - constrain [sCase|Date dt of+ constrain [sCase| dt of MkDate d _ y -> sAnd [ 1 .<= d, d .<= 31 , 0 .<= y ]@@ -116,7 +116,7 @@ -- | A date is square if all its components are. squareDate :: SDate -> SBool-squareDate dt = [sCase|Date dt of+squareDate dt = [sCase| dt of MkDate d m y -> squareDay d .&& squareMonth m .&& squareYear y |] where squareDay d = d `sElem` [1, 4, 9, 16, 25]@@ -126,13 +126,13 @@ -- | Summing the square-roots of the components of a date. sqrSum :: SDate -> SInteger-sqrSum dt = [sCase|Date dt of+sqrSum dt = [sCase| dt of MkDate d m y -> r d + mr m + r y |] where r v = v `SL.lookup` literal ([(i * i, i) | i <- [1, 2, 3, 4, 5]] ++ squareYears) mr :: SMonth -> SInteger- mr m = [sCase|Month m of+ mr m = [sCase| m of Jan -> 1 Apr -> 2 Sep -> 3@@ -159,7 +159,7 @@ constrain $ syear myBirthday .< 2000 .&& syear myBirthday .>= 1900 -- My next birthday will be a square- let next = [sCase|Date myBirthday of+ let next = [sCase| myBirthday of MkDate d m _ -> sMkDate d m (syear today + oneIf (today `onOrAfter` myBirthday)) |] @@ -179,12 +179,12 @@ momBirthday <- symDate "Mom's Birthday" -- Mom has a square birth-date, except for the month:- constrain [sCase|Date momBirthday of+ constrain [sCase| momBirthday of MkDate d _ y -> squareDate (sMkDate d sJan y) |] -- Mom's day and month are perfect cubes- constrain [sCase|Date momBirthday of+ constrain [sCase| momBirthday of MkDate d m _ -> sAnd [ d `sElem` [1, 8, 27] , m `sElem` [sJan, sAug] ]
Documentation/SBV/Examples/TP/Ackermann.hs view
@@ -26,6 +26,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wall -Werror #-}@@ -48,21 +49,25 @@ -- original version, not the commonly referenced Ackermann-Péter function. -- The third argument @a@ generalizes the operation at each level. ack :: SInteger -> SInteger -> SInteger -> SInteger-ack = smtFunction "ack" $ \m n a ->- ite (m .<= 0) (n + a)- $ ite (n .<= 0) 0- $ ite (n .== 1) a- $ ack (m - 1) (ack m (n - 1) a) a+ack = smtFunction "ack"+ $ \m n a -> [sCase| m of+ _ | m .<= 0 -> n + a+ _ | n .<= 0 -> 0+ _ | n .== 1 -> a+ _ -> ack (m - 1) (ack m (n - 1) a) a+ |] -- * Ackermann-Péter function (1935) -- | The Ackermann-Péter function (1935), commonly known as "the Ackermann function." -- This is Rózsa Péter's simplified 2-argument version of Ackermann's original function. pet :: SInteger -> SInteger -> SInteger-pet = smtFunction "pet" $ \m n ->- ite (m .<= 0) (n + 1)- $ ite (n .<= 0) (pet (m - 1) 1)- $ pet (m - 1) (pet m (n - 1))+pet = smtFunction "pet"+ $ \m n -> [sCase| m of+ _ | m .<= 0 -> n + 1+ _ | n .<= 0 -> pet (m - 1) 1+ _ -> pet (m - 1) (pet m (n - 1))+ |] -- * Correctness @@ -79,6 +84,7 @@ -- Step: 1.2.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ack -- [Proven] ack_2_2_4 :: Ɐm ∷ Integer → Bool ack_2_2_4 :: TP (Proof (Forall "m" Integer -> SBool)) ack_2_2_4 = sInduct "ack_2_2_4"@@ -110,6 +116,7 @@ -- Step: 1.4.3 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ack -- [Proven] ack_psd :: Ɐm ∷ Integer → Ɐn ∷ Integer → Ɐa ∷ Integer → Bool ack_psd :: TP (Proof (Forall "m" Integer -> Forall "n" Integer -> Forall "a" Integer -> SBool)) ack_psd = sInduct "ack_psd"@@ -146,6 +153,7 @@ -- Step: 1.3.3 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: pet -- [Proven] pet_psd :: Ɐm ∷ Integer → Ɐn ∷ Integer → Bool pet_psd :: TP (Proof (Forall "m" Integer -> Forall "n" Integer -> SBool)) pet_psd = do@@ -214,6 +222,7 @@ -- Step: 1.4.5 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ack, pet -- [Proven] petAck :: Ɐm ∷ Integer → Ɐn ∷ Integer → Bool petAck :: TP (Proof (Forall "m" Integer -> Forall "n" Integer -> SBool)) petAck = do
Documentation/SBV/Examples/TP/Basics.hs view
@@ -11,6 +11,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-}@@ -219,32 +220,106 @@ =: qed where n = literal e --- * No termination checks+-- * Termination checking --- | It's important to realize that TP proofs in SBV neither check nor guarantee that the--- functions we use are terminating. This is beyond the scope (and current capabilities) of what SBV can handle.--- That is, the proof is up-to-termination, i.e., any proof implicitly assumes all functions defined (or axiomatized)--- terminate for all possible inputs. If non-termination is possible, then the logic becomes inconsistent, i.e.,+-- | When a recursive function is defined via 'smtFunction', SBV automatically checks that it terminates+-- by guessing and verifying a termination measure. Here we define a simple recursive @sumToN@ and prove+-- a property about it. Note the @Functions proven terminating@ line in the output, confirming that SBV+-- verified the termination of @sumToN@ before proceeding with the proof.+--+-- >>> terminationDemo+-- Lemma: sumToN_at_5 Q.E.D.+-- Functions proven terminating: sumToN+-- [Proven] sumToN_at_5 :: Ɐn ∷ Integer → Bool+terminationDemo :: IO (Proof (Forall "n" Integer -> SBool))+terminationDemo = runTP $ do+ let sumToN :: SInteger -> SInteger+ sumToN = smtFunction "sumToN" $ \x -> [sCase| x of+ _ | x .<= 0 -> 0+ _ -> x + sumToN (x - 1)+ |]++ lemma "sumToN_at_5"+ (\(Forall n) -> n .== 5 .=> sumToN n .== 15)+ []++-- | If SBV cannot determine a termination measure, it will report an error. Here, we define+-- a function that recurses without decreasing any argument, and SBV rightfully rejects it:+--+-- >>> badTermination `catch` (\(e :: SomeException) -> mapM_ putStrLn . filter (\l -> take 3 l == "***") . lines $ show e)+-- *** Data.SBV: Cannot determine a termination measure.+-- ***+-- *** Function: bad :: SBV Integer -> SBV Integer+-- ***+-- *** Measures tried:+-- *** abs arg1+-- *** smax 0 arg1+-- *** abs arg1 + smax 0 arg1+-- *** (abs arg1, smax 0 arg1)+-- *** (smax 0 arg1, abs arg1)+-- ***+-- *** Please use 'smtFunctionWithMeasure' to provide an explicit measure.+badTermination :: IO ()+badTermination = do+ let bad :: SInteger -> SInteger+ bad = smtFunction "bad" $ \x -> [sCase| x of+ _ | x .== 0 -> 0+ _ -> bad x+ |]+ r <- prove $ \x -> bad x .== bad x+ print r++-- | If the user provides an explicit but incorrect termination measure via 'smtFunctionWithMeasure',+-- SBV will detect this and report an error. Here, we use @const 0@ as a measure, which clearly+-- does not decrease at recursive calls:+--+-- >>> badMeasure `catch` (\(e :: SomeException) -> mapM_ putStrLn . filter (\l -> take 3 l == "***") . lines $ show e)+-- *** Data.SBV: Termination measure does not strictly decrease at a recursive call site.+-- ***+-- *** Function: badM :: SBV Integer -> SBV Integer+-- ***+-- *** Falsifiable. Counter-example:+-- *** arg = 1 :: Integer+-- *** before = 0 :: Integer+-- *** then = 0 :: Integer+-- ***+-- *** The measure must strictly decrease at every recursive call.+badMeasure :: IO ()+badMeasure = do+ let badM :: SInteger -> SInteger+ badM = smtFunctionWithMeasure "badM" (const (0 :: SInteger), [])+ $ \x -> [sCase| x of+ _ | x .<= 0 -> 0+ _ -> x + badM (x - 1)+ |]+ r <- prove $ \x -> badM x .== badM x+ print r++-- * Axioms and consistency++-- | SBV checks that recursive functions defined via 'smtFunction' terminate, verifying a termination measure, which+-- can be auto-guessed or specified by the user. However, axioms are taken on faith: they are not checked for consistency.+-- If an axiom introduces a non-terminating or contradictory definition, the logic becomes inconsistent, i.e., -- we can prove arbitrary results. ----- Here is a simple example where we tell SBV that there is a function @f@ with non terminating behavior. Using this,--- we can deduce @False@:+-- Here is a simple example where we assert an axiom equivalent to a non-terminating definition @f n == 1 + f n@.+-- Using this, we can deduce @False@: ----- >>> noTerminationChecks+-- >>> axiomsAreDangerous -- Axiom: bad--- Lemma: noTerminationImpliesFalse+-- Lemma: axiomsCanBeInconsistent -- Step: 1 (bad @ (n |-> 0 :: SInteger)) Q.E.D. -- Result: Q.E.D.--- [Proven] noTerminationImpliesFalse :: Bool-noTerminationChecks :: IO (Proof SBool)-noTerminationChecks = runTP $ do+-- [Proven] axiomsCanBeInconsistent :: Bool+axiomsAreDangerous :: IO (Proof SBool)+axiomsAreDangerous = runTP $ do let f :: SInteger -> SInteger f = uninterpret "f" badAxiom <- axiom "bad" (\(Forall n) -> f n .== 1 + f n) - calc "noTerminationImpliesFalse"+ calc "axiomsCanBeInconsistent" sFalse ([] |- f 0 ?? badAxiom `at` Inst @"n" (0 :: SInteger)@@ -293,48 +368,29 @@ -- | It is not unusual that TP proofs rely on other proofs. Typically, all the helpers are used together and proven in -- one go. It is, however, useful to be able to write these proofs as top-level entries, and reuse them multiple times -- in several proofs. (See "Documentation/SBV/Examples/TP/PowerMod.hs" for an example.) To avoid re-proving such--- lemmas, you can turn on proof caching. The idea behind caching is simple: If we see a lemma with the same name being--- proven again, then we simply reuse the last result. The catch here is that lemmas are identified by their names: Hence,--- for caching to be sound, you need to make sure all names used in your proof are unique. Otherwise you can--- conclude wrong results!------ A good trick is to pay the price and run your entire proof without caching (which is the default) once, and if it is--- all good, turn on caching to save time in regressions. (And rerun without caching after code changes.)+-- lemmas, SBV caches proof results keyed by symbolic fingerprint. Use 'recall' to invoke a proof action that+-- benefits from the cache: if the proposition has already been proved, the cached result is returned immediately.+-- Note that 'lemma', 'calc', and 'induct' always prove from scratch and then store the result in the cache;+-- only 'recall' performs a cache lookup. ----- To demonstrate why caching can be unsound, simply consider a proof where we first prove true, and then prove false--- but we /trick/ TP by reusing the name. If you run this, you'll see:+-- Lemma names do not need to be unique. If you prove the same proposition under different names, 'recall' will+-- show the aliases. If you prove different propositions under the same name, each is proved independently.+-- To demonstrate, note that reusing the name @"evil"@ does not cause any confusion: the second call to+-- 'lemma' proves from scratch and correctly fails: ----- >>> runTP badCaching `catch` (\(_ :: SomeException) -> pure ())+-- >>> runTP duplicateNames `catch` (\(_ :: SomeException) -> pure ()) -- Lemma: evil Q.E.D. -- Lemma: evil -- *** Failed to prove evil. -- Falsifiable ----- This is good, the proof failed since it's just not true. (Except for the confusing naming printed in the trace--- due to our own choice.)------ Let's see what happens if we turn caching on:------ >>> runTPWith (tpCache z3) badCaching--- Lemma: evil Q.E.D.--- Cached: evil Q.E.D.------ In this case we were able to ostensibly prove False, i.e., this result is unsound. But at least SBV warned us--- that we used a cached proof (@evil@), reminding us that using unique names is a proof of obligation for the user--- if caching is turned on. Clearly, we failed to uniquely name our proofs in this case.------ Note that a bad proof obtained this way is unsound in the way that it is misleading: That is, it will lead you--- to believe you proved something while you actually proved something else. (More technically, you cannot take the evil--- lemma and use it to prove arbitrary things, since it's still just the proof of truth.) In this sense it is just--- useless as opposed to soundness, but it is alarming as one can be led astray.--- -- (Incidentally, if you really want to be evil, you can just use 'axiom' and assert false, but that's another story.)-badCaching :: TP ()-badCaching = do- -- Prove true, giving it a bad name+duplicateNames :: TP ()+duplicateNames = do+ -- Prove true _ <- lemma "evil" sTrue [] - -- Attempt to prove false, using evil:+ -- Attempt to prove false, reusing the same name. Will be caught! _ <- lemma "evil" sFalse [] pure ()
Documentation/SBV/Examples/TP/BinarySearch.hs view
@@ -10,6 +10,7 @@ ----------------------------------------------------------------------------- {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wall -Werror #-}@@ -35,16 +36,16 @@ -- | Encode binary search in a functional style. bsearch :: Arr -> Idx -> SInteger -> SMaybe Integer bsearch array (low, high) = f array low high- where f = smtFunction "bsearch" $ \arr lo hi x ->+ where f = smtFunctionWithMeasure "bsearch" (\_arr lo hi _x -> (hi - lo + 1) `smax` 0, [])+ $ \arr lo hi x -> let mid = (lo + hi) `sEDiv` 2 xmid = arr `readArray` mid- in ite (lo .> hi)- sNothing- (ite (xmid .== x)- (sJust mid)- (ite (xmid .< x)- (bsearch arr (mid+1, hi) x)- (bsearch arr (lo, mid-1) x)))+ in [sCase| lo of+ _ | lo .> hi -> sNothing+ _ | xmid .== x -> sJust mid+ _ | xmid .< x -> bsearch arr (mid+1, hi) x+ _ -> bsearch arr (lo, mid-1) x+ |] -- * Correctness proof @@ -104,6 +105,7 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: bsearch -- [Proven] bsearchCorrect :: Ɐarr ∷ (ArrayModel Integer Integer) → Ɐlo ∷ Integer → Ɐhi ∷ Integer → Ɐx ∷ Integer → Bool correctness :: IO (Proof (Forall "arr" (ArrayModel Integer Integer) -> Forall "lo" Integer -> Forall "hi" Integer -> Forall "x" Integer -> SBool)) correctness = runTPWith (tpRibbon 50 cvc5) $ do
Documentation/SBV/Examples/TP/Coins.hs view
@@ -25,7 +25,6 @@ import Data.SBV import Data.SBV.Maybe hiding (maybe)-import qualified Data.SBV.Maybe as SM import Data.SBV.TP #ifdef DOCTEST@@ -55,20 +54,22 @@ -- For @n > 10@, we use change for @n-3@ and add one more 3-cent coin. mkChange :: SInteger -> SMaybe Pocket mkChange = smtFunction "mkChange" $ \n ->- ite (n .< 8) sNothing- $ ite (n .== 8) (sJust (sPocket 1 1))- $ ite (n .== 9) (sJust (sPocket 3 0))- $ ite (n .== 10) (sJust (sPocket 0 2))- -- n > 10: use change for (n-3) and add a 3-cent coin- [sCase|Pocket fromJust (mkChange (n - 3)) of- Pocket n3 n5 -> sJust (sPocket (n3 + 1) n5)- |]+ [sCase| n of+ _ | n .< 8 -> sNothing+ _ | n .== 8 -> sJust (sPocket 1 1)+ _ | n .== 9 -> sJust (sPocket 3 0)+ _ | n .== 10 -> sJust (sPocket 0 2)+ _ -> case mkChange (n - 3) of+ Nothing -> sNothing+ Just (Pocket n3 n5) -> sJust (sPocket (n3 + 1) n5)+ |] -- | Evaluate the value of a pocket (total cents). evalPocket :: SMaybe Pocket -> SInteger-evalPocket = SM.maybe 0 $ \p -> [sCase|Pocket p of- Pocket n3 n5 -> 3 * n3 + 5 * n5- |]+evalPocket mp = [sCase| mp of+ Nothing -> 0+ Just (Pocket n3 n5) -> 3 * n3 + 5 * n5+ |] -- * Correctness @@ -89,9 +90,10 @@ -- Step: 1.5.3 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: mkChange -- [Proven] mkChangeCorrect :: Ɐn ∷ Integer → Bool correctness :: TP (Proof (Forall "n" Integer -> SBool))-correctness = do+correctness = sInduct "mkChangeCorrect" (\(Forall n) -> n .>= 8 .=> evalPocket (mkChange n) .== n) (id, []) $@@ -102,8 +104,9 @@ , n .== 10 ==> trivial , n .< 8 ==> trivial -- Vacuously true: contradicts n >= 8 , n .> 10 ==> evalPocket (mkChange n) .== n- =: [sCase|Pocket fromJust (mkChange (n - 3)) of- Pocket n3 n5 -> evalPocket (sJust (sPocket (n3 + 1) n5)) .== n+ =: [sCase| mkChange (n - 3) of+ Nothing -> evalPocket sNothing .== n+ Just (Pocket n3 n5) -> evalPocket (sJust (sPocket (n3 + 1) n5)) .== n |] ?? ih `at` Inst @"n" (n - 3) =: sTrue
+ Documentation/SBV/Examples/TP/Collatz.hs view
@@ -0,0 +1,119 @@+-----------------------------------------------------------------------------+-- |+-- Module : Documentation.SBV.Examples.TP.Collatz+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer: erkokl@gmail.com+-- Stability : experimental+--+-- The Collatz function: starting from a positive integer, if it is 1 we stop;+-- if it is even we halve it; if it is odd we triple and add one. Whether this+-- process terminates for every positive integer is the famous Collatz conjecture,+-- an open problem in mathematics. Because no termination measure is known, we+-- define 'collatz' with 'smtFunctionNoTermination', which emits the recursive+-- definition without any termination check.+--+-- We then prove that 'collatz' reaches 1 for every power of two.+-----------------------------------------------------------------------------++{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror #-}++module Documentation.SBV.Examples.TP.Collatz where++import Data.SBV+import Data.SBV.TP++#ifdef DOCTEST+-- $setup+-- >>> import Data.SBV.TP+#endif++-- * Definitions++-- | The Collatz function. Termination for all positive integers is the famous+-- Collatz conjecture, an open problem in mathematics. We use 'smtFunctionNoTermination'+-- since no termination measure is known.+collatz :: SInteger -> SInteger+collatz = smtFunctionNoTermination "collatz"+ $ \n -> [sCase| n of+ 1 -> 1+ _ | 2 `sDivides` n -> collatz (n `sDiv` 2)+ | True -> collatz (3 * n + 1)+ |]++-- | Power of two: @pow2 k = 2^k@ for @k >= 0@.+pow2 :: SInteger -> SInteger+pow2 = smtFunction "pow2"+ $ \k -> [sCase| k of+ _ | k .<= 0 -> 1+ | True -> 2 * pow2 (k - 1)+ |]++-- * Helper lemmas++-- | Doubling doesn't change the Collatz result.+--+-- >>> runTP doubling+-- Lemma: doubling Q.E.D. [Modulo: collatz termination]+-- [Modulo: collatz termination] doubling :: Ɐn ∷ Integer → Bool+doubling :: TP (Proof (Forall "n" Integer -> SBool))+doubling = lemma "doubling" (\(Forall @"n" n) -> n .>= 1 .=> collatz (2 * n) .== collatz n) []++-- | Powers of two are positive.+--+-- >>> runTP pow2pos+-- Inductive lemma: pow2pos+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: pow2+-- [Proven] pow2pos :: Ɐk ∷ Integer → Bool+pow2pos :: TP (Proof (Forall "k" Integer -> SBool))+pow2pos = induct "pow2pos"+ (\(Forall @"k" k) -> pow2 k .>= 1) $+ \ih k -> []+ |- pow2 (k + 1) .>= 1+ =: 2 * pow2 k .>= 1+ ?? ih+ =: sTrue+ =: qed++-- * Correctness++-- | All powers of two reach 1 under the Collatz function.+--+-- >>> runTP collatzPow2+-- Lemma: doubling Q.E.D. [Modulo: collatz termination]+-- Lemma: pow2pos Q.E.D.+-- Inductive lemma: collatzPow2+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D. [Modulo: collatz termination]+-- Step: 3 Q.E.D.+-- Result: Q.E.D. [Modulo: collatz termination]+-- Functions proven terminating: pow2+-- [Modulo: collatz termination] collatzPow2 :: Ɐk ∷ Integer → Bool+collatzPow2 :: TP (Proof (Forall "k" Integer -> SBool))+collatzPow2 = do+ dbl <- recall doubling+ p2p <- recall pow2pos++ induct "collatzPow2"+ (\(Forall @"k" k) -> k .>= 0 .=> collatz (pow2 k) .== 1) $+ \ih k -> [k .>= 0]+ |- collatz (pow2 (k + 1))+ =: collatz (2 * pow2 k)+ ?? dbl+ ?? p2p+ =: collatz (pow2 k)+ ?? ih+ =: (1 :: SInteger)+ =: qed
Documentation/SBV/Examples/TP/ConstFold.hs view
@@ -67,7 +67,7 @@ -- * @Let nm (Con v) b → subst nm v b@ simplify :: SE -> SE simplify = smtFunction "simplify" $ \expr ->- [sCase|Expr expr of+ [sCase| expr of Sqr (Con v) -> sCon (v * v) Inc (Con v) -> sCon (v + 1)@@ -102,7 +102,7 @@ -- * @Let x a b → Let x (subst nm v a) (if x == nm then b else subst nm v b)@ subst :: SString -> SInteger -> SE -> SE subst = smtFunction "subst" $ \nm v expr ->- [sCase|Expr expr of+ [sCase| expr of -- Substitute for vars if name matches Var x | x .== nm -> sCon v@@ -125,7 +125,7 @@ -- | Constant fold an expression bottom-up: first fold sub-expressions, then simplify. cfold :: SE -> SE cfold = smtFunction "cfold" $ \expr ->- [sCase|Expr expr of+ [sCase| expr of Var nm -> sVar nm Con v -> sCon v Sqr a -> simplify (sSqr (cfold a))@@ -141,7 +141,8 @@ -- -- >>> runTP measureNonNeg -- Lemma: measureNonNeg Q.E.D.--- [Proven] measureNonNeg :: Ɐe ∷ (Expr [Char] Integer) → Bool+-- Functions proven terminating: exprSize+-- [Proven] measureNonNeg :: Ɐe ∷ (Expr String Integer) → Bool measureNonNeg :: TP (Proof (Forall "e" Exp -> SBool)) measureNonNeg = inductiveLemma "measureNonNeg" (\(Forall @"e" (e :: SE)) -> size e .>= 0)@@ -201,7 +202,8 @@ -- -- >>> runTP sqrHelper -- Lemma: sqrHelper Q.E.D.--- [Proven] sqrHelper :: Ɐenv ∷ [([Char], Integer)] → Ɐa ∷ (Expr [Char] Integer) → Bool+-- Functions proven terminating: interpInEnv, sbv.lookup+-- [Proven] sqrHelper :: Ɐenv ∷ [(String, Integer)] → Ɐa ∷ (Expr String Integer) → Bool sqrHelper :: TP (Proof (Forall "env" EL -> Forall "a" Exp -> SBool)) sqrHelper = lemma "sqrHelper" (\(Forall @"env" (env :: E)) (Forall @"a" a) ->@@ -211,7 +213,8 @@ -- -- >>> runTP addHelper -- Lemma: addHelper Q.E.D.--- [Proven] addHelper :: Ɐenv ∷ [([Char], Integer)] → Ɐa ∷ (Expr [Char] Integer) → Ɐb ∷ (Expr [Char] Integer) → Bool+-- Functions proven terminating: interpInEnv, sbv.lookup+-- [Proven] addHelper :: Ɐenv ∷ [(String, Integer)] → Ɐa ∷ (Expr String Integer) → Ɐb ∷ (Expr String Integer) → Bool addHelper :: TP (Proof (Forall "env" EL -> Forall "a" Exp -> Forall "b" Exp -> SBool)) addHelper = lemma "addHelper" (\(Forall @"env" (env :: E)) (Forall @"a" a) (Forall @"b" b) ->@@ -221,7 +224,8 @@ -- -- >>> runTP mulHelper -- Lemma: mulHelper Q.E.D.--- [Proven] mulHelper :: Ɐenv ∷ [([Char], Integer)] → Ɐa ∷ (Expr [Char] Integer) → Ɐb ∷ (Expr [Char] Integer) → Bool+-- Functions proven terminating: interpInEnv, sbv.lookup+-- [Proven] mulHelper :: Ɐenv ∷ [(String, Integer)] → Ɐa ∷ (Expr String Integer) → Ɐb ∷ (Expr String Integer) → Bool mulHelper :: TP (Proof (Forall "env" EL -> Forall "a" Exp -> Forall "b" Exp -> SBool)) mulHelper = lemma "mulHelper" (\(Forall @"env" (env :: E)) (Forall @"a" a) (Forall @"b" b) ->@@ -231,7 +235,8 @@ -- -- >>> runTP letHelper -- Lemma: letHelper Q.E.D.--- [Proven] letHelper :: Ɐenv ∷ [([Char], Integer)] → Ɐnm ∷ [Char] → Ɐa ∷ (Expr [Char] Integer) → Ɐb ∷ (Expr [Char] Integer) → Bool+-- Functions proven terminating: interpInEnv, sbv.lookup+-- [Proven] letHelper :: Ɐenv ∷ [(String, Integer)] → Ɐnm ∷ String → Ɐa ∷ (Expr String Integer) → Ɐb ∷ (Expr String Integer) → Bool letHelper :: TP (Proof (Forall "env" EL -> Forall "nm" String -> Forall "a" Exp -> Forall "b" Exp -> SBool)) letHelper = lemma "letHelper" (\(Forall @"env" (env :: E)) (Forall @"nm" nm) (Forall @"a" a) (Forall @"b" b) ->@@ -249,7 +254,8 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] lookupSwap :: Ɐk ∷ [Char] → Ɐb1 ∷ ([Char], Integer) → Ɐb2 ∷ ([Char], Integer) → Ɐenv ∷ [([Char], Integer)] → Bool+-- Functions proven terminating: sbv.lookup+-- [Proven] lookupSwap :: Ɐk ∷ String → Ɐb1 ∷ (String, Integer) → Ɐb2 ∷ (String, Integer) → Ɐenv ∷ [(String, Integer)] → Bool lookupSwap :: TP (Proof (Forall "k" String -> Forall "b1" (String, Integer) -> Forall "b2" (String, Integer) -> Forall "env" EL -> SBool)) lookupSwap = calc "lookupSwap"@@ -273,11 +279,26 @@ =: qed ] +-- | One-step unfolding of 'SL.lookup' on a cons cell. The solver can expand the+-- @define-fun-rec@ but struggles to fold it back, so we provide this as a reusable hint.+--+-- >>> runTP lookupCons+-- Lemma: lookupCons Q.E.D.+-- Functions proven terminating: sbv.lookup+-- [Proven] lookupCons :: Ɐk ∷ String → Ɐb ∷ (String, Integer) → Ɐrest ∷ [(String, Integer)] → Bool+lookupCons :: TP (Proof (Forall "k" String -> Forall "b" (String, Integer) -> Forall "rest" EL -> SBool))+lookupCons = lemma "lookupCons"+ (\(Forall @"k" (k :: SString)) (Forall @"b" (b :: STuple String Integer)) (Forall @"rest" (rest :: E)) ->+ let (bk, bv) = ST.untuple b+ in SL.lookup k (b .: rest) .== ite (k .== bk) bv (SL.lookup k rest))+ []+ -- | Generalized swap: swapping two adjacent distinct-keyed bindings behind -- a prefix does not affect lookup. -- -- >>> runTP lookupSwapPfx -- Lemma: lookupSwap Q.E.D.+-- Lemma: lookupCons Q.E.D. -- Inductive lemma (strong): lookupSwapPfx -- Step: Measure is non-negative Q.E.D. -- Step: 1 (2 way case split)@@ -289,11 +310,14 @@ -- Step: 1.2.5 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] lookupSwapPfx :: Ɐpfx ∷ [([Char], Integer)] → Ɐk ∷ [Char] → Ɐb1 ∷ ([Char], Integer) → Ɐb2 ∷ ([Char], Integer) → Ɐenv ∷ [([Char], Integer)] → Bool+-- Functions proven terminating: sbv.lookup+-- [Proven] lookupSwapPfx :: Ɐpfx ∷ [(String, Integer)] → Ɐk ∷ String → Ɐb1 ∷ (String, Integer) → Ɐb2 ∷ (String, Integer) → Ɐenv ∷ [(String, Integer)] → Bool lookupSwapPfx :: TP (Proof (Forall "pfx" EL -> Forall "k" String -> Forall "b1" (String, Integer) -> Forall "b2" (String, Integer) -> Forall "env" EL -> SBool)) lookupSwapPfx = do- lkS <- recall "lookupSwap" lookupSwap+ lkS <- recall lookupSwap+ lkC <- recall lookupCons+ sInduct "lookupSwapPfx" (\(Forall @"pfx" (pfx :: E)) (Forall @"k" (k :: SString)) (Forall @"b1" (b1 :: STuple String Integer)) (Forall @"b2" (b2 :: STuple String Integer)) (Forall @"env" (env :: E)) ->@@ -323,6 +347,7 @@ =: ite (k .== hk) hv (SL.lookup k (t ++ b1 .: b2 .: env)) ?? ih `at` (Inst @"pfx" t, Inst @"k" k, Inst @"b1" b1, Inst @"b2" b2, Inst @"env" env) =: ite (k .== hk) hv (SL.lookup k (t ++ b2 .: b1 .: env))+ ?? lkC `at` (Inst @"k" k, Inst @"b" h, Inst @"rest" (t ++ b2 .: b1 .: env)) =: SL.lookup k (h .: (t ++ b2 .: b1 .: env)) =: SL.lookup k (pfx ++ b2 .: b1 .: env) =: qed@@ -332,7 +357,8 @@ -- -- >>> runTP lookupShadow -- Lemma: lookupShadow Q.E.D.--- [Proven] lookupShadow :: Ɐk ∷ [Char] → Ɐb1 ∷ ([Char], Integer) → Ɐb2 ∷ ([Char], Integer) → Ɐenv ∷ [([Char], Integer)] → Bool+-- Functions proven terminating: sbv.lookup+-- [Proven] lookupShadow :: Ɐk ∷ String → Ɐb1 ∷ (String, Integer) → Ɐb2 ∷ (String, Integer) → Ɐenv ∷ [(String, Integer)] → Bool lookupShadow :: TP (Proof (Forall "k" String -> Forall "b1" (String, Integer) -> Forall "b2" (String, Integer) -> Forall "env" EL -> SBool)) lookupShadow = lemma "lookupShadow"@@ -348,6 +374,7 @@ -- -- >>> runTP lookupShadowPfx -- Lemma: lookupShadow Q.E.D.+-- Lemma: lookupCons Q.E.D. -- Inductive lemma (strong): lookupShadowPfx -- Step: Measure is non-negative Q.E.D. -- Step: 1 (2 way case split)@@ -359,11 +386,13 @@ -- Step: 1.2.5 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] lookupShadowPfx :: Ɐpfx ∷ [([Char], Integer)] → Ɐk ∷ [Char] → Ɐb1 ∷ ([Char], Integer) → Ɐb2 ∷ ([Char], Integer) → Ɐenv ∷ [([Char], Integer)] → Bool+-- Functions proven terminating: sbv.lookup+-- [Proven] lookupShadowPfx :: Ɐpfx ∷ [(String, Integer)] → Ɐk ∷ String → Ɐb1 ∷ (String, Integer) → Ɐb2 ∷ (String, Integer) → Ɐenv ∷ [(String, Integer)] → Bool lookupShadowPfx :: TP (Proof (Forall "pfx" EL -> Forall "k" String -> Forall "b1" (String, Integer) -> Forall "b2" (String, Integer) -> Forall "env" EL -> SBool)) lookupShadowPfx = do- lkSh <- recall "lookupShadow" lookupShadow+ lkSh <- recall lookupShadow+ lkC <- recall lookupCons sInduct "lookupShadowPfx" (\(Forall @"pfx" (pfx :: E)) (Forall @"k" (k :: SString)) (Forall @"b1" (b1 :: STuple String Integer)) (Forall @"b2" (b2 :: STuple String Integer)) (Forall @"env" (env :: E)) ->@@ -393,6 +422,7 @@ =: ite (k .== hk) hv (SL.lookup k (t ++ b1 .: b2 .: env)) ?? ih `at` (Inst @"pfx" t, Inst @"k" k, Inst @"b1" b1, Inst @"b2" b2, Inst @"env" env) =: ite (k .== hk) hv (SL.lookup k (t ++ b1 .: env))+ ?? lkC `at` (Inst @"k" k, Inst @"b" h, Inst @"rest" (t ++ b1 .: env)) =: SL.lookup k (h .: (t ++ b1 .: env)) =: SL.lookup k (pfx ++ b1 .: env) =: qed@@ -437,21 +467,22 @@ -- Step: 1.7.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] envSwap :: Ɐe ∷ (Expr [Char] Integer) → Ɐpfx ∷ [([Char], Integer)] → Ɐenv ∷ [([Char], Integer)] → Ɐb1 ∷ ([Char], Integer) → Ɐb2 ∷ ([Char], Integer) → Bool+-- Functions proven terminating: exprSize, interpInEnv, sbv.lookup+-- [Proven] envSwap :: Ɐe ∷ (Expr String Integer) → Ɐpfx ∷ [(String, Integer)] → Ɐenv ∷ [(String, Integer)] → Ɐb1 ∷ (String, Integer) → Ɐb2 ∷ (String, Integer) → Bool envSwap :: TP (Proof (Forall "e" Exp -> Forall "pfx" EL -> Forall "env" EL -> Forall "b1" (String, Integer) -> Forall "b2" (String, Integer) -> SBool)) envSwap = do- mnn <- recall "measureNonNeg" measureNonNeg- lkSP <- recall "lookupSwapPfx" lookupSwapPfx- sqrC <- recall "sqrCong" sqrCong- sqrH <- recall "sqrHelper" sqrHelper- addCL <- recall "addCongL" addCongL- addCR <- recall "addCongR" addCongR- addH <- recall "addHelper" addHelper- mulCL <- recall "mulCongL" mulCongL- mulCR <- recall "mulCongR" mulCongR- mulH <- recall "mulHelper" mulHelper- letH <- recall "letHelper" letHelper+ mnn <- recall measureNonNeg+ lkSP <- recall lookupSwapPfx+ sqrC <- recall sqrCong+ sqrH <- recall sqrHelper+ addCL <- recall addCongL+ addCR <- recall addCongR+ addH <- recall addHelper+ mulCL <- recall mulCongL+ mulCR <- recall mulCongR+ mulH <- recall mulHelper+ letH <- recall letHelper sInduct "envSwap" (\(Forall @"e" (e :: SE)) (Forall @"pfx" (pfx :: E)) (Forall @"env" (env :: E))@@ -593,21 +624,22 @@ -- Step: 1.7.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] envShadow :: Ɐe ∷ (Expr [Char] Integer) → Ɐpfx ∷ [([Char], Integer)] → Ɐenv ∷ [([Char], Integer)] → Ɐb1 ∷ ([Char], Integer) → Ɐb2 ∷ ([Char], Integer) → Bool+-- Functions proven terminating: exprSize, interpInEnv, sbv.lookup+-- [Proven] envShadow :: Ɐe ∷ (Expr String Integer) → Ɐpfx ∷ [(String, Integer)] → Ɐenv ∷ [(String, Integer)] → Ɐb1 ∷ (String, Integer) → Ɐb2 ∷ (String, Integer) → Bool envShadow :: TP (Proof (Forall "e" Exp -> Forall "pfx" EL -> Forall "env" EL -> Forall "b1" (String, Integer) -> Forall "b2" (String, Integer) -> SBool)) envShadow = do- mnn <- recall "measureNonNeg" measureNonNeg- lkShP <- recall "lookupShadowPfx" lookupShadowPfx- sqrC <- recall "sqrCong" sqrCong- sqrH <- recall "sqrHelper" sqrHelper- addCL <- recall "addCongL" addCongL- addCR <- recall "addCongR" addCongR- addH <- recall "addHelper" addHelper- mulCL <- recall "mulCongL" mulCongL- mulCR <- recall "mulCongR" mulCongR- mulH <- recall "mulHelper" mulHelper- letH <- recall "letHelper" letHelper+ mnn <- recall measureNonNeg+ lkShP <- recall lookupShadowPfx+ sqrC <- recall sqrCong+ sqrH <- recall sqrHelper+ addCL <- recall addCongL+ addCR <- recall addCongR+ addH <- recall addHelper+ mulCL <- recall mulCongL+ mulCR <- recall mulCongR+ mulH <- recall mulHelper+ letH <- recall letHelper sInduct "envShadow" (\(Forall @"e" (e :: SE)) (Forall @"pfx" (pfx :: E)) (Forall @"env" (env :: E))@@ -717,7 +749,8 @@ -- -- >>> runTP varHelper -- Lemma: varHelper Q.E.D.--- [Proven] varHelper :: Ɐenv ∷ [([Char], Integer)] → Ɐnm ∷ [Char] → Bool+-- Functions proven terminating: interpInEnv, sbv.lookup+-- [Proven] varHelper :: Ɐenv ∷ [(String, Integer)] → Ɐnm ∷ String → Bool varHelper :: TP (Proof (Forall "env" EL -> Forall "nm" String -> SBool)) varHelper = lemma "varHelper" (\(Forall @"env" (env :: E)) (Forall @"nm" nm) ->@@ -784,20 +817,21 @@ -- Step: 1.7.2.Completeness Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] substCorrect :: Ɐe ∷ (Expr [Char] Integer) → Ɐnm ∷ [Char] → Ɐv ∷ Integer → Ɐenv ∷ [([Char], Integer)] → Bool+-- Functions proven terminating: exprSize, interpInEnv, sbv.lookup, subst+-- [Proven] substCorrect :: Ɐe ∷ (Expr String Integer) → Ɐnm ∷ String → Ɐv ∷ Integer → Ɐenv ∷ [(String, Integer)] → Bool substCorrect :: TP (Proof (Forall "e" Exp -> Forall "nm" String -> Forall "v" Integer -> Forall "env" EL -> SBool)) substCorrect = do- mnn <- recall "measureNonNeg" measureNonNeg- sqrC <- recall "sqrCong" sqrCong- sqrH <- recall "sqrHelper" sqrHelper- addH <- recall "addHelper" addHelper- mulCL <- recall "mulCongL" mulCongL- mulCR <- recall "mulCongR" mulCongR- mulH <- recall "mulHelper" mulHelper- letH <- recall "letHelper" letHelper- varH <- recall "varHelper" varHelper- eSwp <- recall "envSwap" envSwap- eShd <- recall "envShadow" envShadow+ mnn <- recall measureNonNeg+ sqrC <- recall sqrCong+ sqrH <- recall sqrHelper+ addH <- recall addHelper+ mulCL <- recall mulCongL+ mulCR <- recall mulCongR+ mulH <- recall mulHelper+ letH <- recall letHelper+ varH <- recall varHelper+ eSwp <- recall envSwap+ eShd <- recall envShadow sInduct "substCorrect" (\(Forall @"e" (e :: SE)) (Forall @"nm" (nm :: SString)) (Forall @"v" (v :: SInteger)) (Forall @"env" (env :: E)) ->@@ -1057,22 +1091,23 @@ -- Step: 1.7.2.Completeness Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] simpCorrect :: Ɐe ∷ (Expr [Char] Integer) → Ɐenv ∷ [([Char], Integer)] → Bool+-- Functions proven terminating: exprSize, interpInEnv, sbv.lookup, simplify, subst+-- [Proven] simpCorrect :: Ɐe ∷ (Expr String Integer) → Ɐenv ∷ [(String, Integer)] → Bool simpCorrect :: TP (Proof (Forall "e" Exp -> Forall "env" EL -> SBool)) simpCorrect = do- sqrC <- recall "sqrCong" sqrCong- sqrH <- recall "sqrHelper" sqrHelper- addH <- recall "addHelper" addHelper- mulCL <- recall "mulCongL" mulCongL- mulCR <- recall "mulCongR" mulCongR- mulH <- recall "mulHelper" mulHelper- letH <- recall "letHelper" letHelper- subC <- recall "substCorrect" substCorrect+ sqrC <- recall sqrCong+ sqrH <- recall sqrHelper+ addH <- recall addHelper+ mulCL <- recall mulCongL+ mulCR <- recall mulCongR+ mulH <- recall mulHelper+ letH <- recall letHelper+ subC <- recall substCorrect calc "simpCorrect" (\(Forall @"e" (e :: SE)) (Forall @"env" (env :: E)) -> interpInEnv env (simplify e) .== interpInEnv env e) $ \e env -> []- |- [pCase|Expr e of+ |- [pCase| e of Var nm -> interpInEnv env (simplify e) ?? "Var" =: interpInEnv env (simplify (sVar nm))@@ -1336,11 +1371,11 @@ -- >>> runTPWith cvc5 cfoldCorrect -- Lemma: measureNonNeg Q.E.D. -- Lemma: simpCorrect Q.E.D.--- Lemma: sqrCong Q.E.D.--- Lemma: sqrHelper Q.E.D.--- Lemma: mulCongL Q.E.D.--- Lemma: mulCongR Q.E.D.--- Lemma: mulHelper Q.E.D.+-- Cached: sqrCong Q.E.D.+-- Cached: sqrHelper Q.E.D.+-- Cached: mulCongL Q.E.D.+-- Cached: mulCongR Q.E.D.+-- Cached: mulHelper Q.E.D. -- Inductive lemma (strong): cfoldCorrect -- Step: Measure is non-negative Q.E.D. -- Step: 1 (7 way case split)@@ -1382,22 +1417,23 @@ -- Step: 1.7.5 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven] cfoldCorrect :: Ɐe ∷ (Expr [Char] Integer) → Ɐenv ∷ [([Char], Integer)] → Bool+-- Functions proven terminating: cfold, exprSize, interpInEnv, sbv.lookup, simplify, subst+-- [Proven] cfoldCorrect :: Ɐe ∷ (Expr String Integer) → Ɐenv ∷ [(String, Integer)] → Bool cfoldCorrect :: TP (Proof (Forall "e" Exp -> Forall "env" EL -> SBool)) cfoldCorrect = do- mnn <- recall "measureNonNeg" measureNonNeg- sc <- recall "simpCorrect" simpCorrect- sqrC <- recall "sqrCong" sqrCong- sqrH <- recall "sqrHelper" sqrHelper- mulCL <- recall "mulCongL" mulCongL- mulCR <- recall "mulCongR" mulCongR- mulH <- recall "mulHelper" mulHelper+ mnn <- recall measureNonNeg+ sc <- recall simpCorrect+ sqrC <- recall sqrCong+ sqrH <- recall sqrHelper+ mulCL <- recall mulCongL+ mulCR <- recall mulCongR+ mulH <- recall mulHelper sInduct "cfoldCorrect" (\(Forall @"e" (e :: SE)) (Forall @"env" (env :: E)) -> interpInEnv env (cfold e) .== interpInEnv env e) (\e _ -> size e, [proofOf mnn]) $ \ih e env -> []- |- [pCase|Expr e of+ |- [pCase| e of Var nm -> interpInEnv env (cfold e) ?? "case Var" =: interpInEnv env (cfold (sVar nm))
+ Documentation/SBV/Examples/TP/Countdown.hs view
@@ -0,0 +1,135 @@+-----------------------------------------------------------------------------+-- |+-- Module : Documentation.SBV.Examples.TP.Countdown+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer: erkokl@gmail.com+-- Stability : experimental+--+-- Proving properties of a countdown function that builds a list+-- from @n@ down to @0@.+-----------------------------------------------------------------------------++{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror #-}++module Documentation.SBV.Examples.TP.Countdown where++import Prelude hiding (head, length, (!!))++import Data.SBV+import Data.SBV.List+import Data.SBV.TP++#ifdef DOCTEST+-- $setup+-- >>> import Data.SBV.TP+#endif++-- * Definitions++-- | A function that counts down from @n@ to @0@, building a list.+countdown :: SInteger -> SList Integer+countdown = smtFunction "countdown"+ $ \n -> [sCase| n of+ v | v .<= 0 -> singleton 0+ | True -> v .: countdown (v - 1)+ |]++-- * Correctness++-- | Prove that @countdown n@ always starts with @n@, for positive @n@.+--+-- >>> runTP countdownHead+-- Lemma: countdownHead Q.E.D.+-- Functions proven terminating: countdown+-- [Proven] countdownHead :: Ɐn ∷ Integer → Bool+countdownHead :: TP (Proof (Forall "n" Integer -> SBool))+countdownHead = lemma "countdownHead" (\(Forall @"n" n) -> n .> 0 .=> head (countdown n) .== n) []++-- | Prove by induction that @countdown n@ is never empty.+--+-- >>> runTP countdownNonEmpty+-- Inductive lemma: countdownNonEmpty+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: countdown+-- [Proven] countdownNonEmpty :: Ɐn ∷ Integer → Bool+countdownNonEmpty :: TP (Proof (Forall "n" Integer -> SBool))+countdownNonEmpty =+ induct "countdownNonEmpty"+ (\(Forall @"n" n) -> n .>= 0 .=> length (countdown n) .> 0) $+ \ih n -> [n .>= 0] |- length (countdown (n + 1))+ =: length ((n + 1) .: countdown n)+ ?? ih+ =: 1 + length (countdown n)+ =: qed++-- | Prove by induction that @countdown n@ has length @n + 1@.+--+-- >>> runTP countdownLen+-- Inductive lemma: countdownLen+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Step: 3 Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: countdown+-- [Proven] countdownLen :: Ɐn ∷ Integer → Bool+countdownLen :: TP (Proof (Forall "n" Integer -> SBool))+countdownLen =+ induct "countdownLen"+ (\(Forall @"n" n) -> n .>= 0 .=> length (countdown n) .== n + 1) $+ \ih n -> [n .>= 0] |- length (countdown (n + 1))+ =: length ((n + 1) .: countdown n)+ =: 1 + length (countdown n)+ ?? ih+ =: n + 2+ =: qed++-- | Prove by induction that the @k@-th element of @countdown n@ is @n - k@.+--+-- The key subtlety is that the 'induct' Result step only has access to the calc chain+-- equalities, not to the helper proofs (which live inside each step's assertion stack).+-- The Result step must prove @P(n+1, k)@ for all valid @k@, i.e., @0 <= k <= n+1@.+-- If the intros only cover @k <= n@, the Result step has no information for @k = n+1@+-- and hangs. The fix is to use intros @[n >= 0, 0 <= k, k <= n+1]@ so the calc chain+-- covers the entire domain of the goal.+--+-- >>> runTP countdownElem+-- Lemma: countdownLen Q.E.D.+-- Lemma: elemOne Q.E.D.+-- Inductive lemma: countdownElem+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: countdown+-- [Proven] countdownElem :: Ɐn ∷ Integer → Ɐk ∷ Integer → Bool+countdownElem :: TP (Proof (Forall "n" Integer -> Forall "k" Integer -> SBool))+countdownElem = do+ cLen <- recall countdownLen++ -- NB. The precondition uses (<=) not (<): this is important so the lemma covers+ -- k = length y (the last valid index of x .: y), not just k < length y.+ elemOne <- lemma "elemOne" (\(Forall @"x" (x :: SInteger)) (Forall @"y" y) (Forall @"k" k) ->+ k .> 0 .&& k .<= length y .=> (x .: y) !! k .== y !! (k - 1)) []++ induct "countdownElem"+ (\(Forall @"n" n) (Forall @"k" k) -> 0 .<= k .&& k .<= n .=> countdown n !! k .== n - k) $+ \ih n k -> [n .>= 0, 0 .<= k, k .<= n + 1]+ |- countdown (n + 1) !! k+ =: ((n + 1) .: countdown n) !! k+ ?? elemOne+ ?? cLen+ ?? ih `at` Inst @"k" (k - 1)+ =: n + 1 - k+ =: qed
Documentation/SBV/Examples/TP/Fibonacci.hs view
@@ -11,6 +11,7 @@ ----------------------------------------------------------------------------- {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeApplications #-} {-# OPTIONS_GHC -Wall -Werror #-}@@ -24,13 +25,19 @@ -- | Calculate fibonacci using the textbook definition. fibonacci :: SInteger -> SInteger-fibonacci = smtFunction "fibonacci" $ \n -> ite (n .<= 1) 1 (fibonacci (n-1) + fibonacci (n-2))+fibonacci = smtFunction "fibonacci" $ \n -> [sCase| n of+ _ | n .<= 1 -> 1+ _ -> fibonacci (n-1) + fibonacci (n-2)+ |] -- * Tail recursive version -- | Tail recursive version fib :: SInteger -> SInteger -> SInteger -> SInteger-fib = smtFunction "fib" $ \a b n -> ite (n .<= 0) a (fib b (a+b) (n-1))+fib = smtFunction "fib" $ \a b n -> [sCase| n of+ _ | n .<= 0 -> a+ _ -> fib b (a+b) (n-1)+ |] -- | Faster version of fibonacci, using the tail-recursive version. fibTail :: SInteger -> SInteger@@ -53,6 +60,7 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: fib, fibonacci -- [Proven] fibCorrect :: Ɐn ∷ Integer → Bool correctness :: IO (Proof (Forall "n" Integer -> SBool)) correctness = runTP $ do
Documentation/SBV/Examples/TP/GCD.hs view
@@ -16,6 +16,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} @@ -45,7 +46,10 @@ -- there is no greatest common divisor for the pair @(0, 0)@. So, maximality here is meant -- to be in terms of divisibility. That is, any divisor of @a@ and @b@ will also divide their @gcd@. nGCD :: SInteger -> SInteger -> SInteger-nGCD = smtFunction "nGCD" $ \a b -> ite (b .== 0) a (nGCD b (a `sEMod` b))+nGCD = smtFunction "nGCD" $ \a b -> [sCase| b of+ _ | b .== 0 -> a+ _ -> nGCD b (a `sEMod` b)+ |] -- | Generalized GCD, working for all integers. We simply call @nGCD@ with the absolute value of the arguments. gcd :: SInteger -> SInteger -> SInteger@@ -66,6 +70,7 @@ -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: nonNegative Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] nonNegative :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdNonNegative :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdNonNegative = do@@ -99,6 +104,7 @@ -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: gcdZero Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdZero :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdZero :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdZero = do@@ -132,6 +138,7 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] commutative :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool commutative :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) commutative = do@@ -160,6 +167,7 @@ -- ==== __Proof__ -- >>> runTP negGCD -- Lemma: negGCD Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] negGCD :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool negGCD :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) negGCD = lemma "negGCD" (\(Forall a) (Forall b) -> let g = gcd a b in gcd (-a) b .== g .&& g .== gcd a (-b)) []@@ -169,6 +177,7 @@ -- ==== __Proof__ -- >>> runTP zeroGCD -- Lemma: negGCD Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] negGCD :: Ɐa ∷ Integer → Bool zeroGCD :: TP (Proof (Forall "a" Integer -> SBool)) zeroGCD = lemma "negGCD" (\(Forall a) -> gcd a 0 .== gcd 0 a .&& gcd 0 a .== abs a .&& gcd 0 0 .== 0) []@@ -189,14 +198,43 @@ dvd :: SInteger -> SInteger -> SBool a `dvd` b = ite (a .== 0) (b .== 0) (b `sEMod` a .== 0) +-- | \(d \mid a \implies d \mid ka\)+--+-- ==== __Proof__+-- >>> runTP dvdMul+-- Lemma: dvdMul+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2.1 Q.E.D.+-- Step: 1.2.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D.+-- [Proven] dvdMul :: Ɐd ∷ Integer → Ɐa ∷ Integer → Ɐk ∷ Integer → Bool+dvdMul :: TP (Proof (Forall "d" Integer -> Forall "a" Integer -> Forall "k" Integer -> SBool))+dvdMul = calc "dvdMul"+ (\(Forall d) (Forall a) (Forall k) -> d `dvd` a .=> d `dvd` (k*a)) $+ \d a k -> [d `dvd` a]+ |- cases [ d .== 0 ==> d `dvd` (k*a)+ ?? a .== 0+ =: sTrue+ =: qed+ , d ./= 0 ==> d `dvd` (k*a)+ =: (k*a) `sEMod` d .== 0+ ?? a .== d * a `sEDiv` d+ ?? k * a .== d * (k * a `sEDiv` d)+ ?? (d * (k * a `sEDiv` d)) `sEMod` d .== 0+ =: sTrue+ =: qed+ ]+ -- | \(a \mid |b| \iff a \mid b\) ----- A number divides another exactly when it also divides its absolute value. While this property--- seems obvious, I was unable to get z3 to prove it. Even CVC5 needs a bit of help to guide it through--- the case split on @b@.+-- A number divides another exactly when it also divides its absolute value. This follows+-- from 'dvdMul', as both directions are an instance of multiplying by @-1@. -- -- ==== __Proof__ -- >>> runTP dvdAbs+-- Lemma: dvdMul Q.E.D. -- Lemma: dvdAbs_l2r -- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D.@@ -213,53 +251,36 @@ -- [Proven] dvdAbs :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool dvdAbs :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) dvdAbs = do- l2r <- calcWith cvc5 "dvdAbs_l2r"- (\(Forall @"a" a) (Forall @"b" b) -> a `dvd` abs b .=> a `dvd` b) $- \a b -> [a `dvd` abs b]- |- cases [ b .< 0 ==> sTrue =: qed- , b .>= 0 ==> sTrue =: qed- ]+ dM <- recall dvdMul - r2l <- calcWith cvc5 "dvdAbs_r2l"- (\(Forall @"a" a) (Forall @"b" b) -> a `dvd` b .=> a `dvd` abs b) $- \a b -> [a `dvd` b]- |- cases [ b .< 0 ==> sTrue =: qed- , b .>= 0 ==> sTrue =: qed- ]+ l2r <- calc "dvdAbs_l2r"+ (\(Forall @"a" a) (Forall @"b" b) -> a `dvd` abs b .=> a `dvd` b) $+ \a b -> [a `dvd` abs b]+ |- cases [ b .>= 0 ==> a `dvd` b+ =: sTrue+ =: qed+ , b .< 0 ==> a `dvd` b+ ?? dM `at` (Inst @"d" a, Inst @"a" (abs b), Inst @"k" (-1))+ =: sTrue+ =: qed+ ] + r2l <- calc "dvdAbs_r2l"+ (\(Forall @"a" a) (Forall @"b" b) -> a `dvd` b .=> a `dvd` abs b) $+ \a b -> [a `dvd` b]+ |- cases [ b .>= 0 ==> a `dvd` abs b+ =: sTrue+ =: qed+ , b .< 0 ==> a `dvd` abs b+ ?? dM `at` (Inst @"d" a, Inst @"a" b, Inst @"k" (-1))+ =: sTrue+ =: qed+ ]+ lemma "dvdAbs" (\(Forall @"a" a) (Forall @"b" b) -> a `dvd` b .== a `dvd` abs b) [proofOf l2r, proofOf r2l] --- | \(d \mid a \implies d \mid ka\)------ ==== __Proof__--- >>> runTP dvdMul--- Lemma: dvdMul--- Step: 1 (2 way case split)--- Step: 1.1 Q.E.D.--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2 Q.E.D.--- Step: 1.2.3 Q.E.D.--- Step: 1.Completeness Q.E.D.--- Result: Q.E.D.--- [Proven] dvdMul :: Ɐd ∷ Integer → Ɐa ∷ Integer → Ɐk ∷ Integer → Bool-dvdMul :: TP (Proof (Forall "d" Integer -> Forall "a" Integer -> Forall "k" Integer -> SBool))-dvdMul = calc "dvdMul"- (\(Forall d) (Forall a) (Forall k) -> d `dvd` a .=> d `dvd` (k*a)) $- \d a k -> [d `dvd` a]- |- cases [ d .== 0 ==> d `dvd` (k*a)- ?? a .== 0- =: sTrue- =: qed- , d ./= 0 ==> d `dvd` (k*a)- ?? a .== d * a `sEDiv` d- =: d `dvd` ((d * a `sEDiv` d) * k)- =: d `dvd` (d * ((a `sEDiv` d) * k))- =: sTrue- =: qed- ]- -- | \(d \mid (2a + 1) \implies \mathrm{isOdd}(d)\) -- -- ==== __Proof__@@ -406,11 +427,12 @@ -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: gcdDivides Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdDivides :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdDivides :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdDivides = do - dAbs <- recall "dvdAbs" dvdAbs+ dAbs <- recall dvdAbs -- Helper about divisibility. If x|b and x| a%b, then x|a. helper <- calc "helper"@@ -453,7 +475,7 @@ -- ==== __Proof__ -- >>> runTP gcdMaximal -- Lemma: dvdAbs Q.E.D.--- Lemma: gcdComm Q.E.D.+-- Lemma: commutative Q.E.D. -- Lemma: eDiv Q.E.D. -- Lemma: helper -- Step: 1 (x `dvd` a && x `dvd` b) Q.E.D.@@ -478,12 +500,13 @@ -- Step: 1.2.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdMaximal :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐx ∷ Integer → Bool gcdMaximal :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> Forall "x" Integer -> SBool)) gcdMaximal = do - dAbs <- recall "dvdAbs" dvdAbs- comm <- recall "gcdComm" commutative+ dAbs <- recall dvdAbs+ comm <- recall commutative eDiv <- lemma "eDiv" (\(Forall @"x" x) (Forall @"y" y) -> y ./= 0 .=> x .== (x `sEDiv` y) * y + x `sEMod` y)@@ -557,11 +580,12 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdCorrect :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdCorrect :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdCorrect = do- divides <- recall "gcdDivides" gcdDivides- maximal <- recall "gcdMaximal" gcdMaximal+ divides <- recall gcdDivides+ maximal <- recall gcdMaximal calc "gcdCorrect" (\(Forall a) (Forall b) ->@@ -591,17 +615,18 @@ -- >>> runTP gcdLargest -- Lemma: gcdMaximal Q.E.D. -- Lemma: gcdZero Q.E.D.--- Lemma: gcdNonNegative Q.E.D.+-- Lemma: nonNegative Q.E.D. -- Lemma: gcdLargest -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdLargest :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐx ∷ Integer → Bool gcdLargest :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> Forall "x" Integer -> SBool)) gcdLargest = do- maximal <- recall "gcdMaximal" gcdMaximal- zero <- recall "gcdZero" gcdZero- nn <- recall "gcdNonNegative" gcdNonNegative+ maximal <- recall gcdMaximal+ gcdZ <- recall gcdZero+ nn <- recall gcdNonNegative calc "gcdLargest" (\(Forall a) (Forall b) (Forall x) -> (a ./= 0 .|| b ./= 0) .&& x `dvd` a .&& x `dvd` b .=> x .<= gcd a b) $@@ -609,7 +634,7 @@ |- x .<= gcd a b ?? maximal `at` (Inst @"a" a, Inst @"b" b, Inst @"x" x) =: (x `dvd` gcd a b .=> x .<= gcd a b)- ?? zero `at` (Inst @"a" a, Inst @"b" b)+ ?? gcdZ `at` (Inst @"a" a, Inst @"b" b) ?? nn `at` (Inst @"a" a, Inst @"b" b) =: sTrue =: qed@@ -633,14 +658,15 @@ -- Step: 6 Q.E.D. -- Step: 7 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdAdd :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdAdd :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdAdd = do - dSum1 <- recall "dvdSum1" dvdSum1- dSum2 <- recall "dvdSum2" dvdSum2- divides <- recall "gcdDivides" gcdDivides- largest <- recall "gcdLargest" gcdLargest+ dSum1 <- recall dvdSum1+ dSum2 <- recall dvdSum2+ divides <- recall gcdDivides+ largest <- recall gcdLargest calc "gcdAdd" (\(Forall @"a" a) (Forall @"b" b) -> gcd a b .== gcd (a + b) b) $@@ -679,13 +705,12 @@ -- | \(\gcd\, (2a)\, (2b) = 2 (\gcd\,a\, b)\) -- -- ==== __Proof__--- >>> runTPWith cvc5 gcdEvenEven+-- >>> runTP gcdEvenEven -- Lemma: red2 Q.E.D. -- Lemma: modEE -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D.--- Step: 4 Q.E.D. -- Result: Q.E.D. -- Inductive lemma (strong): nGCDEvenEven -- Step: Measure is non-negative Q.E.D.@@ -703,19 +728,19 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdEvenEven :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdEvenEven :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdEvenEven = do - red2 <- lemma "red2"+ red2 <- lemmaWith z3 "red2" (\(Forall @"a" a) (Forall @"b" b) -> b ./= 0 .=> (2*a) `sEDiv` (2*b) .== a `sEDiv` b) [] - modEE <- calc "modEE"+ modEE <- calcWith cvc5 "modEE" (\(Forall @"a" a) (Forall @"b" b) -> b ./= 0 .=> (2*a) `sEMod` (2*b) .== 2 * (a `sEMod` b)) $ \a b -> [b ./= 0] |- (2*a) `sEMod` (2*b)- =: 2*a - 2*b * ((2*a) `sEDiv` (2*b)) ?? red2 `at` (Inst @"a" a, Inst @"b" b) =: 2*a - 2*b * (a `sEDiv` b) =: 2 * (a - b * (a `sEDiv` b))@@ -753,7 +778,7 @@ -- >>> runTP gcdOddEven -- Lemma: gcdDivides Q.E.D. -- Lemma: gcdLargest Q.E.D.--- Lemma: dvdMul Q.E.D.+-- Cached: dvdMul Q.E.D. -- Lemma: dvdOddThenOdd Q.E.D. -- Lemma: dvdEvenWhenOdd Q.E.D. -- Lemma: gcdOddEven@@ -766,15 +791,16 @@ -- Step: 7 Q.E.D. -- Step: 8 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD -- [Proven] gcdOddEven :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdOddEven :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdOddEven = do - divides <- recall "gcdDivides" gcdDivides- largest <- recall "gcdLargest" gcdLargest- dMul <- recall "dvdMul" dvdMul- dOddThenOdd <- recall "dvdOddThenOdd" dvdOddThenOdd- dEvenWhenOdd <- recall "dvdEvenWhenOdd" dvdEvenWhenOdd+ divides <- recall gcdDivides+ largest <- recall gcdLargest+ dMul <- recall dvdMul+ dOddThenOdd <- recall dvdOddThenOdd+ dEvenWhenOdd <- recall dvdEvenWhenOdd calc "gcdOddEven" (\(Forall a) (Forall b) -> gcd (2*a+1) (2*b) .== gcd (2*a+1) b) $@@ -820,11 +846,14 @@ -- works on non-negative numbers. It has the precondition that @a >= b >= 0@, and maintains this invariant in each -- recursive call. nGCDSub :: SInteger -> SInteger -> SInteger-nGCDSub = smtFunction "nGCDSub" $ \a b -> ite (a .== b) a- $ ite (a .== 0) b- $ ite (b .== 0) a- $ ite (a .> b) (nGCDSub (a - b) b)- (nGCDSub a (b - a))+nGCDSub = smtFunction "nGCDSub"+ $ \a b -> [sCase| a of+ _ | a .== b -> a+ _ | a .<= 0 -> b+ _ | b .<= 0 -> a+ _ | a .> b -> nGCDSub (a - b) b+ _ -> nGCDSub a (b - a)+ |] -- | Generalized version of subtraction based GCD, working over all integers. gcdSub :: SInteger -> SInteger -> SInteger@@ -860,13 +889,14 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD, nGCDSub -- [Proven] gcdSubEquiv :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdSubEquiv :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdSubEquiv = do -- We'll be using the commutativity of GCD and the gcdAdd property- comm <- recall "commutative" commutative- addG <- recall "gcdAdd" gcdAdd+ comm <- recall commutative+ addG <- recall gcdAdd -- First prove over the non-negative numbers: nEq <- sInduct "nGCDSubEquiv"@@ -909,12 +939,15 @@ -- | @nGCDBin@ is the binary GCD algorithm that works on non-negative numbers. nGCDBin :: SInteger -> SInteger -> SInteger-nGCDBin = smtFunction "nGCDBin" $ \a b -> ite (a .== 0) b- $ ite (b .== 0) a- $ ite (isEven a .&& isEven b) (2 * nGCDBin (a `sEDiv` 2) (b `sEDiv` 2))- $ ite (isOdd a .&& isEven b) ( nGCDBin a (b `sEDiv` 2))- $ ite (a .<= b) ( nGCDBin a (b - a))- ( nGCDBin (a - b) b)+nGCDBin = smtFunction "nGCDBin"+ $ \a b -> [sCase| a of+ _ | a .<= 0 -> b+ _ | b .<= 0 -> a+ _ | isEven a .&& isEven b -> 2 * nGCDBin (a `sEDiv` 2) (b `sEDiv` 2)+ _ | isOdd a .&& isEven b -> nGCDBin a (b `sEDiv` 2)+ _ | a .<= b -> nGCDBin a (b - a)+ _ -> nGCDBin (a - b) b+ |] -- | Generalized version that works on arbitrary integers. gcdBin :: SInteger -> SInteger -> SInteger gcdBin a b = nGCDBin (abs a) (abs b)@@ -929,7 +962,7 @@ -- Lemma: gcdEvenEven Q.E.D. -- Lemma: gcdOddEven Q.E.D. -- Lemma: gcdAdd Q.E.D.--- Lemma: commutative Q.E.D.+-- Cached: commutative Q.E.D. -- Inductive lemma (strong): nGCDBinEquiv -- Step: Measure is non-negative Q.E.D. -- Step: 1 (5 way case split)@@ -961,13 +994,14 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: nGCD, nGCDBin -- [Proven] gcdBinEquiv :: Ɐa ∷ Integer → Ɐb ∷ Integer → Bool gcdBinEquiv :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> SBool)) gcdBinEquiv = do- gEvenEven <- recallWith cvc5 "gcdEvenEven" gcdEvenEven- gOddEven <- recall "gcdOddEven" gcdOddEven- gAdd <- recall "gcdAdd" gcdAdd- comm <- recall "commutative" commutative+ gEvenEven <- recallWith cvc5 gcdEvenEven+ gOddEven <- recall gcdOddEven+ gAdd <- recall gcdAdd+ comm <- recall commutative -- First prove over the non-negative numbers: nEq <- sInduct "nGCDBinEquiv"
Documentation/SBV/Examples/TP/InsertionSort.hs view
@@ -13,6 +13,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-}@@ -38,31 +39,39 @@ -- | Insert an element into an already sorted list in the correct place. insert :: (OrdSymbolic (SBV a), SymVal a) => SBV a -> SList a -> SList a-insert = smtFunction "insert" $ \e l -> ite (null l) [e]- $ let (x, xs) = uncons l- in ite (e .<= x) (e .: x .: xs) (x .: insert e xs)+insert = smtFunction "insert"+ $ \e l -> [sCase| l of+ [] -> [e]+ x : xs | e .<= x -> e .: x .: xs+ | True -> x .: insert e xs+ |] -- | Insertion sort, using 'insert' above to successively insert the elements. insertionSort :: (OrdSymbolic (SBV a), SymVal a) => SList a -> SList a-insertionSort = smtFunction "insertionSort" $ \l -> ite (null l) []- $ let (x, xs) = uncons l- in insert x (insertionSort xs)+insertionSort = smtFunction "insertionSort"+ $ \l -> [sCase| l of+ [] -> []+ x : xs -> insert x (insertionSort xs)+ |] -- | Remove the first occurrence of an number from a list, if any. removeFirst :: (Eq a, SymVal a) => SBV a -> SList a -> SList a-removeFirst = smtFunction "removeFirst" $ \e l -> ite (null l)- []- (let (x, xs) = uncons l- in ite (e .== x) xs (x .: removeFirst e xs))+removeFirst = smtFunction "removeFirst"+ $ \e l -> [sCase| l of+ [] -> []+ x : xs | e .== x -> xs+ | True -> x .: removeFirst e xs+ |] -- | Are two lists permutations of each other? Note that we diverge from the counting -- based definition of permutation here, since this variant works better with insertion sort. isPermutation :: (Eq a, SymVal a) => SList a -> SList a -> SBool-isPermutation = smtFunction "isPermutation" $ \l r -> ite (null l)- (null r)- (let (x, xs) = uncons l- in x `elem` r .&& isPermutation xs (removeFirst x r))+isPermutation = smtFunction "isPermutation"+ $ \l r -> [sCase| l of+ [] -> null r+ x : xs -> x `elem` r .&& isPermutation xs (removeFirst x r)+ |] -- * Correctness proof @@ -110,6 +119,7 @@ -- Step: 5 Q.E.D. -- Result: Q.E.D. -- Lemma: insertionSortIsCorrect Q.E.D.+-- Functions proven terminating: insert, insertionSort, isPermutation, nonDecreasing, removeFirst -- [Proven] insertionSortIsCorrect :: Ɐxs ∷ [Integer] → Bool correctness :: forall a. (OrdSymbolic (SBV a), Eq a, SymVal a) => IO (Proof (Forall "xs" [a] -> SBool)) correctness = runTPWith (tpRibbon 45 cvc5) $ do
Documentation/SBV/Examples/TP/Kadane.hs view
@@ -18,6 +18,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -28,7 +29,6 @@ import Prelude hiding (length, maximum, null, head, tail, (++)) import Data.SBV-import Data.SBV.List import Data.SBV.TP #ifdef DOCTEST@@ -56,7 +56,11 @@ -- >>> mss [1, 2, 3] -- the whole list -- 6 :: SInteger mss :: SList Integer -> SInteger-mss = smtFunction "mss" $ \xs -> ite (null xs) 0 (mssBegin xs `smax` mss (tail xs))+mss = smtFunction "mss"+ $ \xs -> [sCase| xs of+ [] -> 0+ _ : t -> mssBegin xs `smax` mss t+ |] -- | Maximum sum of segments starting at the beginning of the given list. -- This is 0 if the empty segment is best, or positive if a non-empty prefix exists.@@ -70,9 +74,11 @@ -- >>> mssBegin [1, 2, 3] -- the whole list -- 6 :: SInteger mssBegin :: SList Integer -> SInteger-mssBegin = smtFunction "mssBegin" $ \xs -> ite (null xs) 0- $ let (h, t) = uncons xs- in 0 `smax` (h `smax` (h + mssBegin t))+mssBegin = smtFunction "mssBegin"+ $ \xs -> [sCase| xs of+ [] -> 0+ h : t -> 0 `smax` (h `smax` (h + mssBegin t))+ |] -- * Kadane's algorithm implementation @@ -91,13 +97,14 @@ -- | Helper for Kadane's algorithm. Along with the list, we keep track of the maximum-value -- ending at the beginning of the list argument, and the maximum value sofar. kadaneHelper :: SList Integer -> SInteger -> SInteger -> SInteger-kadaneHelper = smtFunction "kadaneHelper" $ \xs maxEndingHere maxSoFar ->- ite (null xs)- maxSoFar -- end of the list, take the max-value calculated- $ let (h, t) = uncons xs- newMaxEndingHere = 0 `smax` (h + maxEndingHere) -- We can add head to the so far, or restart- newMaxSofar = maxSoFar `smax` newMaxEndingHere -- Maximum of result so far, and the new- in kadaneHelper t newMaxEndingHere newMaxSofar+kadaneHelper = smtFunction "kadaneHelper"+ $ \xs maxEndingHere maxSoFar ->+ [sCase| xs of+ [] -> maxSoFar+ h : t -> let newMaxEndingHere = 0 `smax` (h + maxEndingHere)+ newMaxSofar = maxSoFar `smax` newMaxEndingHere+ in kadaneHelper t newMaxEndingHere newMaxSofar+ |] -- * Correctness proof @@ -132,6 +139,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: kadaneHelper, mss, mssBegin -- [Proven] correctness :: Ɐxs ∷ [Integer] → Bool correctness :: TP (Proof (Forall "xs" [Integer] -> SBool)) correctness = do
Documentation/SBV/Examples/TP/Lists.hs view
@@ -67,7 +67,7 @@ , map_snd_zip_take -- * Counting elements- , count, countAppend, takeDropCount, countNonNeg, countElem, elemCount+ , count, countOneStep, countAppend, takeDropCount, countNonNeg, countElem, elemCount -- * Disjointness , disjoint, disjointDiff@@ -134,6 +134,7 @@ -- Step: Measure is non-negative Q.E.D. -- Step: 1 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.inits -- [Proven] initsLength :: Ɐxs ∷ [Integer] → Bool initsLength :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> SBool)) initsLength =@@ -155,6 +156,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.tails -- [Proven] tailsLength :: Ɐxs ∷ [Integer] → Bool tailsLength :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> SBool)) tailsLength =@@ -194,6 +196,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.closureMap, sbv.tails -- [Proven] tailsAppend :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool tailsAppend :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) tailsAppend = do@@ -250,6 +253,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.reverse -- [Proven] revLen :: Ɐxs ∷ [Integer] → Bool revLen :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> SBool)) revLen = induct "revLen"@@ -273,6 +277,7 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.reverse -- [Proven] revApp :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool revApp :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) revApp = induct "revApp"@@ -290,6 +295,7 @@ -- -- >>> runTP $ revCons @Integer -- Lemma: revCons Q.E.D.+-- Functions proven terminating: sbv.reverse -- [Proven] revCons :: Ɐx ∷ Integer → Ɐxs ∷ [Integer] → Bool revCons :: forall a. SymVal a => TP (Proof (Forall "x" a -> Forall "xs" [a] -> SBool)) revCons = lemma "revCons"@@ -308,6 +314,7 @@ -- Step: 5 Q.E.D. -- Result: Q.E.D. -- Lemma: revSnoc Q.E.D.+-- Functions proven terminating: sbv.reverse -- [Proven] revSnoc :: Ɐx ∷ Integer → Ɐxs ∷ [Integer] → Bool revSnoc :: forall a. SymVal a => TP (Proof (Forall "x" a -> Forall "xs" [a] -> SBool)) revSnoc = do@@ -335,6 +342,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.reverse -- [Proven] revRev :: Ɐxs ∷ [Integer] → Bool revRev :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> SBool)) revRev = do@@ -367,6 +375,7 @@ -- Step: 1.2.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: EnumSymbolic.Integer.enumFromThenTo.down, EnumSymbolic.Integer.enumFromThenTo.up -- [Proven] enumLen :: Ɐn ∷ Integer → Ɐm ∷ Integer → Bool enumLen :: TP (Proof (Forall "n" Integer -> Forall "m" Integer -> SBool)) enumLen =@@ -404,6 +413,8 @@ -- Step: 1.2.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating:+-- EnumSymbolic.Integer.enumFromThenTo.down, EnumSymbolic.Integer.enumFromThenTo.up, sbv.reverse -- [Proven] revNM :: Ɐn ∷ Integer → Ɐm ∷ Integer → Bool revNM :: TP (Proof (Forall "n" Integer -> Forall "m" Integer -> SBool)) revNM = do@@ -476,6 +487,7 @@ -- Step: 1.2.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.replicate -- [Proven] replicateLength :: Ɐk ∷ Integer → Ɐx ∷ Integer → Bool replicateLength :: forall a. SymVal a => TP (Proof (Forall "k" Integer -> Forall "x" a -> SBool)) replicateLength = induct "replicateLength"@@ -502,6 +514,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr -- [Proven] allAny :: Ɐxs ∷ [Bool] → Bool allAny :: TP (Proof (Forall "xs" [Bool] -> SBool)) allAny = induct "allAny"@@ -524,6 +537,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map -- [Proven] mapEquiv :: Ɐxs ∷ [Integer] → Bool mapEquiv :: forall a b. (SymVal a, SymVal b) => (SBV a -> SBV b) -> (SBV a -> SBV b) -> TP (Proof (Forall "xs" [a] -> SBool)) mapEquiv f g = do@@ -551,6 +565,7 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map -- [Proven] mapAppend :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool mapAppend :: forall a b. (SymVal a, SymVal b) => (SBV a -> SBV b) -> TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) mapAppend f =@@ -585,6 +600,7 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map, sbv.reverse -- [Proven] mapReverse :: Ɐxs ∷ [Integer] → Bool mapReverse :: forall a b. (SymVal a, SymVal b) => (SBV a -> SBV b) -> TP (Proof (Forall "xs" [a] -> SBool)) mapReverse f = do@@ -614,6 +630,7 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map -- [Proven] mapCompose :: Ɐxs ∷ [Integer] → Bool mapCompose :: forall a b c. (SymVal a, SymVal b, SymVal c) => (SBV a -> SBV b) -> (SBV b -> SBV c) -> TP (Proof (Forall "xs" [a] -> SBool)) mapCompose f g =@@ -640,10 +657,11 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr, sbv.map -- [Proven] mapConcat :: Ɐxs ∷ [[Integer]] → Bool mapConcat :: (SymVal a, SymVal b) => (SBV a -> SBV b) -> TP (Proof (Forall "xs" [[a]] -> SBool)) mapConcat f = do- ma <- recall "mapAppend" (mapAppend f)+ ma <- recall (mapAppend f) induct "mapConcat" (\(Forall xs) -> map f (concat xs) .== concat (map (map f) xs)) $@@ -667,7 +685,8 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.--- [Proven] foldrMapFusion :: Ɐxs ∷ [[Char]] → Bool+-- Functions proven terminating: sbv.foldr, sbv.map+-- [Proven] foldrMapFusion :: Ɐxs ∷ [String] → Bool foldrMapFusion :: forall a b c. (SymVal a, SymVal b, SymVal c) => SBV c -> (SBV a -> SBV b) -> (SBV b -> SBV c -> SBV c) -> TP (Proof (Forall "xs" [a] -> SBool)) foldrMapFusion a g f = induct "foldrMapFusion"@@ -695,7 +714,8 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.--- [Proven] foldrFusion :: Ɐxs ∷ [[Char]] → Bool+-- Functions proven terminating: sbv.foldr+-- [Proven] foldrFusion :: Ɐxs ∷ [String] → Bool foldrFusion :: forall a b c. (SymVal a, SymVal b, SymVal c) => SBV c -> SBV b -> (SBV c -> SBV b) -> (SBV a -> SBV c -> SBV c) -> (SBV a -> SBV b -> SBV b) -> TP (Proof (Forall "xs" [a] -> SBool)) foldrFusion a b f g h = do let -- Assumptions under which the equality holds@@ -722,6 +742,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr -- [Proven] foldrOverAppend :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool foldrOverAppend :: forall a. SymVal a => SBV a -> (SBV a -> SBV a -> SBV a) -> TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) foldrOverAppend a f =@@ -744,6 +765,7 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldl -- [Proven] foldlOverAppend :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Ɐe ∷ Bool → Bool foldlOverAppend :: forall a b. (SymVal a, SymVal b) => (SBV b -> SBV a -> SBV b) -> TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" b -> SBool)) foldlOverAppend f =@@ -776,7 +798,8 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.--- [Proven] foldrFoldlDuality :: Ɐxs ∷ [Integer] → Ɐe ∷ [Char] → Bool+-- Functions proven terminating: sbv.foldl, sbv.foldr, sbv.reverse+-- [Proven] foldrFoldlDuality :: Ɐxs ∷ [Integer] → Ɐe ∷ String → Bool foldrFoldlDuality :: forall a b. (SymVal a, SymVal b) => (SBV a -> SBV b -> SBV b) -> TP (Proof (Forall "xs" [a] -> Forall "e" b -> SBool)) foldrFoldlDuality f = do foa <- foldlOverAppend (flip f)@@ -827,6 +850,7 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldl, sbv.foldr -- [Proven] foldrFoldlDuality :: Ɐxs ∷ [Integer] → Bool foldrFoldlDualityGeneralized :: forall a. SymVal a => SBV a -> (SBV a -> SBV a -> SBV a) -> TP (Proof (Forall "xs" [a] -> SBool)) foldrFoldlDualityGeneralized e (@) = do@@ -895,6 +919,7 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldl, sbv.foldr -- [Proven] foldrFoldl :: Ɐxs ∷ [Integer] → Bool foldrFoldl :: forall a b. (SymVal a, SymVal b) => (SBV a -> SBV b -> SBV b) -> (SBV b -> SBV a -> SBV b) -> SBV b -> TP (Proof (Forall "xs" [a] -> SBool)) foldrFoldl (<+>) (<*>) e = do@@ -962,6 +987,7 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr, sbv.map -- [Proven] bookKeeping :: Ɐxss ∷ [[Integer]] → Bool -- -- NB. This theorem does not hold if @f@ does not have a left-unit! Consider the input @[[], [x]]@. Left hand side reduces to@@ -1028,6 +1054,7 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.filter -- [Proven] filterAppend :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool filterAppend :: forall a. SymVal a => (SBV a -> SBool) -> TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) filterAppend p =@@ -1059,6 +1086,7 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.filter, sbv.foldr, sbv.map -- [Proven] filterConcat :: Ɐxss ∷ [[Integer]] → Bool filterConcat :: forall a. SymVal a => (SBV a -> SBool) -> TP (Proof (Forall "xss" [[a]] -> SBool)) filterConcat p = do@@ -1086,6 +1114,7 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.dropWhile, sbv.takeWhile -- [Proven] takeDropWhile :: Ɐxs ∷ [Integer] → Bool takeDropWhile :: forall a. SymVal a => (SBV a -> SBool) -> TP (Proof (Forall "xs" [a] -> SBool)) takeDropWhile f =@@ -1102,11 +1131,13 @@ ] -- | Remove adjacent duplicates. destutter :: SymVal a => SList a -> SList a-destutter = smtFunction "destutter" $ \xs -> ite (null xs .|| null (tail xs))- xs- (let (a, as) = uncons xs- r = destutter as- in ite (a .== head as) r (a .: r))+destutter = smtFunction "destutter"+ $ \xs -> [sCase| xs of+ [] -> xs+ [_] -> xs+ a : rest@(b : _) | a .== b -> destutter rest+ | True -> a .: destutter rest+ |] -- | @destutter (destutter xs) == destutter xs@ --@@ -1125,25 +1156,32 @@ -- Result: Q.E.D. -- Inductive lemma (strong): helper3 -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (3 way case split) -- Step: 1.1 Q.E.D.--- Step: 1.2 (2 way full case split)--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2.1 Q.E.D.--- Step: 1.2.2.2 (2 way case split)--- Step: 1.2.2.2.1.1 Q.E.D.--- Step: 1.2.2.2.1.2 Q.E.D.--- Step: 1.2.2.2.2.1 Q.E.D.--- Step: 1.2.2.2.2.2 Q.E.D.--- Step: 1.2.2.2.Completeness Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.3.1 Q.E.D.+-- Step: 1.3.2 (2 way case split)+-- Step: 1.3.2.1.1 Q.E.D.+-- Step: 1.3.2.1.2 Q.E.D.+-- Step: 1.3.2.2.1 Q.E.D.+-- Step: 1.3.2.2.2 Q.E.D.+-- Step: 1.3.2.Completeness Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: destutterIdempotent Q.E.D.+-- Functions proven terminating: destutter, noAdd -- [Proven] destutterIdempotent :: Ɐxs ∷ [Integer] → Bool destutterIdempotent :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> SBool)) destutterIdempotent = do -- No adjacent duplicates- let noAdd = smtFunction "noAdd" $ \xs -> null xs .|| null (tail xs) .|| (head xs ./= head (tail xs) .&& noAdd (tail xs))+ let noAdd = smtFunction "noAdd"+ $ \xs -> [sCase| xs of+ [] -> sTrue+ [_] -> sTrue+ a : rest@(b : _) | a .== b -> sFalse+ | True -> noAdd rest+ |] -- Helper: The head of a destuttered non-empty list does not change helper1 <- induct "helper1"@@ -1172,21 +1210,22 @@ (length, []) $ \ih xs -> [] |- noAdd (destutter xs)- =: split xs- trivial- (\a as -> split as- trivial- (\b bs -> noAdd (destutter (a .: b .: bs))- =: cases [a .== b ==> noAdd (destutter (b .: bs))- ?? ih- =: sTrue- =: qed- , a ./= b ==> noAdd (a .: destutter (b .: bs))- ?? helper1 `at` (Inst @"xs" bs, Inst @"h" b)- ?? ih- =: sTrue- =: qed- ]))+ =: [pCase| xs of+ [] -> trivial+ [_] -> trivial+ whole@(a : rest@(b : bs))+ -> noAdd (destutter whole)+ =: cases [a .== b ==> noAdd (destutter rest)+ ?? ih+ =: sTrue+ =: qed+ , a ./= b ==> noAdd (a .: destutter rest)+ ?? helper1 `at` (Inst @"xs" bs, Inst @"h" b)+ ?? ih+ =: sTrue+ =: qed+ ]+ |] -- Now we can prove idempotency easily: lemma "destutterIdempotent"@@ -1202,6 +1241,7 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.diff -- [Proven] appendDiff :: Ɐas ∷ [Integer] → Ɐbs ∷ [Integer] → Ɐcs ∷ [Integer] → Bool appendDiff :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "as" [a] -> Forall "bs" [a] -> Forall "cs" [a] -> SBool)) appendDiff = induct "appendDiff"@@ -1223,6 +1263,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.diff -- [Proven] diffAppend :: Ɐas ∷ [Integer] → Ɐbs ∷ [Integer] → Ɐcs ∷ [Integer] → Bool diffAppend :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "as" [a] -> Forall "bs" [a] -> Forall "cs" [a] -> SBool)) diffAppend = induct "diffAppend"@@ -1261,6 +1302,7 @@ -- Step: 1.2.2.Completeness Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.diff -- [Proven] diffDiff :: Ɐas ∷ [Integer] → Ɐbs ∷ [Integer] → Ɐcs ∷ [Integer] → Bool diffDiff :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "as" [a] -> Forall "bs" [a] -> Forall "cs" [a] -> SBool)) diffDiff = induct "diffDiff"@@ -1297,7 +1339,11 @@ -- | Are the two lists disjoint? disjoint :: (Eq a, SymVal a) => SList a -> SList a -> SBool-disjoint = smtFunction "disjoint" $ \xs ys -> null xs .|| head xs `notElem` ys .&& disjoint (tail xs) ys+disjoint = smtFunction "disjoint"+ $ \xs ys -> [sCase| xs of+ [] -> sTrue+ a : as -> a `notElem` ys .&& disjoint as ys+ |] -- | @disjoint as bs .=> as \\ bs == as@ --@@ -1307,6 +1353,7 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: disjoint, sbv.diff -- [Proven] disjointDiff :: Ɐas ∷ [Integer] → Ɐbs ∷ [Integer] → Bool disjointDiff :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "as" [a] -> Forall "bs" [a] -> SBool)) disjointDiff = induct "disjointDiff"@@ -1328,6 +1375,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.filter, sbv.partition -- [Proven] partition1 :: Ɐxs ∷ [Integer] → Bool partition1 :: forall a. SymVal a => (SBV a -> SBool) -> TP (Proof (Forall "xs" [a] -> SBool)) partition1 f =@@ -1354,6 +1402,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.filter, sbv.partition -- [Proven] partition2 :: Ɐxs ∷ [Integer] → Bool partition2 :: forall a. SymVal a => (SBV a -> SBool) -> TP (Proof (Forall "xs" [a] -> SBool)) partition2 f =@@ -1427,6 +1476,7 @@ -- Lemma: take_map -- Step: 1 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map -- [Proven] take_map :: Ɐn ∷ Integer → Ɐxs ∷ [Integer] → Bool take_map :: forall a b. (SymVal a, SymVal b) => (SBV a -> SBV b) -> TP (Proof (Forall "n" Integer -> Forall "xs" [a] -> SBool)) take_map f = do@@ -1490,6 +1540,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map -- [Proven] drop_map :: Ɐn ∷ Integer → Ɐxs ∷ [Integer] → Bool drop_map :: forall a b. (SymVal a, SymVal b) => (SBV a -> SBV b) -> TP (Proof (Forall "n" Integer -> Forall "xs" [a] -> SBool)) drop_map f = do@@ -1598,6 +1649,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map, sbv.zip -- [Proven] map_fst_zip :: (Ɐxs ∷ [Integer], Ɐys ∷ [Integer]) → Bool map_fst_zip :: forall a b. (SymVal a, SymVal b) => TP (Proof ((Forall "xs" [a], Forall "ys" [b]) -> SBool)) map_fst_zip = induct "map_fst_zip"@@ -1621,6 +1673,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map, sbv.zip -- [Proven] map_snd_zip :: (Ɐxs ∷ [Integer], Ɐys ∷ [Integer]) → Bool map_snd_zip :: forall a b. (SymVal a, SymVal b) => TP (Proof ((Forall "xs" [a], Forall "ys" [b]) -> SBool)) map_snd_zip = induct "map_snd_zip"@@ -1646,6 +1699,7 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map, sbv.zip -- [Proven] map_fst_zip_take :: (Ɐxs ∷ [Integer], Ɐys ∷ [Integer]) → Bool map_fst_zip_take :: forall a b. (SymVal a, SymVal b) => TP (Proof ((Forall "xs" [a], Forall "ys" [b]) -> SBool)) map_fst_zip_take = do@@ -1675,6 +1729,7 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.map, sbv.zip -- [Proven] map_snd_zip_take :: (Ɐxs ∷ [Integer], Ɐys ∷ [Integer]) → Bool map_snd_zip_take :: forall a b. (SymVal a, SymVal b) => TP (Proof ((Forall "xs" [a], Forall "ys" [b]) -> SBool)) map_snd_zip_take = do@@ -1694,15 +1749,33 @@ -- | Count the number of occurrences of an element in a list count :: SymVal a => SBV a -> SList a -> SInteger-count = smtFunction "count" $ \e l -> ite (null l)- 0- (let (x, xs) = uncons l- cxs = count e xs- in ite (e .== x) (1 + cxs) cxs)+count = smtFunction "count"+ $ \e l -> [sCase| l of+ [] -> 0+ x : xs | e .== x -> 1 + count e xs+ | True -> count e xs+ |] +-- | One-step unfolding of 'count' on a cons cell. The solver can expand the+-- @define-fun-rec@ but struggles to fold it back, so we provide this as a reusable hint.+--+-- >>> runTP $ countOneStep @Integer+-- Lemma: countOneStep Q.E.D.+-- Functions proven terminating: count+-- [Proven] countOneStep :: Ɐe ∷ Integer → Ɐx ∷ Integer → Ɐxs ∷ [Integer] → Bool+countOneStep :: forall a. SymVal a => TP (Proof (Forall "e" a -> Forall "x" a -> Forall "xs" [a] -> SBool))+countOneStep = lemma "countOneStep"+ (\(Forall @"e" e) (Forall @"x" x) (Forall @"xs" (xs :: SList a)) ->+ count e (x .: xs) .== ite (e .== x) (1 + count e xs) (count e xs))+ []+ -- | Interleave the elements of two lists. If one ends, we take the rest from the other. interleave :: SymVal a => SList a -> SList a -> SList a-interleave = smtFunction "interleave" (\xs ys -> ite (null xs) ys (head xs .: interleave ys (tail xs)))+interleave = smtFunction "interleave"+ $ \xs ys -> [sCase| xs of+ [] -> ys+ a : as -> a .: interleave ys as+ |] -- | Prove that interleave preserves total length. --@@ -1712,25 +1785,29 @@ -- >>> runTP $ interleaveLen @Integer -- Inductive lemma (strong): interleaveLen -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2.1 Q.E.D. -- Step: 1.2.2 Q.E.D. -- Step: 1.2.3 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: interleave -- [Proven] interleaveLen :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool interleaveLen :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) interleaveLen = sInduct "interleaveLen" (\(Forall xs) (Forall ys) -> length xs + length ys .== length (interleave xs ys)) (\xs ys -> length xs + length ys, []) $ \ih xs ys -> [] |- length xs + length ys .== length (interleave xs ys)- =: split xs- trivial- (\a as -> length (a .: as) + length ys .== length (interleave (a .: as) ys)- =: 1 + length as + length ys .== 1 + length (interleave ys as)- ?? ih `at` (Inst @"xs" ys, Inst @"ys" as)- =: sTrue- =: qed)+ =: [pCase| xs of+ [] -> trivial+ whole@(_ : as) ->+ length whole + length ys .== length (interleave whole ys)+ =: 1 + length as + length ys .== 1 + length (interleave ys as)+ ?? ih `at` (Inst @"xs" ys, Inst @"ys" as)+ =: sTrue+ =: qed+ |] -- | Uninterleave the elements of two lists. We roughly split it into two, of alternating elements. uninterleave :: SymVal a => SList a -> STuple [a] [a]@@ -1738,10 +1815,12 @@ -- | Generalized form of uninterleave with the auxilary lists made explicit. uninterleaveGen :: SymVal a => SList a -> STuple [a] [a] -> STuple [a] [a]-uninterleaveGen = smtFunction "uninterleave" (\xs alts -> let (es, os) = untuple alts- in ite (null xs)- (tuple (reverse es, reverse os))- (uninterleaveGen (tail xs) (tuple (os, head xs .: es))))+uninterleaveGen = smtFunction "uninterleave"+ $ \xs alts -> let (es, os) = untuple alts+ in [sCase| xs of+ [] -> tuple (reverse es, reverse os)+ x : ys -> uninterleaveGen ys (tuple (os, x .: es))+ |] -- | The functions 'uninterleave' and 'interleave' are inverses so long as the inputs are of the same length. (The equality -- would even hold if the first argument has one extra element, but we keep things simple here.)@@ -1752,23 +1831,24 @@ -- Lemma: revCons Q.E.D. -- Inductive lemma (strong): roundTripGen -- Step: Measure is non-negative Q.E.D.--- Step: 1 (4 way full case split)+-- Step: 1 (3 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2 Q.E.D.--- Step: 1.3 Q.E.D.--- Step: 1.4.1 Q.E.D.--- Step: 1.4.2 Q.E.D.--- Step: 1.4.3 Q.E.D.--- Step: 1.4.4 Q.E.D.--- Step: 1.4.5 Q.E.D.--- Step: 1.4.6 Q.E.D.--- Step: 1.4.7 Q.E.D.--- Step: 1.4.8 Q.E.D.+-- Step: 1.3.1 Q.E.D.+-- Step: 1.3.2 Q.E.D.+-- Step: 1.3.3 Q.E.D.+-- Step: 1.3.4 Q.E.D.+-- Step: 1.3.5 Q.E.D.+-- Step: 1.3.6 Q.E.D.+-- Step: 1.3.7 Q.E.D.+-- Step: 1.3.8 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: interleaveRoundTrip -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: interleave, sbv.reverse, uninterleave -- [Proven] interleaveRoundTrip :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool interleaveRoundTrip :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) interleaveRoundTrip = do@@ -1785,22 +1865,23 @@ \ih xs ys alts -> [length xs .== length ys] |- let (es, os) = untuple alts in uninterleaveGen (interleave xs ys) alts- =: split2 (xs, ys)- trivial- trivial- trivial- (\(a, as) (b, bs) -> uninterleaveGen (interleave (a .: as) (b .: bs)) alts- =: uninterleaveGen (a .: interleave (b .: bs) as) alts- =: uninterleaveGen (a .: b .: interleave as bs) alts- =: uninterleaveGen (interleave as bs) (tuple (a .: es, b .: os))- ?? ih `at` (Inst @"xs" as, Inst @"ys" bs, Inst @"alts" (tuple (a .: es, b .: os)))- =: tuple (reverse (a .: es) ++ as, reverse (b .: os) ++ bs)- ?? revHelper `at` (Inst @"a" a, Inst @"as" es, Inst @"bs" as)- =: tuple (reverse es ++ (a .: as), reverse (b .: os) ++ bs)- ?? revHelper `at` (Inst @"a" b, Inst @"as" os, Inst @"bs" bs)- =: tuple (reverse es ++ (a .: as), reverse os ++ (b .: bs))- =: tuple (reverse es ++ xs, reverse os ++ ys)- =: qed)+ =: [pCase| tuple (xs, ys) of+ ([], _) -> trivial+ (_, []) -> trivial+ (ll@(a : as), rr@(b : bs)) ->+ uninterleaveGen (interleave ll rr) alts+ =: uninterleaveGen (a .: interleave rr as) alts+ =: uninterleaveGen (a .: b .: interleave as bs) alts+ =: uninterleaveGen (interleave as bs) (tuple (a .: es, b .: os))+ ?? ih `at` (Inst @"xs" as, Inst @"ys" bs, Inst @"alts" (tuple (a .: es, b .: os)))+ =: tuple (reverse (a .: es) ++ as, reverse (b .: os) ++ bs)+ ?? revHelper `at` (Inst @"a" a, Inst @"as" es, Inst @"bs" as)+ =: tuple (reverse es ++ ll, reverse (b .: os) ++ bs)+ ?? revHelper `at` (Inst @"a" b, Inst @"as" os, Inst @"bs" bs)+ =: tuple (reverse es ++ ll, reverse os ++ rr)+ =: tuple (reverse es ++ xs, reverse os ++ ys)+ =: qed+ |] -- Round-trip theorem: calc "interleaveRoundTrip"@@ -1822,6 +1903,7 @@ -- Step: 3 Q.E.D. -- Step: 4 (simplify) Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count -- [Proven] countAppend :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Ɐe ∷ Integer → Bool countAppend :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "e" a -> SBool)) countAppend =@@ -1852,6 +1934,7 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count -- [Proven] takeDropCount :: Ɐxs ∷ [Integer] → Ɐn ∷ Integer → Ɐe ∷ Integer → Bool takeDropCount :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "n" Integer -> Forall "e" a -> SBool)) takeDropCount = do@@ -1879,6 +1962,7 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count -- [Proven] countNonNeg :: Ɐxs ∷ [Integer] → Ɐe ∷ Integer → Bool countNonNeg :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "e" a -> SBool)) countNonNeg =@@ -1916,6 +2000,7 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count -- [Proven] countElem :: Ɐxs ∷ [Integer] → Ɐe ∷ Integer → Bool countElem :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "xs" [a] -> Forall "e" a -> SBool)) countElem = do@@ -1947,6 +2032,7 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count -- [Proven] elemCount :: Ɐxs ∷ [Integer] → Ɐe ∷ Integer → Bool elemCount :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "xs" [a] -> Forall "e" a -> SBool)) elemCount =
Documentation/SBV/Examples/TP/Majority.hs view
@@ -11,6 +11,7 @@ ----------------------------------------------------------------------------- {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-}@@ -34,11 +35,11 @@ -- majority element, then the result is irrelevant. majority :: SymVal a => SBV a -> SInteger -> SList a -> SBV a majority = smtFunction "majority"- $ \c i lst -> ite (null lst) c- (let (x, xs) = uncons lst- in ite (i .== 0)- (majority x 1 xs)- (majority c (i + ite (c .== x) 1 (-1)) xs))+ $ \c i lst -> [sCase| lst of+ [] -> c+ x : xs | i .== 0 -> majority x 1 xs+ | True -> majority c (i + ite (c .== x) 1 (-1)) xs+ |] -- | We can now define mjrty, which simply feeds the majority function with an arbitrary element of the domain. -- By the definition of 'majority' above, this arbitrary element will be returned if the given list is empty.@@ -90,6 +91,7 @@ -- Lemma: uniqueness -- Step: 1 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count, majority -- ([Proven] majority :: Ɐc ∷ Integer → Ɐxs ∷ [Integer] → Bool,[Proven] ifExistsFound :: Ɐc ∷ Integer → Ɐxs ∷ [Integer] → Bool,[Proven] ifNoMajority :: Ɐc ∷ Integer → Ɐxs ∷ [Integer] → Bool,[Proven] uniqueness :: Ɐm1 ∷ Integer → Ɐm2 ∷ Integer → Ɐxs ∷ [Integer] → Bool) correctness :: forall a. SymVal a => IO ( Proof (Forall "c" a -> Forall "xs" [a] -> SBool) -- If majority exists, the calculated value is majority
Documentation/SBV/Examples/TP/McCarthy91.hs view
@@ -10,6 +10,7 @@ ----------------------------------------------------------------------------- {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} @@ -22,11 +23,22 @@ -- * Definitions --- | Nested recursive definition of McCarthy's function.+-- | Nested recursive definition of McCarthy's function. We use 'smtFunctionWithContract' because+-- the nested recursion @mcCarthy91 (mcCarthy91 (n + 11))@ requires knowing what the inner call returns+-- in order to verify that the outer call's measure decreases. The contract states that for inputs @≤ 100@,+-- the result is @91@. Note that the contract itself is verified as part of the measure check: SBV proves+-- both measure decrease and the contract simultaneously via well-founded induction. mcCarthy91 :: SInteger -> SInteger-mcCarthy91 = smtFunction "mcCarthy91" $ \n -> ite (n .> 100)- (n - 10)- (mcCarthy91 (mcCarthy91 (n + 11)))+mcCarthy91 = smtFunctionWithContract "mcCarthy91"+ ( \n -> 0 `smax` (101 - n)+ , \n r -> n .<= 100 .=> r .== 91+ , []+ )+ $ \n -> [sCase| n of+ _ | n .> 100 -> n - 10+ _ -> mcCarthy91 (mcCarthy91 (n + 11))+ |]+ -- | Specification for McCarthy's function. spec91 :: SInteger -> SInteger spec91 n = ite (n .> 100) (n - 10) 91@@ -51,6 +63,7 @@ -- Step: 1.3 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: mcCarthy91 -- [Proven] mcCarthy91 :: Ɐn ∷ Integer → Bool correctness :: IO (Proof (Forall "n" Integer -> SBool)) correctness = runTP $ do
Documentation/SBV/Examples/TP/MergeSort.hs view
@@ -13,6 +13,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -39,17 +40,24 @@ -- | Merge two already sorted lists into another merge :: (OrdSymbolic (SBV a), SymVal a) => SList a -> SList a -> SList a-merge = smtFunction "merge" $ \l r -> ite (null l) r- $ ite (null r) l- $ let (a, as) = uncons l- (b, bs) = uncons r- in ite (a .<= b) (a .: merge as r) (b .: merge l bs)+merge = smtFunction "merge"+ $ \l r -> [sCase| tuple (l, r) of+ ([], _) -> r+ (_, []) -> l + (ll@(a : as), rr@(b : bs)) | a .<= b -> a .: merge as rr+ | True -> b .: merge ll bs+ |]+ -- | Merge sort, using 'merge' above to successively sort halved input mergeSort :: (OrdSymbolic (SBV a), SymVal a) => SList a -> SList a-mergeSort = smtFunction "mergeSort" $ \l -> ite (length l .<= 1) l- $ let (h1, h2) = splitAt (length l `sEDiv` 2) l- in merge (mergeSort h1) (mergeSort h2)+mergeSort = smtFunction "mergeSort"+ $ \l -> [sCase| l of+ [] -> l+ [_] -> l+ _ -> let (h1, h2) = splitAt (length l `sEDiv` 2) l+ in merge (mergeSort h1) (mergeSort h2)+ |] -- * Correctness proof @@ -71,46 +79,51 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Lemma: countOneStep Q.E.D.+-- Lemma: mergeHead Q.E.D.+-- Lemma: mergeUnfold Q.E.D. -- Inductive lemma (strong): mergeKeepsSort -- Step: Measure is non-negative Q.E.D.--- Step: 1 (4 way full case split)+-- Step: 1 (3 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2 Q.E.D.--- Step: 1.3 Q.E.D.--- Step: 1.4.1 (unfold merge) Q.E.D.--- Step: 1.4.2 (2 way case split)--- Step: 1.4.2.1.1 (case split) Q.E.D.--- Step: 1.4.2.1.2 Q.E.D.--- Step: 1.4.2.2.1 (case split) Q.E.D.--- Step: 1.4.2.2.2 Q.E.D.--- Step: 1.4.2.Completeness Q.E.D.+-- Step: 1.3 (2 way case split)+-- Step: 1.3.1.1 (2 way case split) Q.E.D.+-- Step: 1.3.1.2 Q.E.D.+-- Step: 1.3.1.3 Q.E.D.+-- Step: 1.3.2.1 (2 way case split) Q.E.D.+-- Step: 1.3.2.2 Q.E.D.+-- Step: 1.3.2.3 Q.E.D.+-- Step: 1.3.Completeness Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Inductive lemma (strong): sortNonDecreasing -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2.1 (unfold) Q.E.D. -- Step: 1.2.2 (push nonDecreasing down) Q.E.D. -- Step: 1.2.3 Q.E.D. -- Step: 1.2.4 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Inductive lemma (strong): mergeCount -- Step: Measure is non-negative Q.E.D.--- Step: 1 (4 way full case split)+-- Step: 1 (3 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2 Q.E.D.--- Step: 1.3 Q.E.D.--- Step: 1.4.1 (unfold merge) Q.E.D.--- Step: 1.4.2 (push count inside) Q.E.D.--- Step: 1.4.3 (unfold count, twice) Q.E.D.--- Step: 1.4.4 Q.E.D.--- Step: 1.4.5 Q.E.D.--- Step: 1.4.6 (unfold count in reverse, twice) Q.E.D.--- Step: 1.4.7 (simplify) Q.E.D.+-- Step: 1.3.1 (unfold merge) Q.E.D.+-- Step: 1.3.2 (push count inside) Q.E.D.+-- Step: 1.3.3 (unfold count, twice) Q.E.D.+-- Step: 1.3.4 Q.E.D.+-- Step: 1.3.5 Q.E.D.+-- Step: 1.3.6 (unfold count in reverse, twice) Q.E.D.+-- Step: 1.3.7 (simplify) Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Inductive lemma (strong): sortIsPermutation -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2.1 (unfold mergeSort) Q.E.D. -- Step: 1.2.2 (push count down, simplify, rearrange) Q.E.D.@@ -118,8 +131,10 @@ -- Step: 1.2.4 Q.E.D. -- Step: 1.2.5 Q.E.D. -- Step: 1.2.6 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: mergeSortIsCorrect Q.E.D.+-- Functions proven terminating: count, merge, mergeSort, nonDecreasing -- [Proven] mergeSortIsCorrect :: Ɐxs ∷ [Integer] → Bool correctness :: forall a. (OrdSymbolic (SBV a), SymVal a) => IO (Proof (Forall "xs" [a] -> SBool)) correctness = runTPWith (tpRibbon 60 z3) $ do@@ -133,7 +148,20 @@ nonDecrIns <- SH.nonDecrIns @a takeDropCount <- TP.takeDropCount @a+ cntStep <- TP.countOneStep @a + -- Head of merge: one unfold of merge suffices for the solver+ mergeHead <- lemma "mergeHead"+ (\(Forall xs) (Forall ys) -> sNot (null ys) .=>+ head (merge xs ys) .== ite (null xs) (head ys) (ite (head xs .<= head ys) (head xs) (head ys)))+ []++ -- Unfold lemma for merge's recursive case+ mergeUnfold <- lemma "mergeUnfold"+ (\(Forall x) (Forall xs) (Forall y) (Forall ys) ->+ merge (x .: xs) (y .: ys) .== ite (x .<= y) (x .: merge xs (y .: ys)) (y .: merge (x .: xs) ys))+ []+ -------------------------------------------------------------------------------------------- -- Part II. Prove that the output of merge sort is non-decreasing. --------------------------------------------------------------------------------------------@@ -143,54 +171,58 @@ (\(Forall xs) (Forall ys) -> nonDecreasing xs .&& nonDecreasing ys .=> nonDecreasing (merge xs ys)) (\xs ys -> tuple (length xs, length ys), []) $ \ih xs ys -> [nonDecreasing xs, nonDecreasing ys]- |- split2 (xs, ys)- trivial -- when both xs and ys are empty. Trivial.- trivial -- when xs is empty, but ys isn't. Trivial.- trivial -- when ys is empty, but xs isn't. Trivial.- (\(a, as) (b, bs) ->- nonDecreasing (merge (a .: as) (b .: bs))- ?? "unfold merge"- =: nonDecreasing (ite (a .<= b)- (a .: merge as (b .: bs))- (b .: merge (a .: as) bs))- ?? "case split"- =: cases [ a .<= b ==> nonDecreasing (a .: merge as (b .: bs))- ?? ih `at` (Inst @"xs" as, Inst @"ys" (b .: bs))- ?? nonDecrIns `at` (Inst @"x" a, Inst @"xs" (merge as (b .: bs)))- =: sTrue- =: qed- , a .> b ==> nonDecreasing (b .: merge (a .: as) bs)- ?? ih `at` (Inst @"xs" (a .: as), Inst @"ys" bs)- ?? nonDecrIns `at` (Inst @"x" b, Inst @"xs" (merge (a .: as) bs))- =: sTrue- =: qed- ])+ |- [pCase| tuple (xs, ys) of+ ([], _) -> trivial+ (_, []) -> trivial+ (ll@(a : as), rr@(b : bs)) ->+ nonDecreasing (merge ll rr)+ ?? "2 way case split"+ =: cases [ a .<= b ==> nonDecreasing (merge ll rr)+ ?? mergeUnfold `at` (Inst @"x" a, Inst @"xs" as, Inst @"y" b, Inst @"ys" bs)+ =: nonDecreasing (a .: merge as rr)+ ?? ih `at` (Inst @"xs" as, Inst @"ys" rr)+ ?? nonDecrIns `at` (Inst @"x" a, Inst @"xs" (merge as rr))+ ?? mergeHead `at` (Inst @"xs" as, Inst @"ys" rr)+ =: sTrue+ =: qed+ , a .> b ==> nonDecreasing (merge ll rr)+ ?? mergeUnfold `at` (Inst @"x" a, Inst @"xs" as, Inst @"y" b, Inst @"ys" bs)+ =: nonDecreasing (b .: merge ll bs)+ ?? ih `at` (Inst @"xs" ll, Inst @"ys" bs)+ ?? nonDecrIns `at` (Inst @"x" b, Inst @"xs" (merge ll bs))+ ?? mergeHead `at` (Inst @"xs" ll, Inst @"ys" bs)+ =: sTrue+ =: qed+ ]+ |] sortNonDecreasing <- sInduct "sortNonDecreasing" (\(Forall xs) -> nonDecreasing (mergeSort xs)) (length, []) $- \ih xs -> [] |- split xs- qed- (\e es -> nonDecreasing (mergeSort (e .: es))- ?? "unfold"- =: let (h1, h2) = splitAt (length (e .: es) `sEDiv` 2) (e .: es)- in nonDecreasing (ite (length (e .: es) .<= 1)- (e .: es)- (merge (mergeSort h1) (mergeSort h2)))- ?? "push nonDecreasing down"- =: ite (length (e .: es) .<= 1)- (nonDecreasing (e .: es))- (nonDecreasing (merge (mergeSort h1) (mergeSort h2)))- ?? ih `at` Inst @"xs" es- =: ite (length (e .: es) .<= 1)- sTrue- (nonDecreasing (merge (mergeSort h1) (mergeSort h2)))- ?? ih `at` Inst @"xs" h1- ?? ih `at` Inst @"xs" h2- ?? mergeKeepsSort `at` (Inst @"xs" (mergeSort h1), Inst @"ys" (mergeSort h2))- =: sTrue- =: qed)+ \ih xs -> [] |- [pCase| xs of+ [] -> qed+ whole@(_ : es) ->+ nonDecreasing (mergeSort whole)+ ?? "unfold"+ =: let (h1, h2) = splitAt (length whole `sEDiv` 2) whole+ in nonDecreasing (ite (length whole .<= 1)+ whole+ (merge (mergeSort h1) (mergeSort h2)))+ ?? "push nonDecreasing down"+ =: ite (length whole .<= 1)+ (nonDecreasing whole)+ (nonDecreasing (merge (mergeSort h1) (mergeSort h2)))+ ?? ih `at` Inst @"xs" es+ =: ite (length whole .<= 1)+ sTrue+ (nonDecreasing (merge (mergeSort h1) (mergeSort h2)))+ ?? ih `at` Inst @"xs" h1+ ?? ih `at` Inst @"xs" h2+ ?? mergeKeepsSort `at` (Inst @"xs" (mergeSort h1), Inst @"ys" (mergeSort h2))+ =: sTrue+ =: qed+ |] -------------------------------------------------------------------------------------------- -- Part III. Prove that the output of merge sort is a permuation of its input@@ -199,73 +231,80 @@ sInduct "mergeCount" (\(Forall xs) (Forall ys) (Forall e) -> count e (merge xs ys) .== count e xs + count e ys) (\xs ys _e -> tuple (length xs, length ys), []) $- \ih as bs e -> [] |- split2 (as, bs)- trivial- trivial- trivial- (\(x, xs) (y, ys) -> count e (merge (x .: xs) (y .: ys))- ?? "unfold merge"- =: count e (ite (x .<= y)- (x .: merge xs (y .: ys))- (y .: merge (x .: xs) ys))- ?? "push count inside"- =: ite (x .<= y)- (count e (x .: merge xs (y .: ys)))- (count e (y .: merge (x .: xs) ys))- ?? "unfold count, twice"- =: ite (x .<= y)- (let r = count e (merge xs (y .: ys)) in ite (e .== x) (1+r) r)- (let r = count e (merge (x .: xs) ys) in ite (e .== y) (1+r) r)- ?? ih `at` (Inst @"xs" xs, Inst @"ys" (y .: ys), Inst @"e" e)- =: ite (x .<= y)- (let r = count e xs + count e (y .: ys) in ite (e .== x) (1+r) r)- (let r = count e (merge (x .: xs) ys) in ite (e .== y) (1+r) r)- ?? ih `at` (Inst @"xs" (x .: xs), Inst @"ys" ys, Inst @"e" e)- =: ite (x .<= y)- (let r = count e xs + count e (y .: ys) in ite (e .== x) (1+r) r)- (let r = count e (x .: xs) + count e ys in ite (e .== y) (1+r) r)- ?? "unfold count in reverse, twice"- =: ite (x .<= y)- (count e (x .: xs) + count e (y .: ys))- (count e (x .: xs) + count e (y .: ys))- ?? "simplify"- =: count e (x .: xs) + count e (y .: ys)- =: qed)+ \ih as bs e -> [] |- [pCase| tuple (as, bs) of+ ([], _) -> trivial+ (_, []) -> trivial + (ll@(x : xs), rr@(y : ys)) ->+ count e (merge ll rr)+ ?? "unfold merge"+ =: count e (ite (x .<= y)+ (x .: merge xs rr)+ (y .: merge ll ys))+ ?? "push count inside"+ =: ite (x .<= y)+ (count e (x .: merge xs rr))+ (count e (y .: merge ll ys))+ ?? "unfold count, twice"+ ?? cntStep `at` (Inst @"e" e, Inst @"x" x, Inst @"xs" (merge xs rr))+ ?? cntStep `at` (Inst @"e" e, Inst @"x" y, Inst @"xs" (merge ll ys))+ =: ite (x .<= y)+ (let r = count e (merge xs rr) in ite (e .== x) (1+r) r)+ (let r = count e (merge ll ys) in ite (e .== y) (1+r) r)+ ?? ih `at` (Inst @"xs" xs, Inst @"ys" rr, Inst @"e" e)+ =: ite (x .<= y)+ (let r = count e xs + count e rr in ite (e .== x) (1+r) r)+ (let r = count e (merge ll ys) in ite (e .== y) (1+r) r)+ ?? ih `at` (Inst @"xs" ll, Inst @"ys" ys, Inst @"e" e)+ =: ite (x .<= y)+ (let r = count e xs + count e rr in ite (e .== x) (1+r) r)+ (let r = count e ll + count e ys in ite (e .== y) (1+r) r)+ ?? "unfold count in reverse, twice"+ ?? cntStep `at` (Inst @"e" e, Inst @"x" x, Inst @"xs" xs)+ ?? cntStep `at` (Inst @"e" e, Inst @"x" y, Inst @"xs" ys)+ =: ite (x .<= y)+ (count e ll + count e rr)+ (count e ll + count e rr)+ ?? "simplify"+ =: count e ll + count e rr+ =: qed+ |]+ sortIsPermutation <- sInductWith cvc5 "sortIsPermutation" (\(Forall xs) (Forall e) -> count e xs .== count e (mergeSort xs)) (\xs _e -> length xs, []) $- \ih as e -> [] |- split as- trivial- (\x xs -> count e (mergeSort (x .: xs))- ?? "unfold mergeSort"- =: count e (ite (length (x .: xs) .<= 1)- (x .: xs)- (let (h1, h2) = splitAt (length (x .: xs) `sEDiv` 2) (x .: xs)- in merge (mergeSort h1) (mergeSort h2)))- ?? "push count down, simplify, rearrange"- =: let (h1, h2) = splitAt (length (x .: xs) `sEDiv` 2) (x .: xs)- in ite (null xs)- (count e [x])- (count e (merge (mergeSort h1) (mergeSort h2)))- ?? mergeCount `at` (Inst @"xs" (mergeSort h1), Inst @"ys" (mergeSort h2), Inst @"e" e)- =: ite (null xs)- (count e [x])- (count e (mergeSort h1) + count e (mergeSort h2))- ?? ih `at` (Inst @"xs" h1, Inst @"e" e)- =: ite (null xs)- (count e [x])- (count e h1 + count e (mergeSort h2))- ?? ih `at` (Inst @"xs" h2, Inst @"e" e)- =: ite (null xs)- (count e [x])- (count e h1 + count e h2)- ?? takeDropCount `at` (Inst @"xs" (x .: xs), Inst @"n" (length (x .: xs) `sEDiv` 2), Inst @"e" e)- =: ite (null xs)- (count e [x])- (count e (x .: xs))- =: qed)+ \ih as e -> [] |- [pCase| as of+ [] -> trivial+ whole@(x : xs) -> count e (mergeSort whole)+ ?? "unfold mergeSort"+ =: count e (ite (length whole .<= 1)+ whole+ (let (h1, h2) = splitAt (length whole `sEDiv` 2) whole+ in merge (mergeSort h1) (mergeSort h2)))+ ?? "push count down, simplify, rearrange"+ =: let (h1, h2) = splitAt (length whole `sEDiv` 2) whole+ in ite (null xs)+ (count e [x])+ (count e (merge (mergeSort h1) (mergeSort h2)))+ ?? mergeCount `at` (Inst @"xs" (mergeSort h1), Inst @"ys" (mergeSort h2), Inst @"e" e)+ =: ite (null xs)+ (count e [x])+ (count e (mergeSort h1) + count e (mergeSort h2))+ ?? ih `at` (Inst @"xs" h1, Inst @"e" e)+ =: ite (null xs)+ (count e [x])+ (count e h1 + count e (mergeSort h2))+ ?? ih `at` (Inst @"xs" h2, Inst @"e" e)+ =: ite (null xs)+ (count e [x])+ (count e h1 + count e h2)+ ?? takeDropCount `at` (Inst @"xs" whole, Inst @"n" (length whole `sEDiv` 2), Inst @"e" e)+ =: ite (null xs)+ (count e [x])+ (count e whole)+ =: qed+ |] -------------------------------------------------------------------------------------------- -- Put the two parts together for the final proof
+ Documentation/SBV/Examples/TP/MutualCorecursion.hs view
@@ -0,0 +1,187 @@+-----------------------------------------------------------------------------+-- |+-- Module : Documentation.SBV.Examples.TP.MutualCorecursion+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer: erkokl@gmail.com+-- Stability : experimental+--+-- Demonstrating mutually corecursive (productive) functions. Two functions+-- @ping@ and @pong@ take turns producing elements of a stream: each emits+-- its argument and then calls the other with the next value:+--+-- @+-- ping n = n .: pong (n + 1)+-- pong n = n .: ping (n + 1)+-- @+--+-- Together they produce the natural number stream starting from @n@:+-- @ping 0 = [0, 1, 2, 3, ...]@. We prove that the @k@-th element+-- of @ping n@ is @n + k@.+-----------------------------------------------------------------------------++{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror #-}++module Documentation.SBV.Examples.TP.MutualCorecursion where++import Prelude hiding (head, length, (!!))++import Data.SBV+import Data.SBV.List+import Data.SBV.TP++#ifdef DOCTEST+-- $setup+-- >>> import Data.SBV.TP+#endif++-- * Definitions++-- | @ping n@ emits @n@ and hands off to 'pong'. Note the use of 'smtProductiveFunction':+-- since @ping@ and @pong@ are corecursive (no base case, always producing output), we+-- declare them productive instead of terminating.+ping :: SInteger -> SList Integer+ping = smtProductiveFunction "ping"+ $ \n -> n .: pong (n + 1)++-- | @pong n@ emits @n@ and hands off to 'ping'. See 'ping' for why we use 'smtProductiveFunction'.+pong :: SInteger -> SList Integer+pong = smtProductiveFunction "pong"+ $ \n -> n .: ping (n + 1)++-- * Helper lemmas++-- | @ping@ produces unboundedly long lists.+--+-- >>> runTP pingLen+-- Inductive lemma: pingLen+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Result: Q.E.D.+-- Functions proven productive: ping, pong+-- [Proven] pingLen :: Ɐm ∷ Integer → Ɐn ∷ Integer → Bool+pingLen :: TP (Proof (Forall "m" Integer -> Forall "n" Integer -> SBool))+pingLen = inductWith cvc5 "pingLen"+ (\(Forall @"m" (m :: SInteger)) (Forall @"n" n) -> length (ping n) .>= m) $+ \ih m n -> []+ |- length (ping n) .>= m + 1+ =: length (n .: pong (n + 1)) .>= m + 1+ ?? ih `at` Inst @"n" (n + 2)+ =: sTrue+ =: qed++-- | @pong@ produces unboundedly long lists.+--+-- >>> runTP pongLen+-- Inductive lemma: pongLen+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Result: Q.E.D.+-- Functions proven productive: ping, pong+-- [Proven] pongLen :: Ɐm ∷ Integer → Ɐn ∷ Integer → Bool+pongLen :: TP (Proof (Forall "m" Integer -> Forall "n" Integer -> SBool))+pongLen = inductWith cvc5 "pongLen"+ (\(Forall @"m" (m :: SInteger)) (Forall @"n" n) -> length (pong n) .>= m) $+ \ih m n -> []+ |- length (pong n) .>= m + 1+ =: length (n .: ping (n + 1)) .>= m + 1+ ?? ih `at` Inst @"n" (n + 2)+ =: sTrue+ =: qed++-- | Indexing past a cons: @(x .: y) !! k == y !! (k - 1)@ when @k > 0@ and in bounds.+--+-- >>> runTP consIndex+-- Lemma: consIndex Q.E.D.+-- [Proven] consIndex :: Ɐx ∷ Integer → Ɐy ∷ [Integer] → Ɐk ∷ Integer → Bool+consIndex :: TP (Proof (Forall "x" Integer -> Forall "y" [Integer] -> Forall "k" Integer -> SBool))+consIndex = lemma "consIndex"+ (\(Forall @"x" (x :: SInteger)) (Forall @"y" y) (Forall @"k" k) ->+ k .> 0 .&& k .<= length y .=> (x .: y) !! k .== y !! (k - 1))+ []++-- * Correctness++-- | Proving @ping n@ and @pong n@ produce the same elements. We prove that the @k@-th+-- elements are the same, by induction on @k@.+--+-- >>> runTP pingEqPong+-- Lemma: pingLen Q.E.D.+-- Lemma: pongLen Q.E.D.+-- Lemma: consIndex Q.E.D.+-- Inductive lemma: pingEqPong+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Step: 3 Q.E.D.+-- Step: 4 Q.E.D.+-- Step: 5 Q.E.D.+-- Result: Q.E.D.+-- Functions proven productive: ping, pong+-- [Proven] pingEqPong :: Ɐk ∷ Integer → Ɐn ∷ Integer → Bool+pingEqPong :: TP (Proof (Forall "k" Integer -> Forall "n" Integer -> SBool))+pingEqPong = do+ piLen <- recall pingLen+ poLen <- recall pongLen+ ci <- recall consIndex++ inductWith cvc5 "pingEqPong"+ (\(Forall @"k" k) (Forall @"n" n) -> k .>= 0 .=> ping n !! k .== pong n !! k) $+ \ih k n -> [k .>= 0]+ |- ping n !! (k + 1)+ =: (n .: pong (n + 1)) !! (k + 1)+ ?? ci `at` (Inst @"x" n, Inst @"y" (pong (n + 1)), Inst @"k" (k + 1))+ ?? poLen+ =: pong (n + 1) !! k+ ?? ih `at` Inst @"n" (n + 1)+ =: ping (n + 1) !! k+ ?? ci `at` (Inst @"x" n, Inst @"y" (ping (n + 1)), Inst @"k" (k + 1))+ ?? piLen+ =: (n .: ping (n + 1)) !! (k + 1)+ =: pong n !! (k + 1)+ =: qed++-- | The @k@-th element of @ping n@ is @n + k@.+--+-- >>> runTP pingElem+-- Lemma: pingEqPong Q.E.D.+-- Cached: consIndex Q.E.D.+-- Cached: pongLen Q.E.D.+-- Inductive lemma: pingElem+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Step: 3 Q.E.D.+-- Step: 4 Q.E.D.+-- Step: 5 Q.E.D.+-- Result: Q.E.D.+-- Functions proven productive: ping, pong+-- [Proven] pingElem :: Ɐk ∷ Integer → Ɐn ∷ Integer → Bool+pingElem :: TP (Proof (Forall "k" Integer -> Forall "n" Integer -> SBool))+pingElem = do+ eq <- recall pingEqPong+ ci <- recall consIndex+ poLen <- recall pongLen++ inductWith cvc5 "pingElem"+ (\(Forall @"k" k) (Forall @"n" n) -> k .>= 0 .=> ping n !! k .== n + k) $+ \ih k n -> [k .>= 0]+ |- ping n !! (k + 1)+ =: (n .: pong (n + 1)) !! (k + 1)+ ?? ci `at` (Inst @"x" n, Inst @"y" (pong (n + 1)), Inst @"k" (k + 1))+ ?? poLen+ =: pong (n + 1) !! k+ ?? eq `at` (Inst @"k" k, Inst @"n" (n + 1))+ =: ping (n + 1) !! k+ ?? ih `at` Inst @"n" (n + 1)+ =: (n + 1) + k+ =: n + (k + 1)+ =: qed
+ Documentation/SBV/Examples/TP/NatStream.hs view
@@ -0,0 +1,121 @@+-----------------------------------------------------------------------------+-- |+-- Module : Documentation.SBV.Examples.TP.NatStream+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer: erkokl@gmail.com+-- Stability : experimental+--+-- Demonstrating productive (corecursive) functions. A productive function+-- is one where every recursive call is guarded by a data constructor, so+-- the function always makes progress by producing output. Unlike terminating+-- functions, productive functions need not have a base case and may produce+-- infinite output.+-----------------------------------------------------------------------------++{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror #-}++module Documentation.SBV.Examples.TP.NatStream where++import Prelude hiding (head, length, (!!))++import Data.SBV+import Data.SBV.List+import Data.SBV.TP++#ifdef DOCTEST+-- $setup+-- >>> import Data.SBV.TP+#endif++-- * Definitions++-- | The infinite stream of integers starting from @n@: @[n, n+1, n+2, ...]@.+-- There is no base case; every recursive call is guarded by the list+-- constructor @.:@, making this a productive (corecursive) definition.+nats :: SInteger -> SList Integer+nats = smtProductiveFunction "nats"+ $ \n -> n .: nats (n + 1)++-- * Correctness++-- | Prove that @nats n@ always starts with @n@.+--+-- NB. As of Mar 2026, z3 can't handle this but cvc5 can.+--+-- >>> runTP natsHead+-- Lemma: natsHead Q.E.D.+-- Functions proven productive: nats+-- [Proven] natsHead :: Ɐn ∷ Integer → Bool+natsHead :: TP (Proof (Forall "n" Integer -> SBool))+natsHead = lemmaWith cvc5 "natsHead"+ (\(Forall @"n" n) -> head (nats n) .== n)+ []++-- | Prove by induction that @nats n@ has at least @m@ elements, for any @m@.+-- This captures the idea that @nats@ produces an unboundedly long list.+--+-- NB. As of Mar 2026, z3 can't handle this but cvc5 can.+--+-- >>> runTP natsLen+-- Inductive lemma: natsLen+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Result: Q.E.D.+-- Functions proven productive: nats+-- [Proven] natsLen :: Ɐm ∷ Integer → Ɐn ∷ Integer → Bool+natsLen :: TP (Proof (Forall "m" Integer -> Forall "n" Integer -> SBool))+natsLen =+ inductWith cvc5 "natsLen"+ (\(Forall @"m" m) (Forall @"n" n) -> length (nats n) .>= m) $+ \ih m n -> []+ |- length (nats n) .>= m + 1+ =: length (n .: nats (n + 1)) .>= m + 1+ ?? ih `at` Inst @"n" (n + 1)+ =: sTrue+ =: qed++-- | Prove by induction that the @k@-th element of @nats n@ is @n + k@.+--+-- NB. As of Mar 2026, z3 can't handle this but cvc5 can.+--+-- >>> runTP natsElem+-- Lemma: natsLen Q.E.D.+-- Lemma: elemOne Q.E.D.+-- Inductive lemma: natsElem+-- Step: Base Q.E.D.+-- Step: 1 Q.E.D.+-- Step: 2 Q.E.D.+-- Step: 3 Q.E.D.+-- Step: 4 Q.E.D.+-- Result: Q.E.D.+-- Functions proven productive: nats+-- [Proven] natsElem :: Ɐk ∷ Integer → Ɐn ∷ Integer → Bool+natsElem :: TP (Proof (Forall "k" Integer -> Forall "n" Integer -> SBool))+natsElem = do+ nLen <- recall natsLen++ elemOne <- lemma "elemOne"+ (\(Forall @"x" (x :: SInteger)) (Forall @"y" y) (Forall @"k" k) ->+ k .> 0 .&& k .<= length y .=> (x .: y) !! k .== y !! (k - 1))+ []++ inductWith cvc5 "natsElem"+ (\(Forall @"k" k) (Forall @"n" n) -> k .>= 0 .=> nats n !! k .== n + k) $+ \ih k n -> [k .>= 0]+ |- nats n !! (k + 1)+ =: (n .: nats (n + 1)) !! (k + 1)+ ?? elemOne+ ?? nLen+ =: nats (n + 1) !! k+ ?? ih `at` Inst @"n" (n + 1)+ =: (n + 1) + k+ =: n + (k + 1)+ =: qed
Documentation/SBV/Examples/TP/Numeric.hs view
@@ -46,6 +46,7 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr, sbv.replicate -- [Proven] sumConst_correct :: Ɐn ∷ Integer → Bool sumConstProof :: SInteger -> TP (Proof (Forall "n" Integer -> SBool)) sumConstProof c = induct "sumConst_correct"@@ -75,6 +76,8 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating:+-- EnumSymbolic.Integer.enumFromThenTo.down, EnumSymbolic.Integer.enumFromThenTo.up, sbv.foldr -- [Proven] sum_correct :: Ɐn ∷ Integer → Bool sumProof :: TP (Proof (Forall "n" Integer -> SBool)) sumProof = induct "sum_correct"@@ -100,6 +103,9 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating:+-- EnumSymbolic.Integer.enumFromThenTo.down, EnumSymbolic.Integer.enumFromThenTo.up,+-- sbv.foldr, sbv.map -- [Proven] sumSquare_correct :: Ɐn ∷ Integer → Bool sumSquareProof :: TP (Proof (Forall "n" Integer -> SBool)) sumSquareProof = do@@ -149,6 +155,9 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating:+-- EnumSymbolic.Integer.enumFromThenTo.down, EnumSymbolic.Integer.enumFromThenTo.up,+-- sbv.foldr, sumCubed -- [Proven] nicomachus :: Ɐn ∷ Integer → Bool nicomachus :: TP (Proof (Forall "n" Integer -> SBool)) nicomachus = do@@ -158,7 +167,10 @@ infixr 8 ^ sumCubed :: SInteger -> SInteger- sumCubed = smtFunction "sumCubed" $ \n -> ite (n .<= 0) 0 (n^3 + sumCubed (n - 1))+ sumCubed = smtFunction "sumCubed" $ \n -> [sCase| n of+ _ | n .<= 0 -> 0+ _ -> n^3 + sumCubed (n - 1)+ |] -- Grab the proof of regular summation formula sp <- sumProof@@ -224,11 +236,15 @@ -- Step: 7 Q.E.D. -- Step: 8 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: pow -- [Proven] elevenMinusFour :: Ɐn ∷ Integer → Bool elevenMinusFour :: TP (Proof (Forall "n" Integer -> SBool)) elevenMinusFour = do let pow :: SInteger -> SInteger -> SInteger- pow = smtFunction "pow" $ \x y -> ite (y .== 0) 1 (x * pow x (y - 1))+ pow = smtFunction "pow" $ \x y -> [sCase| y of+ _ | y .<= 0 -> 1+ _ -> x * pow x (y - 1)+ |] emf :: SInteger -> SBool emf n = 7 `sDivides` (11 `pow` n - 4 `pow` n)@@ -275,6 +291,9 @@ -- Step: 6 Q.E.D. -- Step: 7 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating:+-- EnumSymbolic.Integer.enumFromThenTo.down, EnumSymbolic.Integer.enumFromThenTo.up,+-- sbv.foldr, sbv.map -- [Proven] sumMulFactorial :: Ɐn ∷ Integer → Bool sumMulFactorial :: TP (Proof (Forall "n" Integer -> SBool)) sumMulFactorial = do@@ -319,6 +338,7 @@ -- Step: 2.2.2 Q.E.D. -- Step: 2.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr -- [Proven] product0 :: Ɐxs ∷ [Integer] → Bool product0 :: TP (Proof (Forall "xs" [Integer] -> SBool)) product0 =
Documentation/SBV/Examples/TP/Peano.hs view
@@ -41,7 +41,7 @@ -- | Create a symbolic version of naturals. mkSymbolic [''Nat] --- | Numeric instance. Choices: We clamp everything at 'Zero'. Negation is identity.+-- | Numeric instance. Choices: We clamp everything at Zero. Negation is identity. instance Num Nat where fromInteger i | i <= 0 = Zero | True = Succ (fromInteger (i - 1))@@ -67,7 +67,7 @@ (+) = plus where plus = smtFunction "sNatPlus" $- \m n -> [sCase|Nat m of+ \m n -> [sCase| m of Zero -> n Succ p -> sSucc (p + n) |]@@ -76,14 +76,14 @@ (*) = times where times = smtFunction "sNatTimes" $- \m n -> [sCase|Nat m of+ \m n -> [sCase| m of Zero -> 0 Succ p -> n + p * n |] abs = id - signum m = [sCase|Nat m of+ signum m = [sCase| m of Zero -> 0 _ -> 1 |]@@ -98,21 +98,25 @@ -- -- NB. When writing the properties below, we use the notation \(\overline{n}\) to mean @n2i n@. n2i :: SNat -> SInteger-n2i = smtFunction "n2i" $ \n -> [sCase|Nat n of+n2i = smtFunction "n2i" $ \n -> [sCase| n of Zero -> 0 Succ p -> 1 + n2i p |] --- | Convert Non-negative integers to 'Nat'. Negative numbers become 'Zero'.+-- | Convert Non-negative integers to 'Nat'. Negative numbers become Zero. -- -- NB. When writing the properties below, we use the notation \(\underline{i}\) to mean @i2n i@. i2n :: SInteger -> SNat-i2n = smtFunction "i2n" $ \i -> ite (i .<= 0) 0 (sSucc (i2n (i - 1)))+i2n = smtFunction "i2n" $ \i -> [sCase| i of+ _ | i .<= 0 -> 0+ _ -> sSucc (i2n (i - 1))+ |] -- | \(\overline{n} \geq 0\) -- -- >>> runTP n2iNonNeg -- Lemma: n2iNonNeg Q.E.D.+-- Functions proven terminating: n2i -- [Proven] n2iNonNeg :: Ɐn ∷ Nat → Bool n2iNonNeg :: TP (Proof (Forall "n" Nat -> SBool)) n2iNonNeg = inductiveLemma "n2iNonNeg" (\(Forall n) -> n2i n .>= 0) []@@ -121,6 +125,7 @@ -- -- >>> runTP i2n2i -- Lemma: i2n2i Q.E.D.+-- Functions proven terminating: i2n, n2i -- [Proven] i2n2i :: Ɐi ∷ Integer → Bool i2n2i :: TP (Proof (Forall "i" Integer -> SBool)) i2n2i = inductiveLemma "i2n2i" (\(Forall i) -> n2i (i2n i) .== i `smax` 0) []@@ -129,6 +134,7 @@ -- -- >>> runTP n2i2n -- Lemma: n2i2n Q.E.D.+-- Functions proven terminating: i2n, n2i -- [Proven] n2i2n :: Ɐn ∷ Nat → Bool n2i2n :: TP (Proof (Forall "n" Nat -> SBool)) n2i2n = inductiveLemma "n2i2n" (\(Forall n) -> i2n (n2i n) .== n) []@@ -137,6 +143,7 @@ -- -- >>> runTP n2iAdd -- Lemma: n2iAdd Q.E.D.+-- Functions proven terminating: n2i, sNatPlus -- [Proven] n2iAdd :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool n2iAdd :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) n2iAdd = inductiveLemma "n2iAdd" (\(Forall m) (Forall n) -> n2i (m + n) .== n2i m + n2i n) []@@ -149,6 +156,7 @@ -- -- >>> runTP addCorrect -- Lemma: addCorrect Q.E.D.+-- Functions proven terminating: n2i, sNatPlus -- [Proven] addCorrect :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool addCorrect :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) addCorrect = inductiveLemma@@ -162,6 +170,7 @@ -- -- >>> runTP addLeftUnit -- Lemma: addLeftUnit Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] addLeftUnit :: Ɐm ∷ Nat → Bool addLeftUnit :: TP (Proof (Forall "m" Nat -> SBool)) addLeftUnit = lemma "addLeftUnit" (\(Forall m) -> 0 + m .== m) []@@ -170,6 +179,7 @@ -- -- >>> runTP addRightUnit -- Lemma: addRightUnit Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] addRightUnit :: Ɐm ∷ Nat → Bool addRightUnit :: TP (Proof (Forall "m" Nat -> SBool)) addRightUnit = inductiveLemma "addRightUnit" (\(Forall m) -> m + 0 .== m) []@@ -186,6 +196,7 @@ -- Step: 3 Q.E.D. -- Result: Q.E.D. -- Lemma: addSucc Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] addSucc :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool addSucc :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) addSucc = do@@ -215,6 +226,7 @@ -- -- >>> runTP addAssoc -- Lemma: addAssoc Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] addAssoc :: Ɐm ∷ Nat → Ɐn ∷ Nat → Ɐo ∷ Nat → Bool addAssoc :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> Forall "o" Nat -> SBool)) addAssoc = inductiveLemma@@ -237,17 +249,18 @@ -- Step: 3 Q.E.D. -- Result: Q.E.D. -- Lemma: addComm Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] addComm :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool addComm :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) addComm = do- alu <- recall "addLeftUnit" addLeftUnit- aru <- recall "addRightUnit" addRightUnit+ alu <- recall addLeftUnit+ aru <- recall addRightUnit caseZero <- lemma "caseZero" (\(Forall @"n" (n :: SNat)) -> 0 + n .== n + 0) [proofOf alu, proofOf aru] - as <- recall "addSucc" addSucc+ as <- recall addSucc caseSucc <- calc "caseSucc" (\(Forall @"m" m) (Forall @"n" n) -> m + n .== n + m .=> sSucc m + n .== n + sSucc m) $@@ -281,6 +294,7 @@ -- Step: 5 Q.E.D. -- Result: Q.E.D. -- Lemma: mullCorrect Q.E.D.+-- Functions proven terminating: n2i, sNatPlus, sNatTimes -- [Proven] mullCorrect :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool mulCorrect :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) mulCorrect = do@@ -288,7 +302,7 @@ (\(Forall @"n" n) -> n2i (0 * n) .== n2i 0 * n2i n) [] - addC <- recall "addCorrect" addCorrect+ addC <- recall addCorrect caseSucc <- calc "caseSucc" (\(Forall @"m" m) (Forall @"n" n) ->@@ -315,6 +329,7 @@ -- -- >>> runTP mulLeftAbsorb -- Lemma: mulLeftAbsorb Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulLeftAbsorb :: Ɐm ∷ Nat → Bool mulLeftAbsorb :: TP (Proof (Forall "m" Nat -> SBool)) mulLeftAbsorb = lemma "mulLeftAbsorb" (\(Forall m) -> 0 * m .== 0) []@@ -323,6 +338,7 @@ -- -- >>> runTP mulRightAbsorb -- Lemma: mulRightAbsorb Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulRightAbsorb :: Ɐm ∷ Nat → Bool mulRightAbsorb :: TP (Proof (Forall "m" Nat -> SBool)) mulRightAbsorb = inductiveLemma "mulRightAbsorb" (\(Forall m) -> m * 0 .== 0) []@@ -333,6 +349,7 @@ -- -- >>> runTP mulLeftUnit -- Lemma: mulLeftUnit Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulLeftUnit :: Ɐm ∷ Nat → Bool mulLeftUnit :: TP (Proof (Forall "m" Nat -> SBool)) mulLeftUnit = inductiveLemma "mulLeftUnit" (\(Forall m) -> sSucc 0 * m .== m) []@@ -341,6 +358,7 @@ -- -- >>> runTP mulRightUnit -- Lemma: mulRightUnit Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulRightUnit :: Ɐm ∷ Nat → Bool mulRightUnit :: TP (Proof (Forall "m" Nat -> SBool)) mulRightUnit = inductiveLemma "mulRightUnit" (\(Forall m) -> m * sSucc 0 .== m) []@@ -365,13 +383,14 @@ -- Step: 9 Q.E.D. -- Result: Q.E.D. -- Lemma: distribLeft Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] distribLeft :: Ɐm ∷ Nat → Ɐn ∷ Nat → Ɐo ∷ Nat → Bool distribLeft :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> Forall "o" Nat -> SBool)) distribLeft = do caseZero <- lemma "caseZero" (\(Forall @"n" n) (Forall @"o" (o :: SNat)) -> 0 * (n + o) .== 0 * n + 0 * o) [] - addAsc <- recall "addAssoc" addAssoc- addCom <- recall "addComm" addComm+ addAsc <- recall addAssoc+ addCom <- recall addComm caseSucc <- calc "caseSucc" (\(Forall @"m" m) (Forall @"n" n) (Forall @"o" o) ->@@ -406,7 +425,7 @@ -- Lemma: caseZero Q.E.D. -- Lemma: addAssoc Q.E.D. -- Lemma: addComm Q.E.D.--- Lemma: addSucc Q.E.D.+-- Cached: addSucc Q.E.D. -- Lemma: caseSucc -- Step: 1 Q.E.D. -- Step: 2 Q.E.D.@@ -417,14 +436,15 @@ -- Step: 7 Q.E.D. -- Result: Q.E.D. -- Lemma: distribRight Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] distribRight :: Ɐm ∷ Nat → Ɐn ∷ Nat → Ɐo ∷ Nat → Bool distribRight :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> Forall "o" Nat -> SBool)) distribRight = do caseZero <- lemma "caseZero" (\(Forall @"n" n) (Forall @"o" (o :: SNat)) -> (0 + n) * o .== 0 * o + n * o) [] - pAddAssoc <- recall "addAssoc" addAssoc- pAddCom <- recall "addComm" addComm- pAddSucc <- recall "addSucc" addSucc+ pAddAssoc <- recall addAssoc+ pAddCom <- recall addComm+ pAddSucc <- recall addSucc caseSucc <- calc "caseSucc" (\(Forall @"m" m) (Forall @"n" n) (Forall @"o" o) ->@@ -458,7 +478,7 @@ -- Lemma: addLeftUnit Q.E.D. -- Lemma: distribLeft Q.E.D. -- Lemma: mulRightUnit Q.E.D.--- Lemma: addComm Q.E.D.+-- Cached: addComm Q.E.D. -- Lemma: mulSucc -- Step: 1 Q.E.D. -- Step: 2 (defn of +) Q.E.D.@@ -466,13 +486,14 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulSucc :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool mulSucc :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) mulSucc = do- alu <- recall "addLeftUnit" addLeftUnit- dL <- recall "distribLeft" distribLeft- mru <- recall "mulRightUnit" mulRightUnit- ac <- recall "addComm" addComm+ alu <- recall addLeftUnit+ dL <- recall distribLeft+ mru <- recall mulRightUnit+ ac <- recall addComm calc "mulSucc" (\(Forall @"m" m) (Forall @"n" n) -> m * sSucc n .== m * n + m) $@@ -503,6 +524,7 @@ -- Step: 4 Q.E.D. -- Result: Q.E.D. -- Lemma: mulAssoc Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulAssoc :: Ɐm ∷ Nat → Ɐn ∷ Nat → Ɐo ∷ Nat → Bool mulAssoc :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> Forall "o" Nat -> SBool)) mulAssoc = do@@ -510,7 +532,7 @@ (\(Forall @"n" n) (Forall @"o" (o :: SNat)) -> 0 * (n * o) .== (0 * n) * o) [] - distR <- recall "distribRight" distribRight+ distR <- recall distribRight caseSucc <- calc "caseSucc" (\(Forall @"m" m) (Forall @"n" n) (Forall @"o" o) ->@@ -548,17 +570,18 @@ -- Step: 6 Q.E.D. -- Result: Q.E.D. -- Lemma: mulComm Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulComm :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool mulComm :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) mulComm = do- mra <- recall "mulRightAbsorb" mulRightAbsorb+ mra <- recall mulRightAbsorb caseZero <- lemma "caseZero" (\(Forall @"m" (m :: SNat)) -> 0 * m .== m * 0) [proofOf mra] - mru <- recall "mulRightUnit" mulRightUnit- dL <- recall "distribLeft" distribLeft+ mru <- recall mulRightUnit+ dL <- recall distribLeft caseSucc <- calc "caseSucc" (\(Forall @"m" m) (Forall @"n" n) -> m * n .== n * m .=> sSucc m * n .== n * sSucc m) $@@ -596,10 +619,11 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] ltTrans :: Ɐm ∷ Nat → Ɐn ∷ Nat → Ɐo ∷ Nat → Bool ltTrans :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> Forall "o" Nat -> SBool)) ltTrans = do- aa <- recall "addAssoc" addAssoc+ aa <- recall addAssoc calc "ltTrans" (\(Forall @"m" m) (Forall @"n" n) (Forall @"o" o) -> m .< n .&& n .< o .=> m .< o) $@@ -626,6 +650,7 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] ltIrreflexive :: Ɐm ∷ Nat → Bool ltIrreflexive :: TP (Proof (Forall "m" Nat -> SBool)) ltIrreflexive = do@@ -678,14 +703,15 @@ -- Step: 7.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: lteEquiv Q.E.D.+-- Functions proven terminating: i2n, n2i, sNatPlus -- [Proven] lteEquiv :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool lteEquiv :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) lteEquiv = do- n2ia <- recall "n2iAdd" n2iAdd- nn <- recall "n2iNonNeg" n2iNonNeg- n2i2nId <- recall "n2i2n" n2i2n- i2n2iId <- recall "i2n2i" i2n2i- aru <- recall "addRightUnit" addRightUnit+ n2ia <- recall n2iAdd+ nn <- recall n2iNonNeg+ n2i2nId <- recall n2i2n+ i2n2iId <- recall i2n2i+ aru <- recall addRightUnit ltr <- calcWith cvc5 "lteEquiv_ltr" (\(Forall @"m" m) (Forall @"n" n) -> (m .>= n) .=> (n2i m .>= n2i n)) $@@ -741,10 +767,11 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: i2n, n2i, sNatPlus -- [Proven] ordered :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool ordered :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) ordered = do- lteEq <- recall "lteEquiv" lteEquiv+ lteEq <- recall lteEquiv calcWith cvc5 "ordered" (\(Forall m) (Forall n) -> m .>= n .|| n .>= m) $@@ -760,10 +787,11 @@ -- >>> runTP trichotomy -- Lemma: ordered Q.E.D. -- Lemma: trichotomy Q.E.D.+-- Functions proven terminating: i2n, n2i, sNatPlus -- [Proven] trichotomy :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool trichotomy :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) trichotomy = do- pOrdered <- recall "ordered" ordered+ pOrdered <- recall ordered lemma "trichotomy" (\(Forall m) (Forall n) -> m .< n .|| m .== n .|| n .< m)@@ -783,11 +811,12 @@ -- Step: 4 Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] addOrder :: Ɐm ∷ Nat → Ɐn ∷ Nat → Ɐo ∷ Nat → Bool addOrder :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> Forall "o" Nat -> SBool)) addOrder = do- pAddAssoc <- recall "addAssoc" addAssoc- pAddComm <- recall "addComm" addComm+ pAddAssoc <- recall addAssoc+ pAddComm <- recall addComm calc "addOrder" (\(Forall m) (Forall n) (Forall o) -> m .< n .=> m + o .< n + o) $@@ -818,10 +847,11 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sNatPlus, sNatTimes -- [Proven] mulOrder :: Ɐm ∷ Nat → Ɐn ∷ Nat → Ɐo ∷ Nat → Bool mulOrder :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> Forall "o" Nat -> SBool)) mulOrder = do- pDistribRight <- recall "distribRight" distribRight+ pDistribRight <- recall distribRight calc "mulOrder" (\(Forall m) (Forall n) (Forall o) -> 0 .< o .&& m .< n .=> m * o .< n * o) $@@ -844,6 +874,7 @@ -- -- >>> runTP orderSum -- Lemma: orderSum Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] orderSum :: Ɐm ∷ Nat → Ɐn ∷ Nat → Bool orderSum :: TP (Proof (Forall "m" Nat -> Forall "n" Nat -> SBool)) orderSum = lemma "orderSum"@@ -856,6 +887,7 @@ -- -- >>> runTP zeroLtOne -- Lemma: zeroLtOne Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] zeroLtOne :: Bool zeroLtOne :: TP (Proof SBool) zeroLtOne = lemma "zeroLtOne" (0 .< (1 :: SNat)) []@@ -864,6 +896,7 @@ -- -- >>> runTP nothingBetweenZeroAndOne -- Lemma: nothingBetweenZeroAndOne Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] nothingBetweenZeroAndOne :: Ɐm ∷ Nat → Bool nothingBetweenZeroAndOne :: TP (Proof (Forall "m" Nat -> SBool)) nothingBetweenZeroAndOne = lemma "nothingBetweenZeroAndOne"@@ -876,6 +909,7 @@ -- -- >>> runTP minimumElt -- Lemma: minimumElt Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] minimumElt :: Ɐm ∷ Nat → Bool minimumElt :: TP (Proof (Forall "m" Nat -> SBool)) minimumElt = lemma "minimumElt" (\(Forall m) -> m .>= 0) []@@ -886,6 +920,7 @@ -- -- >>> runTP noMaximumElt -- Lemma: noMaximumElt Q.E.D.+-- Functions proven terminating: sNatPlus -- [Proven] noMaximumElt :: Ɐm ∷ Nat → ∃n ∷ Nat → Bool noMaximumElt :: TP (Proof (Forall "m" Nat -> Exists "n" Nat -> SBool)) noMaximumElt = lemma "noMaximumElt" (\(Forall m) (Exists n) -> m .< n) []
Documentation/SBV/Examples/TP/PigeonHole.hs view
@@ -40,6 +40,7 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr --[Proven] pigeonHole :: Ɐxs ∷ [Integer] → Bool pigeonHole :: TP (Proof (Forall "xs" [Integer] -> SBool)) pigeonHole = induct "pigeonHole"
Documentation/SBV/Examples/TP/PowerMod.hs view
@@ -9,10 +9,12 @@ -- Proofs about power and modulus. Adapted from an example by amigalemming, -- see <http://github.com/LeventErkok/sbv/issues/744>. ----- We also demonstrate the proof-caching features of TP.+-- We also demonstrate the use of recall for reusing previously established proofs. ----------------------------------------------------------------------------- +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} @@ -23,50 +25,81 @@ import Data.SBV import Data.SBV.TP --- | The proofs in this module are structured so they are presented at the top-level and reused.--- This results in re-running the proofs over and over, as each proof has to run all its dependents.--- To avoid re-running proofs, we tell TP to use a proof-cache. Note that use of a proof-cache comes--- with the user obligation that all proofs used are uniquely named. Otherwise the results can be--- unsound, and SBV will indicate this possibility in its output.-runCached :: TP a -> IO a-runCached = runTPWith (tpCache z3)+#ifdef DOCTEST+-- $setup+-- >>> import Data.SBV.TP+#endif -- | Power function over integers. power :: SInteger -> SInteger -> SInteger-power = smtFunction "power" $ \b n -> ite (n .<= 0) 1 (b * power b (n-1))+power = smtFunction "power" $ \b n -> [sCase| n of+ _ | n .<= 0 -> 1+ _ -> b * power b (n-1)+ |] -- | \(m > 1 \Rightarrow n + mk \equiv n \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modAddMultiple--- Inductive lemma: modAddMultiple+-- >>> runTP modAddMultiple+-- Inductive lemma: modAddMultiplePos -- Step: Base Q.E.D. -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Lemma: modAddMultiple+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D. -- [Proven] modAddMultiple :: Ɐk ∷ Integer → Ɐn ∷ Integer → Ɐm ∷ Integer → Bool modAddMultiple :: TP (Proof (Forall "k" Integer -> Forall "n" Integer -> Forall "m" Integer -> SBool)) modAddMultiple = do- inductWith (tpCache cvc5) "modAddMultiple"+ -- First prove for k >= 0 by induction. We need this restriction since+ -- the inductive hypothesis for integers is guarded by k >= 0.+ pos <- induct "modAddMultiplePos"+ (\(Forall k) (Forall n) (Forall m) -> k .>= 0 .&& m .> 1 .=> (n + m*k) `sEMod` m .== n `sEMod` m) $+ \ih k n m -> [k .>= 0, m .> 1] |- (n + m*(k+1)) `sEMod` m+ =: (n + m*k + m) `sEMod` m+ ?? m `sEMod` m .== 0+ ?? (n + m*k + m) `sEDiv` m .== (n + m*k) `sEDiv` m + 1+ =: (n + m*k) `sEMod` m+ ?? ih `at` (Inst @"n" n, Inst @"m" m)+ =: n `sEMod` m+ =: qed++ -- Extend to all k by case-splitting. For k < 0, use the positive case with+ -- k' = -k > 0 and n' = n+m*k: pos gives (n'+m*k') mod m = n' mod m,+ -- i.e., n mod m = (n+m*k) mod m.+ calc "modAddMultiple" (\(Forall k) (Forall n) (Forall m) -> m .> 1 .=> (n + m*k) `sEMod` m .== n `sEMod` m) $- \ih k n m -> [m .> 1] |- (n + m*(k+1)) `sEMod` m- =: (n + m*k + m) `sEMod` m- =: (n + m*k) `sEMod` m- ?? ih `at` (Inst @"n" n, Inst @"m" m)- =: n `sEMod` m- =: qed+ \k n m -> [m .> 1] |- cases [ k .>= 0 ==> (n + m*k) `sEMod` m+ ?? pos `at` (Inst @"k" k, Inst @"n" n, Inst @"m" m)+ =: n `sEMod` m+ =: qed+ , k .< 0 ==> (n + m*k) `sEMod` m+ ?? pos `at` (Inst @"k" (-k), Inst @"n" (n + m*k), Inst @"m" m)+ =: n `sEMod` m+ =: qed+ ] -- | \(m > 0 \Rightarrow a + b \equiv a + (b \bmod m) \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modAddRight--- Inductive lemma: modAddMultiple+-- >>> runTP modAddRight+-- Inductive lemma: modAddMultiplePos -- Step: Base Q.E.D. -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Lemma: modAddMultiple+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D. -- Lemma: modAddRight -- Step: 1 Q.E.D. -- Step: 2 Q.E.D.@@ -86,13 +119,19 @@ -- | \(m > 0 \Rightarrow a + b \equiv (a \bmod m) + b \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modAddLeft--- Inductive lemma: modAddMultiple+-- >>> runTP modAddLeft+-- Inductive lemma: modAddMultiplePos -- Step: Base Q.E.D. -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Lemma: modAddMultiple+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D. -- Lemma: modAddRight -- Step: 1 Q.E.D. -- Step: 2 Q.E.D.@@ -118,13 +157,19 @@ -- | \(m > 0 \Rightarrow a - b \equiv a - (b \bmod m) \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modSubRight--- Inductive lemma: modAddMultiple+-- >>> runTP modSubRight+-- Inductive lemma: modAddMultiplePos -- Step: Base Q.E.D. -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Lemma: modAddMultiple+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D. -- Lemma: modSubRight -- Step: 1 Q.E.D. -- Step: 2 Q.E.D.@@ -147,13 +192,19 @@ -- | \(a \geq 0 \land m > 0 \Rightarrow ab \equiv a \cdot (b \bmod m) \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modMulRightNonneg--- Inductive lemma: modAddMultiple+-- >>> runTP modMulRightNonneg+-- Inductive lemma: modAddMultiplePos -- Step: Base Q.E.D. -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Lemma: modAddMultiple+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D. -- Lemma: modAddRight -- Step: 1 Q.E.D. -- Step: 2 Q.E.D.@@ -163,7 +214,6 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D. -- Cached: modAddRight Q.E.D. -- Inductive lemma: modMulRightNonneg -- Step: Base Q.E.D.@@ -174,11 +224,11 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.--- [Proven. Cached: modAddRight] modMulRightNonneg :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool+-- [Proven] modMulRightNonneg :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool modMulRightNonneg :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> Forall "m" Integer -> SBool)) modMulRightNonneg = do mAddL <- modAddLeft- mAddR <- modAddRight+ mAddR <- recall modAddRight induct "modMulRightNonneg" (\(Forall a) (Forall b) (Forall m) -> a .>= 0 .&& m .> 0 .=> (a*b) `sEMod` m .== (a * b `sEMod` m) `sEMod` m) $@@ -198,13 +248,19 @@ -- | \(a \geq 0 \land m > 0 \Rightarrow -ab \equiv -\left(a \cdot (b \bmod m)\right) \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modMulRightNeg--- Inductive lemma: modAddMultiple+-- >>> runTP modMulRightNeg+-- Inductive lemma: modAddMultiplePos -- Step: Base Q.E.D. -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Lemma: modAddMultiple+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D. -- Lemma: modAddRight -- Step: 1 Q.E.D. -- Step: 2 Q.E.D.@@ -214,12 +270,7 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Lemma: modSubRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.+-- Lemma: modSubRight Q.E.D. -- Inductive lemma: modMulRightNeg -- Step: Base Q.E.D. -- Step: 1 Q.E.D.@@ -229,11 +280,11 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.--- [Proven. Cached: modAddMultiple] modMulRightNeg :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool+-- [Proven] modMulRightNeg :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool modMulRightNeg :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> Forall "m" Integer -> SBool)) modMulRightNeg = do mAddL <- modAddLeft- mSubR <- modSubRight+ mSubR <- recall modSubRight induct "modMulRightNeg" (\(Forall a) (Forall b) (Forall m) -> a .>= 0 .&& m .> 0 .=> (-(a*b)) `sEMod` m .== (-(a * b `sEMod` m)) `sEMod` m) $@@ -253,13 +304,19 @@ -- | \(m > 0 \Rightarrow ab \equiv a \cdot (b \bmod m) \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modMulRight--- Inductive lemma: modAddMultiple+-- >>> runTP modMulRight+-- Inductive lemma: modAddMultiplePos -- Step: Base Q.E.D. -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Lemma: modAddMultiple+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D. -- Lemma: modAddRight -- Step: 1 Q.E.D. -- Step: 2 Q.E.D.@@ -269,7 +326,6 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D. -- Cached: modAddRight Q.E.D. -- Inductive lemma: modMulRightNonneg -- Step: Base Q.E.D.@@ -280,24 +336,7 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Lemma: modSubRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Inductive lemma: modMulRightNeg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.+-- Lemma: modMulRightNeg Q.E.D. -- Lemma: modMulRight -- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D.@@ -306,11 +345,11 @@ -- Step: 1.2.3 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.--- [Proven. Cached: modAddLeft, modAddMultiple, modAddRight] modMulRight :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool+-- [Proven] modMulRight :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool modMulRight :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> Forall "m" Integer -> SBool)) modMulRight = do mMulNonneg <- modMulRightNonneg- mMulNeg <- modMulRightNeg+ mMulNeg <- recall modMulRightNeg calc "modMulRight" (\(Forall a) (Forall b) (Forall m) -> m .> 0 .=> (a*b) `sEMod` m .== (a * b `sEMod` m) `sEMod` m) $@@ -329,68 +368,17 @@ -- | \(m > 0 \Rightarrow ab \equiv (a \bmod m) \cdot b \pmod{m}\) -- -- ==== __Proof__--- >>> runCached modMulLeft--- Inductive lemma: modAddMultiple--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddLeft--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Inductive lemma: modMulRightNonneg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Lemma: modSubRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Inductive lemma: modMulRightNeg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Lemma: modMulRight--- Step: 1 (2 way case split)--- Step: 1.1 Q.E.D.--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2 Q.E.D.--- Step: 1.2.3 Q.E.D.--- Step: 1.Completeness Q.E.D.--- Result: Q.E.D.+-- >>> runTP modMulLeft+-- Lemma: modMulRight Q.E.D. -- Lemma: modMulLeft -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.--- [Proven. Cached: modAddLeft, modAddMultiple, modAddRight] modMulLeft :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool+-- [Proven] modMulLeft :: Ɐa ∷ Integer → Ɐb ∷ Integer → Ɐm ∷ Integer → Bool modMulLeft :: TP (Proof (Forall "a" Integer -> Forall "b" Integer -> Forall "m" Integer -> SBool)) modMulLeft = do- mMulR <- modMulRight+ mMulR <- recall modMulRight calc "modMulLeft" (\(Forall a) (Forall b) (Forall m) -> m .> 0 .=> (a*b) `sEMod` m .== (a `sEMod` m * b) `sEMod` m) $@@ -404,76 +392,8 @@ -- | \(n \geq 0 \land m > 0 \Rightarrow b^n \equiv (b \bmod m)^n \pmod{m}\) -- -- ==== __Proof__--- >>> runCached powerMod--- Inductive lemma: modAddMultiple--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddLeft--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Inductive lemma: modMulRightNonneg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Lemma: modSubRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Inductive lemma: modMulRightNeg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Lemma: modMulRight--- Step: 1 (2 way case split)--- Step: 1.1 Q.E.D.--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2 Q.E.D.--- Step: 1.2.3 Q.E.D.--- Step: 1.Completeness Q.E.D.--- Result: Q.E.D.--- Lemma: modMulLeft--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modMulRightNonneg Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modSubRight Q.E.D.--- Cached: modMulRightNeg Q.E.D.+-- >>> runTP powerMod+-- Lemma: modMulLeft Q.E.D. -- Cached: modMulRight Q.E.D. -- Inductive lemma: powerModInduct -- Step: Base Q.E.D.@@ -485,11 +405,12 @@ -- Step: 6 Q.E.D. -- Result: Q.E.D. -- Lemma: powerMod Q.E.D.--- [Proven. Cached: modAddLeft, modAddMultiple, modAddRight, modMulRight] powerMod :: Ɐb ∷ Integer → Ɐn ∷ Integer → Ɐm ∷ Integer → Bool+-- Functions proven terminating: power+-- [Proven] powerMod :: Ɐb ∷ Integer → Ɐn ∷ Integer → Ɐm ∷ Integer → Bool powerMod :: TP (Proof (Forall "b" Integer -> Forall "n" Integer -> Forall "m" Integer -> SBool)) powerMod = do- mMulL <- modMulLeft- mMulR <- modMulRight+ mMulL <- recall modMulLeft+ mMulR <- recall modMulRight -- We want to write the b parameter first, but need to induct on n. So, this helper rearranges the parameters only. pMod <- induct "powerModInduct"@@ -515,12 +436,13 @@ -- | \(n \geq 0 \Rightarrow 1^n = 1\) -- -- ==== __Proof__--- >>> runCached onePower+-- >>> runTP onePower -- Inductive lemma: onePower -- Step: Base Q.E.D. -- Step: 1 (unfold power) Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: power -- [Proven] onePower :: Ɐn ∷ Integer → Bool onePower :: TP (Proof (Forall "n" Integer -> SBool)) onePower = induct "onePower"@@ -535,91 +457,8 @@ -- | \(n \geq 0 \Rightarrow (27^n \bmod 13) = 1\) -- -- ==== __Proof__--- >>> runCached powerOf27--- Inductive lemma: onePower--- Step: Base Q.E.D.--- Step: 1 (unfold power) Q.E.D.--- Step: 2 Q.E.D.--- Result: Q.E.D.--- Inductive lemma: modAddMultiple--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddLeft--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Inductive lemma: modMulRightNonneg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Lemma: modSubRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Inductive lemma: modMulRightNeg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Lemma: modMulRight--- Step: 1 (2 way case split)--- Step: 1.1 Q.E.D.--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2 Q.E.D.--- Step: 1.2.3 Q.E.D.--- Step: 1.Completeness Q.E.D.--- Result: Q.E.D.--- Lemma: modMulLeft--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modMulRightNonneg Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modSubRight Q.E.D.--- Cached: modMulRightNeg Q.E.D.--- Cached: modMulRight Q.E.D.--- Inductive lemma: powerModInduct--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.+-- >>> runTP powerOf27+-- Lemma: onePower Q.E.D. -- Lemma: powerMod Q.E.D. -- Lemma: powerOf27 -- Step: 1 Q.E.D.@@ -627,11 +466,12 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.--- [Proven. Cached: modAddLeft, modAddMultiple, modAddRight, modMulRight] powerOf27 :: Ɐn ∷ Integer → Bool+-- Functions proven terminating: power+-- [Proven] powerOf27 :: Ɐn ∷ Integer → Bool powerOf27 :: TP (Proof (Forall "n" Integer -> SBool)) powerOf27 = do- pOne <- onePower- pMod <- powerMod+ pOne <- recall onePower+ pMod <- recall powerMod calc "powerOf27" (\(Forall n) -> n .>= 0 .=> power 27 n `sEMod` 13 .== 1) $ \n -> [n .>= 0] |- power 27 n `sEMod` 13@@ -646,105 +486,16 @@ -- | \(n \geq 0 \wedge m > 0 \implies (27^{\frac{n}{3}} \bmod 13) \cdot 3^{n \bmod 3} \equiv 3^{n \bmod 3} \pmod{m}\) -- -- ==== __Proof__--- >>> runCached powerOfThreeMod13VarDivisor--- Inductive lemma: onePower--- Step: Base Q.E.D.--- Step: 1 (unfold power) Q.E.D.--- Step: 2 Q.E.D.--- Result: Q.E.D.--- Inductive lemma: modAddMultiple--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Result: Q.E.D.--- Lemma: modAddLeft--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Inductive lemma: modMulRightNonneg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Lemma: modSubRight--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Inductive lemma: modMulRightNeg--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Lemma: modMulRight--- Step: 1 (2 way case split)--- Step: 1.1 Q.E.D.--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2 Q.E.D.--- Step: 1.2.3 Q.E.D.--- Step: 1.Completeness Q.E.D.--- Result: Q.E.D.--- Lemma: modMulLeft--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Result: Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modMulRightNonneg Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modAddRight Q.E.D.--- Cached: modAddLeft Q.E.D.--- Cached: modAddMultiple Q.E.D.--- Cached: modSubRight Q.E.D.--- Cached: modMulRightNeg Q.E.D.--- Cached: modMulRight Q.E.D.--- Inductive lemma: powerModInduct--- Step: Base Q.E.D.--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Step: 5 Q.E.D.--- Step: 6 Q.E.D.--- Result: Q.E.D.--- Lemma: powerMod Q.E.D.--- Lemma: powerOf27--- Step: 1 Q.E.D.--- Step: 2 Q.E.D.--- Step: 3 Q.E.D.--- Step: 4 Q.E.D.--- Result: Q.E.D.+-- >>> runTP powerOfThreeMod13VarDivisor+-- Lemma: powerOf27 Q.E.D. -- Lemma: powerOfThreeMod13VarDivisor -- Step: 1 Q.E.D. -- Result: Q.E.D.--- [Proven. Cached: modAddLeft, modAddMultiple, modAddRight, modMulRight] powerOfThreeMod13VarDivisor :: Ɐn ∷ Integer → Ɐm ∷ Integer → Bool+-- Functions proven terminating: power+-- [Proven] powerOfThreeMod13VarDivisor :: Ɐn ∷ Integer → Ɐm ∷ Integer → Bool powerOfThreeMod13VarDivisor :: TP (Proof (Forall "n" Integer -> Forall "m" Integer -> SBool)) powerOfThreeMod13VarDivisor = do- p27 <- powerOf27+ p27 <- recall powerOf27 calc "powerOfThreeMod13VarDivisor" (\(Forall n) (Forall m) -> n .>= 0 .&& m .> 0 .=> power 27 (n `sEDiv` 3) `sEMod` 13 * power 3 (n `sEMod` 3) `sEMod` m
Documentation/SBV/Examples/TP/Primes.hs view
@@ -13,6 +13,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} @@ -79,7 +80,7 @@ -- [Proven] dividesTransitive :: Ɐx ∷ Integer → Ɐy ∷ Integer → Ɐz ∷ Integer → Bool dividesTransitive :: TP (Proof (Forall "x" Integer -> Forall "y" Integer -> Forall "z" Integer -> SBool)) dividesTransitive = do- dp <- recall "dividesProduct" dividesProduct+ dp <- recall dividesProduct calc "dividesTransitive" (\(Forall x) (Forall y) (Forall z) -> x `dvd` y .&& y `dvd` z .=> x `dvd` z) $@@ -104,7 +105,12 @@ -- @n@ that is at least @k@ is the number that is at least @k@ and divides @n@ evenly. The idea is that a number is -- prime if the least divisor starting from @2@ is itself. ld :: SInteger -> SInteger -> SInteger-ld = smtFunction "ld" $ \k n -> ite (n `sEMod` k .== 0) k (ld (k+1) n)+ld = smtFunctionWithMeasure "ld" (\k n -> (n - k) `smax` 0, [])+ $ \k n -> [sCase| tuple (k .<= 0 .|| k .> n, n `sEMod` k) of+ (True, _) -> 0+ (_, 0) -> k+ _ -> ld (k+1) n+ |] -- | \(1 < k \leq n \implies \mathit{ld}\,k\,n \mid n \land k \leq \mathit{ld}\,k\,n \leq n\) --@@ -117,6 +123,7 @@ -- Step: 1.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ld -- [Proven] leastDivisorDivides :: Ɐk ∷ Integer → Ɐn ∷ Integer → Bool leastDivisorDivides :: TP (Proof (Forall "k" Integer -> Forall "n" Integer -> SBool)) leastDivisorDivides =@@ -147,6 +154,7 @@ -- Step: 1.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ld -- [Proven] leastDivisorisLeast :: Ɐk ∷ Integer → Ɐn ∷ Integer → Ɐd ∷ Integer → Bool leastDivisorIsLeast :: TP (Proof (Forall "k" Integer -> Forall "n" Integer -> Forall "d" Integer -> SBool)) leastDivisorIsLeast =@@ -169,7 +177,7 @@ -- >>> runTP leastDivisorTwice -- Lemma: dividesTransitive Q.E.D. -- Lemma: leastDivisorDivides Q.E.D.--- Lemma: leastDivisorIsLeast Q.E.D.+-- Lemma: leastDivisorisLeast Q.E.D. -- Lemma: helper1 Q.E.D. -- Lemma: helper2 Q.E.D. -- Lemma: helper3@@ -180,12 +188,13 @@ -- Step: 1 Q.E.D. -- Result: Q.E.D. -- Lemma: leastDivisorTwice Q.E.D.+-- Functions proven terminating: ld -- [Proven] leastDivisorTwice :: Ɐk ∷ Integer → Ɐn ∷ Integer → Bool leastDivisorTwice :: TP (Proof (Forall "k" Integer -> Forall "n" Integer -> SBool)) leastDivisorTwice = do- dt <- recall "dividesTransitive" dividesTransitive- ldd <- recall "leastDivisorDivides" leastDivisorDivides- ldl <- recall "leastDivisorIsLeast" leastDivisorIsLeast+ dt <- recall dividesTransitive+ ldd <- recall leastDivisorDivides+ ldl <- recall leastDivisorIsLeast h1 <- lemmaWith cvc5 "helper1"@@ -235,6 +244,7 @@ -- === __Proof__ -- >>> runTP primeAtLeast2 -- Lemma: primeAtLeast2 Q.E.D.+-- Functions proven terminating: ld -- [Proven] primeAtLeast2 :: Ɐp ∷ Integer → Bool primeAtLeast2 :: TP (Proof (Forall "p" Integer -> SBool)) primeAtLeast2 = lemma "primeAtLeast2" (\(Forall p) -> isPrime p .=> p .>= 2) []@@ -244,15 +254,16 @@ -- === __Proof__ -- >>> runTP leastDivisorIsPrime -- Lemma: leastDivisorTwice Q.E.D.--- Lemma: leastDivisorDivides Q.E.D.+-- Cached: leastDivisorDivides Q.E.D. -- Lemma: leastDivisorIsPrime -- Step: 1 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ld -- [Proven] leastDivisorIsPrime :: Ɐn ∷ Integer → Bool leastDivisorIsPrime :: TP (Proof (Forall "n" Integer -> SBool)) leastDivisorIsPrime = do- ldt <- recall "leastDivisorTwice" leastDivisorTwice- ldd <- recall "leastDivisorDivides" leastDivisorDivides+ ldt <- recall leastDivisorTwice+ ldd <- recall leastDivisorDivides calc "leastDivisorIsPrime" (\(Forall n) -> n .>= 2 .=> isPrime (ld 2 n)) $@@ -271,7 +282,10 @@ -- | The factorial function. fact :: SInteger -> SInteger-fact = smtFunction "fact" $ \n -> ite (n .<= 0) 1 (n * fact (n - 1))+fact = smtFunction "fact" $ \n -> [sCase| n of+ _ | n .<= 0 -> 1+ _ -> n * fact (n - 1)+ |] -- | \(n! \geq 1\) --@@ -285,6 +299,7 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: fact -- [Proven] factAtLeast1 :: Ɐn ∷ Integer → Bool factAtLeast1 :: TP (Proof (Forall "n" Integer -> SBool)) factAtLeast1 = inductWith cvc5 "factAtLeast1"@@ -312,10 +327,11 @@ -- Step: 2.2.2 Q.E.D. -- Step: 2.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: fact -- [Proven] dividesFact :: Ɐn ∷ Integer → Ɐk ∷ Integer → Bool dividesFact :: TP (Proof (Forall "n" Integer -> Forall "k" Integer -> SBool)) dividesFact = do- dvp <- recall "dividesProduct" dividesProduct+ dvp <- recall dividesProduct induct "dividesFact" (\(Forall n) (Forall k) -> 1 .<= k .&& k .<= n .=> k `dvd` fact n) $@@ -343,10 +359,11 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: fact -- [Proven] notDividesFactP1 :: Ɐn ∷ Integer → Ɐk ∷ Integer → Bool notDividesFactP1 :: TP (Proof (Forall "n" Integer -> Forall "k" Integer -> SBool)) notDividesFactP1 = do- df <- recall "dividesFact" dividesFact+ df <- recall dividesFact calc "notDividesFactP1" (\(Forall n) (Forall k) -> 1 .< k .&& k .<= n .=> sNot (k `dvd` (fact n + 1))) $@@ -375,11 +392,12 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: fact, ld -- [Proven] greaterPrimeDivides :: Ɐn ∷ Integer → Bool greaterPrimeDivides :: TP (Proof (Forall "n" Integer -> SBool)) greaterPrimeDivides = do- ldd <- recall "leastDivisorDivides" leastDivisorDivides- fal1 <- recall "factAtLeast1" factAtLeast1+ ldd <- recall leastDivisorDivides+ fal1 <- recall factAtLeast1 calc "greaterPrimeDivides" (\(Forall n) -> greaterPrime n `dvd` (1 + fact n)) $@@ -398,7 +416,7 @@ -- Lemma: notDividesFactP1 Q.E.D. -- Lemma: greaterPrimeDivides Q.E.D. -- Lemma: leastDivisorIsPrime Q.E.D.--- Lemma: factAtLeast1 Q.E.D.+-- Cached: factAtLeast1 Q.E.D. -- Lemma: primeAtLeast2 Q.E.D. -- Lemma: greaterPrimeGreater -- Step: 1 Q.E.D.@@ -408,14 +426,15 @@ -- Step: 5 Q.E.D. -- Step: 6 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: fact, ld -- [Proven] greaterPrimeGreater :: Ɐn ∷ Integer → Bool greaterPrimeGreater :: TP (Proof (Forall "n" Integer -> SBool)) greaterPrimeGreater = do- ndfp1 <- recall "notDividesFactP1" notDividesFactP1- gpd <- recall "greaterPrimeDivides" greaterPrimeDivides- ldp <- recall "leastDivisorIsPrime" leastDivisorIsPrime- fal1 <- recall "factAtLeast1" factAtLeast1- pal2 <- recall "primeAtLeast2" primeAtLeast2+ ndfp1 <- recall notDividesFactP1+ gpd <- recall greaterPrimeDivides+ ldp <- recall leastDivisorIsPrime+ fal1 <- recall factAtLeast1+ pal2 <- recall primeAtLeast2 calc "greaterPrimeGreater" (\(Forall n) -> greaterPrime n .> n) $@@ -450,12 +469,13 @@ -- Step: 2 Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: fact, ld -- [Proven] infinitudeOfPrimes :: Ɐn ∷ Integer → Bool infinitudeOfPrimes :: TP (Proof (Forall "n" Integer -> SBool)) infinitudeOfPrimes = do- ldp <- recall "leastDivisorIsPrime" leastDivisorIsPrime- fa1 <- recall "factAtLeast1" factAtLeast1- gpg <- recall "greaterPrimeGreater" greaterPrimeGreater+ ldp <- recall leastDivisorIsPrime+ fa1 <- recall factAtLeast1+ gpg <- recall greaterPrimeGreater calc "infinitudeOfPrimes" (\(Forall n) -> let p = greaterPrime n in p .> n .&& isPrime p) $@@ -481,10 +501,11 @@ -- Step: 1 Q.E.D. -- Result: Q.E.D. -- Lemma: noLargestPrime Q.E.D.+-- Functions proven terminating: fact, ld -- [Proven] noLargestPrime :: Ɐn ∷ Integer → ∃p ∷ Integer → Bool noLargestPrime :: TP (Proof (Forall "n" Integer -> Exists "p" Integer -> SBool)) noLargestPrime = do- iop <- recall "infinitudeOfPrimes" infinitudeOfPrimes+ iop <- recall infinitudeOfPrimes h <- calc "helper" (\(Forall @"n" n) -> quantifiedBool (\(Exists p) -> isPrime p .&& p .> n)) $
Documentation/SBV/Examples/TP/QuickSort.hs view
@@ -16,6 +16,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-}@@ -38,30 +39,106 @@ #ifdef DOCTEST -- $setup -- >>> :set -XTypeApplications+-- >>> import Data.SBV.TP #endif -- * Quick sort -- | Quick-sort, using the first element as pivot.-quickSort :: (OrdSymbolic (SBV a), SymVal a) => SList a -> SList a-quickSort = smtFunction "quickSort" $ \l -> ite (null l)- []- (let (x, xs) = uncons l- (lo, hi) = untuple (partition x xs)- in quickSort lo ++ [x] ++ quickSort hi)+quickSort :: forall a. (OrdSymbolic (SBV a), SymVal a) => SList a -> SList a+quickSort = smtFunctionWithMeasure "quickSort"+ ( length @a+ , [ measureLemma (partitionFstBound @a)+ , measureLemma (partitionSndBound @a)+ ]+ )+ $ \l -> [sCase| l of+ [] -> []+ x : xs -> case partition x xs of+ (lo, hi) -> quickSort lo ++ [x] ++ quickSort hi+ |] -- | We define @partition@ as an explicit function. Unfortunately, we can't just replace this -- with @\pivot xs -> Data.List.SBV.partition (.< pivot) xs@ because that would create a firstified version of partition -- with a free-variable captured, which isn't supported due to higher-order limitations in SMTLib. partition :: (OrdSymbolic (SBV a), SymVal a) => SBV a -> SList a -> STuple [a] [a]-partition = smtFunction "partition" $ \pivot xs -> ite (null xs)- (tuple ([], []))- (let (a, as) = uncons xs- (lo, hi) = untuple (partition pivot as)- in ite (a .< pivot)- (tuple (a .: lo, hi))- (tuple (lo, a .: hi)))+partition = smtFunction "partition"+ $ \pivot xs -> [sCase| xs of+ [] -> tuple ([], [])+ a : as -> case partition pivot as of+ (lo, hi) | a .< pivot -> tuple (a .: lo, hi)+ | True -> tuple (lo, a .: hi)+ |] +-- | The first component of partition is no longer than the input.+--+-- >>> runTP $ partitionFstBound @Integer+-- Inductive lemma (strong): partitionNotLongerFst+-- Step: Measure is non-negative Q.E.D.+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2.1 Q.E.D.+-- Step: 1.2.2 (simplify) Q.E.D.+-- Step: 1.2.3 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: partition+-- [Proven] partitionNotLongerFst :: Ɐl ∷ [Integer] → Ɐpivot ∷ Integer → Bool+partitionFstBound :: forall a. (OrdSymbolic (SBV a), SymVal a) => TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))+partitionFstBound = sInduct "partitionNotLongerFst"+ (\(Forall l) (Forall pivot) -> length (fst (partition @a pivot l)) .<= length l)+ (\l _ -> length l, []) $+ \ih l pivot -> [] |- length (fst (partition @a pivot l)) .<= length l+ =: [pCase| l of+ [] -> trivial+ whole@(a : as) ->+ let lo = fst (partition pivot as)+ in ite (a .< pivot)+ (length (a .: lo) .<= length whole)+ (length lo .<= length whole)+ ?? "simplify"+ =: ite (a .< pivot)+ (length lo .<= length as)+ (length lo .<= 1 + length as)+ ?? ih `at` (Inst @"l" as, Inst @"pivot" pivot)+ =: sTrue+ =: qed+ |]++-- | The second component of partition is no longer than the input.+--+-- >>> runTP $ partitionSndBound @Integer+-- Inductive lemma (strong): partitionNotLongerSnd+-- Step: Measure is non-negative Q.E.D.+-- Step: 1 (2 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2.1 Q.E.D.+-- Step: 1.2.2 (simplify) Q.E.D.+-- Step: 1.2.3 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: partition+-- [Proven] partitionNotLongerSnd :: Ɐl ∷ [Integer] → Ɐpivot ∷ Integer → Bool+partitionSndBound :: forall a. (OrdSymbolic (SBV a), SymVal a) => TP (Proof (Forall "l" [a] -> Forall "pivot" a -> SBool))+partitionSndBound = sInduct "partitionNotLongerSnd"+ (\(Forall l) (Forall pivot) -> length (snd (partition @a pivot l)) .<= length l)+ (\l _ -> length l, []) $+ \ih l pivot -> [] |- length (snd (partition @a pivot l)) .<= length l+ =: [pCase| l of+ [] -> trivial+ whole@(a : as) -> let hi = snd (partition pivot as)+ in ite (a .< pivot)+ (length hi .<= length whole)+ (length (a .: hi) .<= length whole)+ ?? "simplify"+ =: ite (a .< pivot)+ (length hi .<= 1 + length as)+ (length hi .<= length as)+ ?? ih `at` (Inst @"l" as, Inst @"pivot" pivot)+ =: sTrue+ =: qed+ |]+ -- * Correctness proof -- | Correctness of quick-sort.@@ -147,22 +224,8 @@ -- Step: 2 (push lge down) Q.E.D. -- Step: 3 Q.E.D. -- Result: Q.E.D.--- Inductive lemma (strong): partitionNotLongerFst--- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)--- Step: 1.1 Q.E.D.--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2 (simplify) Q.E.D.--- Step: 1.2.3 Q.E.D.--- Result: Q.E.D.--- Inductive lemma (strong): partitionNotLongerSnd--- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)--- Step: 1.1 Q.E.D.--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2 (simplify) Q.E.D.--- Step: 1.2.3 Q.E.D.--- Result: Q.E.D.+-- Lemma: partitionNotLongerFst Q.E.D.+-- Lemma: partitionNotLongerSnd Q.E.D. -- Inductive lemma: countPartition -- Step: Base Q.E.D. -- Step: 1 (expand partition) Q.E.D.@@ -178,7 +241,7 @@ -- Result: Q.E.D. -- Inductive lemma (strong): sortCountsMatch -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2.1 Q.E.D. -- Step: 1.2.2 (expand quickSort) Q.E.D.@@ -188,11 +251,12 @@ -- Step: 1.2.6 (IH on lo) Q.E.D. -- Step: 1.2.7 (IH on hi) Q.E.D. -- Step: 1.2.8 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: sortIsPermutation Q.E.D. -- Inductive lemma: nonDecreasingMerge -- Step: Base Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2.1 Q.E.D. -- Step: 1.2.2 Q.E.D.@@ -201,15 +265,17 @@ -- Step: 1.2.5 Q.E.D. -- Step: 1.2.6 Q.E.D. -- Step: 1.2.7 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Inductive lemma (strong): sortIsNonDecreasing -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (2 way case split) -- Step: 1.1 Q.E.D. -- Step: 1.2.1 Q.E.D. -- Step: 1.2.2 (expand quickSort) Q.E.D. -- Step: 1.2.3 (push nonDecreasing down) Q.E.D. -- Step: 1.2.4 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: quickSortIsCorrect Q.E.D. -- Inductive lemma: partitionSortedLeft@@ -261,6 +327,7 @@ -- │ │ └╴sublistTail -- │ └╴sublistIfPerm -- └╴nonDecreasingMerge+-- Functions proven terminating: count, lge, llt, nonDecreasing, partition, quickSort -- [Proven] quickSortIsCorrect :: Ɐxs ∷ [Integer] → Bool correctness :: forall a. (Eq a, OrdSymbolic (SBV a), SymVal a) => IO (Proof (Forall "xs" [a] -> SBool)) correctness = runTPWith (tpRibbon 60 z3) $ do@@ -284,8 +351,16 @@ -- llt: list less-than: all the elements are < pivot -- lge: list greater-equal: all the elements are >= pivot let llt, lge :: SBV a -> SList a -> SBool- llt = smtFunction "llt" $ \pivot l -> null l .|| let (x, xs) = uncons l in x .< pivot .&& llt pivot xs- lge = smtFunction "lge" $ \pivot l -> null l .|| let (x, xs) = uncons l in x .>= pivot .&& lge pivot xs+ llt = smtFunction "llt"+ $ \pivot l -> [sCase| l of+ [] -> sTrue+ x : xs -> x .< pivot .&& llt pivot xs+ |]+ lge = smtFunction "lge"+ $ \pivot l -> [sCase| l of+ [] -> sTrue+ x : xs -> x .>= pivot .&& lge pivot xs+ |] -- llt correctness lltCorrect <-@@ -404,40 +479,10 @@ =: qed -- The first element of partition does not increase in size- partitionNotLongerFst <- sInduct "partitionNotLongerFst"- (\(Forall l) (Forall pivot) -> length (fst (partition @a pivot l)) .<= length l)- (\l _ -> length l, []) $- \ih l pivot -> [] |- length (fst (partition @a pivot l)) .<= length l- =: split l trivial- (\a as -> let lo = fst (partition pivot as)- in ite (a .< pivot)- (length (a .: lo) .<= length (a .: as))- (length lo .<= length (a .: as))- ?? "simplify"- =: ite (a .< pivot)- (length lo .<= length as)- (length lo .<= 1 + length as)- ?? ih `at` (Inst @"l" as, Inst @"pivot" pivot)- =: sTrue- =: qed)+ partitionNotLongerFst <- recall (partitionFstBound @a) -- The second element of partition does not increase in size- partitionNotLongerSnd <- sInduct "partitionNotLongerSnd"- (\(Forall l) (Forall pivot) -> length (snd (partition @a pivot l)) .<= length l)- (\l _ -> length l, []) $- \ih l pivot -> [] |- length (snd (partition @a pivot l)) .<= length l- =: split l trivial- (\a as -> let hi = snd (partition pivot as)- in ite (a .< pivot)- (length hi .<= length (a .: as))- (length (a .: hi) .<= length (a .: as))- ?? "simplify"- =: ite (a .< pivot)- (length hi .<= 1 + length as)- (length hi .<= length as)- ?? ih `at` (Inst @"l" as, Inst @"pivot" pivot)- =: sTrue- =: qed)+ partitionNotLongerSnd <- recall (partitionSndBound @a) -------------------------------------------------------------------------------------------- -- Part IV. Helper lemmas for count@@ -490,29 +535,32 @@ (\xs _ -> length xs, []) $ \ih xs e -> [] |- count e (quickSort xs)- =: split xs trivial- (\a as -> count e (quickSort (a .: as))- ?? "expand quickSort"- =: count e (let (lo, hi) = untuple (partition a as)- in quickSort lo ++ [a] ++ quickSort hi)- ?? "push count down"- =: let (lo, hi) = untuple (partition a as)- in count e (quickSort lo ++ [a] ++ quickSort hi)- ?? countAppend `at` (Inst @"xs" (quickSort lo), Inst @"ys" ([a] ++ quickSort hi), Inst @"e" e)- =: count e (quickSort lo) + count e ([a] ++ quickSort hi)- ?? countAppend `at` (Inst @"xs" [a], Inst @"ys" (quickSort hi), Inst @"e" e)- =: count e (quickSort lo) + count e [a] + count e (quickSort hi)- ?? ih `at` (Inst @"xs" lo, Inst @"e" e)- ?? partitionNotLongerFst `at` (Inst @"l" as, Inst @"pivot" a)- ?? "IH on lo"- =: count e lo + count e [a] + count e (quickSort hi)- ?? ih `at` (Inst @"xs" hi, Inst @"e" e)- ?? partitionNotLongerSnd `at` (Inst @"l" as, Inst @"pivot" a)- ?? "IH on hi"- =: count e lo + count e [a] + count e hi- ?? countPartition `at` (Inst @"xs" as, Inst @"pivot" a, Inst @"e" e)- =: count e xs- =: qed)+ =: [pCase| xs of+ [] -> trivial+ whole@(a : as) ->+ count e (quickSort whole)+ ?? "expand quickSort"+ =: count e (case partition a as of+ (lo, hi) -> quickSort lo ++ [a] ++ quickSort hi)+ ?? "push count down"+ =: case partition a as of+ (lo, hi) -> count e (quickSort lo ++ [a] ++ quickSort hi)+ ?? countAppend `at` (Inst @"xs" (quickSort lo), Inst @"ys" ([a] ++ quickSort hi), Inst @"e" e)+ =: count e (quickSort lo) + count e ([a] ++ quickSort hi)+ ?? countAppend `at` (Inst @"xs" [a], Inst @"ys" (quickSort hi), Inst @"e" e)+ =: count e (quickSort lo) + count e [a] + count e (quickSort hi)+ ?? ih `at` (Inst @"xs" lo, Inst @"e" e)+ ?? partitionNotLongerFst `at` (Inst @"l" as, Inst @"pivot" a)+ ?? "IH on lo"+ =: count e lo + count e [a] + count e (quickSort hi)+ ?? ih `at` (Inst @"xs" hi, Inst @"e" e)+ ?? partitionNotLongerSnd `at` (Inst @"l" as, Inst @"pivot" a)+ ?? "IH on hi"+ =: count e lo + count e [a] + count e hi+ ?? countPartition `at` (Inst @"xs" as, Inst @"pivot" a, Inst @"e" e)+ =: count e xs+ =: qed+ |] sortIsPermutation <- lemma "sortIsPermutation" (\(Forall xs) -> isPermutation xs (quickSort xs)) [proofOf sortCountsMatch] @@ -527,18 +575,21 @@ \ih (x, xs) pivot ys -> [nonDecreasing (x .: xs), llt pivot xs, nonDecreasing ys, lge pivot ys] |- nonDecreasing (x .: xs ++ [pivot] ++ ys)- =: split xs trivial- (\a as -> nonDecreasing (x .: (a .: as) ++ [pivot] ++ ys)- =: nonDecreasing (x .: a .: (as ++ [pivot] ++ ys))- =: x .<= a .&& nonDecreasing (a .: (as ++ [pivot] ++ ys))- =: nonDecreasing (a .: (as ++ [pivot] ++ ys))- =: nonDecreasing ((a .: as) ++ [pivot] ++ ys)- =: nonDecreasing (xs ++ [pivot] ++ ys)- -- This hint shouldn't be necessary, but it makes the proof go faster!- ?? nonDecreasing xs- ?? ih- =: sTrue- =: qed)+ =: [pCase| xs of+ [] -> trivial+ whole@(a : as) ->+ nonDecreasing (x .: whole ++ [pivot] ++ ys)+ =: nonDecreasing (x .: a .: (as ++ [pivot] ++ ys))+ =: x .<= a .&& nonDecreasing (a .: (as ++ [pivot] ++ ys))+ =: nonDecreasing (a .: (as ++ [pivot] ++ ys))+ =: nonDecreasing (whole ++ [pivot] ++ ys)+ =: nonDecreasing (xs ++ [pivot] ++ ys)+ -- This hint shouldn't be necessary, but it makes the proof go faster!+ ?? nonDecreasing xs+ ?? ih+ =: sTrue+ =: qed+ |] -------------------------------------------------------------------------------------------- -- Part VII. Prove that the output of quick sort is non-decreasing@@ -549,38 +600,41 @@ (length @a, []) $ \ih xs -> [] |- nonDecreasing (quickSort xs)- =: split xs trivial- (\a as -> nonDecreasing (quickSort (a .: as))- ?? "expand quickSort"- =: nonDecreasing (let (lo, hi) = untuple (partition a as)- in quickSort lo ++ [a] ++ quickSort hi)- ?? "push nonDecreasing down"- =: let (lo, hi) = untuple (partition a as)- in nonDecreasing (quickSort lo ++ [a] ++ quickSort hi)- -- Deduce that lo/hi is not longer than as, and hence, shorter than xs- ?? partitionNotLongerFst `at` (Inst @"l" as, Inst @"pivot" a)- ?? partitionNotLongerSnd `at` (Inst @"l" as, Inst @"pivot" a)+ =: [pCase| xs of+ [] -> trivial+ whole@(a : as) ->+ nonDecreasing (quickSort whole)+ ?? "expand quickSort"+ =: nonDecreasing (case partition a as of+ (lo, hi) -> quickSort lo ++ [a] ++ quickSort hi)+ ?? "push nonDecreasing down"+ =: case partition a as of+ (lo, hi) -> nonDecreasing (quickSort lo ++ [a] ++ quickSort hi)+ -- Deduce that lo/hi is not longer than as, and hence, shorter than xs+ ?? partitionNotLongerFst `at` (Inst @"l" as, Inst @"pivot" a)+ ?? partitionNotLongerSnd `at` (Inst @"l" as, Inst @"pivot" a) - -- Use the inductive hypothesis twice to deduce quickSort of lo and hi are nonDecreasing- ?? ih `at` Inst @"xs" lo -- nonDecreasing (quickSort lo)- ?? ih `at` Inst @"xs" hi -- nonDecreasing (quickSort hi)+ -- Use the inductive hypothesis twice to deduce quickSort of lo and hi are nonDecreasing+ ?? ih `at` Inst @"xs" lo -- nonDecreasing (quickSort lo)+ ?? ih `at` Inst @"xs" hi -- nonDecreasing (quickSort hi) - -- Deduce that lo is all less than a, and hi is all greater than or equal to a- ?? partitionFstLT `at` (Inst @"l" as, Inst @"pivot" a)- ?? partitionSndGE `at` (Inst @"l" as, Inst @"pivot" a)+ -- Deduce that lo is all less than a, and hi is all greater than or equal to a+ ?? partitionFstLT `at` (Inst @"l" as, Inst @"pivot" a)+ ?? partitionSndGE `at` (Inst @"l" as, Inst @"pivot" a) - -- Deduce that quickSort lo is all less than a- ?? sortIsPermutation `at` Inst @"xs" lo- ?? lltPermutation `at` (Inst @"xs" (quickSort lo), Inst @"pivot" a, Inst @"ys" lo)+ -- Deduce that quickSort lo is all less than a+ ?? sortIsPermutation `at` Inst @"xs" lo+ ?? lltPermutation `at` (Inst @"xs" (quickSort lo), Inst @"pivot" a, Inst @"ys" lo) - -- Deduce that quickSort hi is all greater than or equal to a- ?? sortIsPermutation `at` Inst @"xs" hi- ?? lgePermutation `at` (Inst @"xs" (quickSort hi), Inst @"pivot" a, Inst @"ys" hi)+ -- Deduce that quickSort hi is all greater than or equal to a+ ?? sortIsPermutation `at` Inst @"xs" hi+ ?? lgePermutation `at` (Inst @"xs" (quickSort hi), Inst @"pivot" a, Inst @"ys" hi) - -- Finally conclude that the whole reconstruction is non-decreasing- ?? nonDecreasingMerge `at` (Inst @"xs" (quickSort lo), Inst @"pivot" a, Inst @"ys" (quickSort hi))- =: sTrue- =: qed)+ -- Finally conclude that the whole reconstruction is non-decreasing+ ?? nonDecreasingMerge `at` (Inst @"xs" (quickSort lo), Inst @"pivot" a, Inst @"ys" (quickSort hi))+ =: sTrue+ =: qed+ |] -------------------------------------------------------------------------------------------- -- Part VIII. Putting it together
Documentation/SBV/Examples/TP/RevAcc.hs view
@@ -13,6 +13,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeAbstractions #-} @@ -35,7 +36,11 @@ -- | Accummulating reverse. revAcc :: SymVal a => SList a -> SList a -> SList a-revAcc = smtFunction "revAcc" $ \acc xs -> ite (null xs) acc (revAcc (head xs .: acc) (tail xs))+revAcc = smtFunction "revAcc"+ $ \acc xs -> [sCase| xs of+ [] -> acc+ a : as -> revAcc (a .: acc) as+ |] -- | Given 'revAcc', we can reverse a list by providing the empty list as the initial accumulator. rev :: SymVal a => SList a -> SList a@@ -54,6 +59,7 @@ -- Step: 4 Q.E.D. -- Result: Q.E.D. -- Lemma: revCorrect Q.E.D.+-- Functions proven terminating: revAcc, sbv.reverse -- [Proven] revCorrect :: Ɐxs ∷ [Integer] → Bool correctness :: forall a. SymVal a => IO (Proof (Forall "xs" [a] -> SBool)) correctness = runTP $ do
Documentation/SBV/Examples/TP/Reverse.hs view
@@ -17,6 +17,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} @@ -41,14 +42,54 @@ -- * Reversing with no auxiliaries -- | This definition of reverse uses no helper functions, other than the usual--- head, tail, cons, and uncons to reverse a given list. Note that efficiency+-- head, tail, and cons to reverse a given list. Note that efficiency -- is not our concern here, we call 'rev' itself three times in the body.-rev :: SymVal a => SList a -> SList a-rev = smtFunction "rev" $ \xs -> ite (null xs .|| null (tail xs)) xs- (let (x, as) = uncons xs- (hras, tas) = uncons (rev as)- in hras .: rev (x .: rev tas))+rev :: forall a. SymVal a => SList a -> SList a+rev = smtFunctionWithMeasure "rev"+ ( length @a+ , [measureLemma (revPreservesLen @a)]+ )+ $ \xs -> [sCase| xs of+ [] -> xs+ x : as -> case rev as of+ [] -> [x]+ hras : tas -> hras .: rev (x .: rev tas)+ |] +-- | Reversing preserves length. Needed as a measure helper for 'rev'.+--+-- >>> runTP $ revPreservesLen @Integer+-- Inductive lemma (strong): revPreservesLen+-- Step: Measure is non-negative Q.E.D.+-- Step: 1 (3 way case split)+-- Step: 1.1 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.3.1 Q.E.D.+-- Step: 1.3.2 Q.E.D.+-- Step: 1.3.3 Q.E.D.+-- Step: 1.Completeness Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: rev+-- [Proven] revPreservesLen :: Ɐxs ∷ [Integer] → Bool+revPreservesLen :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> SBool))+revPreservesLen = sInductWith cvc5 "revPreservesLen"+ (\(Forall xs) -> length (rev @a xs) .== length xs)+ (length, []) $+ \ih xs -> [] |- length (rev @a xs) .== length xs+ =: [pCase| xs of+ [] -> trivial+ [_] -> trivial+ whole@(a : as) -> length (head (rev as) .: rev (a .: rev (tail (rev as)))) .== length whole+ -- Simplify: length (h .: e) = 1 + length e+ =: (1 + length (rev (a .: rev (tail (rev as))))) .== (1 + length as)+ -- Now apply the IH instances in order: each precondition depends on previous conclusions+ ?? ih `at` Inst @"xs" as+ ?? ih `at` Inst @"xs" (tail (rev as))+ ?? ih `at` Inst @"xs" (a .: rev (tail (rev as)))+ =: sTrue+ =: qed+ |]+ -- * Correctness proof -- | Correctness the function 'rev'. We have:@@ -60,73 +101,76 @@ -- Lemma: revRev Q.E.D. -- Inductive lemma (strong): revCorrect -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (3 way case split) -- Step: 1.1 Q.E.D.--- Step: 1.2 (2 way full case split)--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2.1 Q.E.D.--- Step: 1.2.2.2 Q.E.D.--- Step: 1.2.2.3 Q.E.D.--- Step: 1.2.2.4 Q.E.D.--- Step: 1.2.2.5 Q.E.D.--- Step: 1.2.2.6 (simplify head) Q.E.D.--- Step: 1.2.2.7 Q.E.D.--- Step: 1.2.2.8 (simplify tail) Q.E.D.--- Step: 1.2.2.9 Q.E.D.--- Step: 1.2.2.10 Q.E.D.--- Step: 1.2.2.11 Q.E.D.--- Step: 1.2.2.12 (substitute) Q.E.D.--- Step: 1.2.2.13 Q.E.D.--- Step: 1.2.2.14 Q.E.D.--- Step: 1.2.2.15 Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.3.1 Q.E.D.+-- Step: 1.3.2 Q.E.D.+-- Step: 1.3.3 Q.E.D.+-- Step: 1.3.4 Q.E.D.+-- Step: 1.3.5 Q.E.D.+-- Step: 1.3.6 (simplify head) Q.E.D.+-- Step: 1.3.7 Q.E.D.+-- Step: 1.3.8 (simplify tail) Q.E.D.+-- Step: 1.3.9 Q.E.D.+-- Step: 1.3.10 Q.E.D.+-- Step: 1.3.11 Q.E.D.+-- Step: 1.3.12 (substitute) Q.E.D.+-- Step: 1.3.13 Q.E.D.+-- Step: 1.3.14 Q.E.D.+-- Step: 1.3.15 Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: rev, sbv.reverse -- [Proven] revCorrect :: Ɐxs ∷ [Integer] → Bool correctness :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> SBool)) correctness = do -- Quietly import a few helpers from "Data.SBV.TP.List"- revLen <- recall "revLen" $ TP.revLen @a- revApp <- recall "revApp" $ TP.revApp @a- revSnoc <- recall "revSnoc" $ TP.revSnoc @a- revRev <- recall "revRev" $ TP.revRev @a+ revLen <- recall $ TP.revLen @a+ revApp <- recall $ TP.revApp @a+ revSnoc <- recall $ TP.revSnoc @a+ revRev <- recall $ TP.revRev @a sInductWith cvc5 "revCorrect" (\(Forall xs) -> rev xs .== reverse xs) (length, []) $ \ih xs -> [] |- rev xs- =: split xs trivial- (\a as -> split as trivial- (\_ _ -> head (rev as) .: rev (a .: rev (tail (rev as)))- ?? ih `at` Inst @"xs" as- =: head (reverse as) .: rev (a .: rev (tail (rev as)))- ?? ih `at` Inst @"xs" as- =: head (reverse as) .: rev (a .: rev (tail (reverse as)))- ?? ih `at` Inst @"xs" (tail (rev as))- =: head (reverse as) .: rev (a .: rev (tail (reverse as)))- ?? revSnoc `at` (Inst @"x" (last as), Inst @"xs" (init as))- =: let w = init as- b = last as- in head (b .: reverse w) .: rev (a .: rev (tail (reverse as)))- ?? "simplify head"- =: b .: rev (a .: rev (tail (reverse as)))- ?? revSnoc `at` (Inst @"x" (last xs), Inst @"xs" (init as))- =: b .: rev (a .: rev (tail (b .: reverse w)))- ?? "simplify tail"- =: b .: rev (a .: rev (reverse w))- ?? ih `at` Inst @"xs" (reverse w)- ?? revLen `at` Inst @"xs" w- =: b .: rev (a .: reverse (reverse w))- ?? revRev `at` Inst @"xs" w- =: b .: rev (a .: w)- ?? ih- =: b .: reverse (a .: w)- ?? "substitute"- =: last as .: reverse (a .: init as)- ?? revApp `at` (Inst @"xs" (a .: init as), Inst @"ys" [last as])- =: reverse (a .: init as ++ [last as])- =: reverse (a .: as)- =: reverse xs- =: qed))+ =: [pCase| xs of+ [] -> trivial+ [_] -> trivial+ a : as -> head (rev as) .: rev (a .: rev (tail (rev as)))+ ?? ih `at` Inst @"xs" as+ =: head (reverse as) .: rev (a .: rev (tail (rev as)))+ ?? ih `at` Inst @"xs" as+ =: head (reverse as) .: rev (a .: rev (tail (reverse as)))+ ?? ih `at` Inst @"xs" (tail (rev as))+ =: head (reverse as) .: rev (a .: rev (tail (reverse as)))+ ?? revSnoc `at` (Inst @"x" (last as), Inst @"xs" (init as))+ =: let w = init as+ b = last as+ in head (b .: reverse w) .: rev (a .: rev (tail (reverse as)))+ ?? "simplify head"+ =: b .: rev (a .: rev (tail (reverse as)))+ ?? revSnoc `at` (Inst @"x" (last xs), Inst @"xs" (init as))+ =: b .: rev (a .: rev (tail (b .: reverse w)))+ ?? "simplify tail"+ =: b .: rev (a .: rev (reverse w))+ ?? ih `at` Inst @"xs" (reverse w)+ ?? revLen `at` Inst @"xs" w+ =: b .: rev (a .: reverse (reverse w))+ ?? revRev `at` Inst @"xs" w+ =: b .: rev (a .: w)+ ?? ih+ =: b .: reverse (a .: w)+ ?? "substitute"+ =: last as .: reverse (a .: init as)+ ?? revApp `at` (Inst @"xs" (a .: init as), Inst @"ys" [last as])+ =: reverse (a .: init as ++ [last as])+ =: reverse (a .: as)+ =: reverse xs+ =: qed+ |] {- HLint ignore correctness "Use last" -} {- HLint ignore correctness "Redundant reverse" -}
Documentation/SBV/Examples/TP/SortHelpers.hs view
@@ -12,6 +12,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-}@@ -20,7 +21,7 @@ module Documentation.SBV.Examples.TP.SortHelpers where -import Prelude hiding (null, tail, elem, head, (++), take, drop)+import Prelude hiding (null, length, tail, elem, head, (++), take, drop) import Data.SBV import Data.SBV.List@@ -35,10 +36,12 @@ -- | A predicate testing whether a given list is non-decreasing. nonDecreasing :: (OrdSymbolic (SBV a), SymVal a) => SList a -> SBool-nonDecreasing = smtFunction "nonDecreasing" $ \l -> null l .|| null (tail l)- .|| let (x, l') = uncons l- (y, _) = uncons l'- in x .<= y .&& nonDecreasing l'+nonDecreasing = smtFunction "nonDecreasing"+ $ \l -> [sCase| l of+ [] -> sTrue+ [_] -> sTrue+ x : rest@(y : _) -> x .<= y .&& nonDecreasing rest+ |] -- | Are two lists permutations of each other? isPermutation :: SymVal a => SList a -> SList a -> SBool@@ -48,6 +51,7 @@ -- -- >>> runTP $ nonDecrTail @Integer -- Lemma: nonDecrTail Q.E.D.+-- Functions proven terminating: nonDecreasing -- [Proven] nonDecrTail :: Ɐx ∷ Integer → Ɐxs ∷ [Integer] → Bool nonDecrTail :: forall a. (OrdSymbolic (SBV a), SymVal a) => TP (Proof (Forall "x" a -> Forall "xs" [a] -> SBool)) nonDecrTail = lemma "nonDecrTail"@@ -58,6 +62,7 @@ -- -- >>> runTP $ nonDecrIns @Integer -- Lemma: nonDecrInsert Q.E.D.+-- Functions proven terminating: nonDecreasing -- [Proven] nonDecrInsert :: Ɐx ∷ Integer → Ɐxs ∷ [Integer] → Bool nonDecrIns :: forall a. (OrdSymbolic (SBV a), SymVal a) => TP (Proof (Forall "x" a -> Forall "xs" [a] -> SBool)) nonDecrIns = lemma "nonDecrInsert"@@ -100,6 +105,7 @@ -- Lemma: sublistCorrect -- Step: 1 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count -- [Proven] sublistCorrect :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Ɐx ∷ Integer → Bool sublistCorrect :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> Forall "x" a -> SBool)) sublistCorrect = do@@ -151,6 +157,7 @@ -- Lemma: sublistElem -- Step: 1 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: count -- [Proven] sublistElem :: Ɐx ∷ Integer → Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool sublistElem :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)) sublistElem = do@@ -168,6 +175,7 @@ -- -- >>> runTP $ sublistTail @Integer -- Lemma: sublistTail Q.E.D.+-- Functions proven terminating: count -- [Proven] sublistTail :: Ɐx ∷ Integer → Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool sublistTail :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "x" a -> Forall "xs" [a] -> Forall "ys" [a] -> SBool)) sublistTail =@@ -179,6 +187,7 @@ -- -- >>> runTP $ sublistIfPerm @Integer -- Lemma: sublistIfPerm Q.E.D.+-- Functions proven terminating: count -- [Proven] sublistIfPerm :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool sublistIfPerm :: forall a. (Eq a, SymVal a) => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) sublistIfPerm = lemma "sublistIfPerm"
Documentation/SBV/Examples/TP/StrongInduction.hs view
@@ -11,6 +11,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-}+{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-}@@ -48,13 +49,17 @@ -- Step: 1.3.3 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: seq -- [Proven] oddSequence1 :: Ɐn ∷ Integer → Bool oddSequence1 :: IO (Proof (Forall "n" Integer -> SBool)) oddSequence1 = runTP $ do let s :: SInteger -> SInteger- s = smtFunction "seq" $ \n -> ite (n .<= 0) 1- $ ite (n .== 1) 3- $ s (n-2) + 2 * s (n-1)+ s = smtFunction "seq"+ $ \n -> [sCase| n of+ _ | n .<= 0 -> 1+ _ | n .== 1 -> 3+ _ -> s (n-2) + 2 * s (n-1)+ |] -- z3 can't handle this, but CVC5 is proves it just fine. -- Note also that we do a "proof-by-contradiction," by deriving that@@ -95,13 +100,17 @@ -- Step: 1.3.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: seq -- [Proven] oddSequence2 :: Ɐn ∷ Integer → Bool oddSequence2 :: IO (Proof (Forall "n" Integer -> SBool)) oddSequence2 = runTPWith (tpRibbon 50 z3) $ do let s :: SInteger -> SInteger- s = smtFunction "seq" $ \n -> ite (n .<= 0) 1- $ ite (n .== 1) 3- $ 2 * s (n-1) - s (n-2)+ s = smtFunction "seq"+ $ \n -> [sCase| n of+ _ | n .<= 0 -> 1+ _ | n .== 1 -> 3+ _ -> 2 * s (n-1) - s (n-2)+ |] s0 <- lemma "oddSequence_0" (s 0 .== 1) [] s1 <- lemma "oddSequence_1" (s 1 .== 3) []@@ -149,7 +158,11 @@ won'tProve1 :: IO () won'tProve1 = runTP $ do let len :: SList Integer -> SInteger- len = smtFunction "len" $ \xs -> ite (null xs) 0 (1 + len (tail xs))+ len = smtFunction "len"+ $ \xs -> [sCase| xs of+ [] -> 0+ _ : as -> 1 + len as+ |] -- Run it for 5 seconds, as otherwise z3 will hang as it can't prove make the inductive step _ <- sInductWith z3{extraArgs = ["-t:5000"]} "lengthGood"@@ -175,11 +188,11 @@ won'tProve2 :: IO () won'tProve2 = runTP $ do let len :: SList Integer -> SInteger- len = smtFunction "badLength" $ \xs -> ite (null xs)- 123- (ite (null xs)- 0- (1 + len (tail xs)))+ len = smtFunction "badLength"+ $ \xs -> [sCase| xs of+ [] -> 123+ _ : as -> 1 + len as+ |] _ <- sInduct "badLength" (\(Forall xs) -> len xs .== length xs)@@ -229,7 +242,11 @@ let -- a bizarre (but valid!) way to sum two integers weirdSum :: SInteger -> SInteger -> SInteger- weirdSum = smtFunction "weirdSum" (\x y -> ite (x .<= 0) y (weirdSum (x - 1) (y + 1)))+ weirdSum = smtFunction "weirdSum"+ $ \x y -> [sCase| x of+ _ | x .<= 0 -> y+ _ -> weirdSum (x - 1) (y + 1)+ |] _ <- sInductWith z3{extraArgs = ["-t:5000"]} "badMeasure" (\(Forall x) (Forall y) -> x .>= 0 .=> weirdSum x y .== x + y)@@ -261,26 +278,30 @@ -- Result: Q.E.D. -- Inductive lemma (strong): sumHalves -- Step: Measure is non-negative Q.E.D.--- Step: 1 (2 way full case split)+-- Step: 1 (3 way case split) -- Step: 1.1 Q.E.D.--- Step: 1.2 (2 way full case split)--- Step: 1.2.1 Q.E.D.--- Step: 1.2.2.1 Q.E.D.--- Step: 1.2.2.2 Q.E.D.--- Step: 1.2.2.3 Q.E.D.--- Step: 1.2.2.4 Q.E.D.--- Step: 1.2.2.5 Q.E.D.--- Step: 1.2.2.6 (simplify) Q.E.D.+-- Step: 1.2 Q.E.D.+-- Step: 1.3.1 Q.E.D.+-- Step: 1.3.2 Q.E.D.+-- Step: 1.3.3 Q.E.D.+-- Step: 1.3.4 Q.E.D.+-- Step: 1.3.5 Q.E.D.+-- Step: 1.3.6 (simplify) Q.E.D.+-- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: halvingSum, sbv.foldr -- [Proven] sumHalves :: Ɐxs ∷ [Integer] → Bool sumHalves :: IO (Proof (Forall "xs" [Integer] -> SBool)) sumHalves = runTP $ do let halvingSum :: SList Integer -> SInteger- halvingSum = smtFunction "halvingSum" $ \xs -> ite (null xs .|| null (tail xs))- (sum xs)- (let (f, s) = splitAt (length xs `sDiv` 2) xs- in halvingSum f + halvingSum s)+ halvingSum = smtFunction "halvingSum"+ $ \xs -> [sCase| xs of+ [] -> sum xs+ [_] -> sum xs+ _ -> let (f, s) = splitAt (length xs `sDiv` 2) xs+ in halvingSum f + halvingSum s+ |] helper <- induct "sumAppend" (\(Forall xs) (Forall ys) -> sum (xs ++ ys) .== sum xs + sum ys) $@@ -296,17 +317,20 @@ (\(Forall xs) -> halvingSum xs .== sum xs) (length, []) $ \ih xs -> [] |- halvingSum xs- =: split xs qed- (\a as -> split as qed- (\b bs -> halvingSum (a .: b .: bs)- =: let (f, s) = splitAt (length (a .: b .: bs) `sDiv` 2) (a .: b .: bs)- in halvingSum f + halvingSum s- ?? ih `at` Inst @"xs" f- =: sum f + halvingSum s- ?? ih `at` Inst @"xs" s- =: sum f + sum s- ?? helper `at` (Inst @"xs" f, Inst @"ys" s)- =: sum (f ++ s)- ?? "simplify"- =: sum (a .: b .: bs)- =: qed))+ =: [pCase| xs of+ [] -> qed+ [_] -> qed+ whole@(_ : _ : _) ->+ halvingSum whole+ =: let (f, s) = splitAt (length whole `sDiv` 2) whole+ in halvingSum f + halvingSum s+ ?? ih `at` Inst @"xs" f+ =: sum f + halvingSum s+ ?? ih `at` Inst @"xs" s+ =: sum f + sum s+ ?? helper `at` (Inst @"xs" f, Inst @"ys" s)+ =: sum (f ++ s)+ ?? "simplify"+ =: sum whole+ =: qed+ |]
Documentation/SBV/Examples/TP/SumReverse.hs view
@@ -52,6 +52,7 @@ -- Step: 4 (commutativity) Q.E.D. -- Step: 5 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: sbv.foldr, sbv.reverse -- [Proven] sumReverse :: Ɐxs ∷ [Integer] → Bool revSum :: forall a. (SymVal a, Num (SBV a)) => IO (Proof (Forall "xs" [a] -> SBool)) revSum = runTP $ do
Documentation/SBV/Examples/TP/TautologyChecker.hs view
@@ -60,31 +60,34 @@ -- | Depth of nested If constructors in the condition position. ifDepth :: SFormula -> SInteger-ifDepth = smtFunction "ifDepth" $ \f -> [sCase|Formula f of- If c _ _ -> 1 + ifDepth c- _ -> 0- |]+ifDepth = smtFunction "ifDepth"+ $ \f -> [sCase| f of+ If c _ _ -> 1 + ifDepth c+ _ -> 0+ |] -- | \(\mathit{ifDepth}(f) \geq 0\) -- -- >>> runTP ifDepthNonNeg -- Lemma: ifDepthNonNeg Q.E.D.+-- Functions proven terminating: ifDepth -- [Proven] ifDepthNonNeg :: Ɐf ∷ Formula → Bool ifDepthNonNeg :: TP (Proof (Forall "f" Formula -> SBool)) ifDepthNonNeg = inductiveLemma "ifDepthNonNeg" (\(Forall f) -> ifDepth f .>= 0) [] -- | Complexity of a formula (for termination measure). ifComplexity :: SFormula -> SInteger-ifComplexity = smtFunction "ifComplexity" $ \f ->- [sCase|Formula f of- If c l r -> ifComplexity c * (ifComplexity l + ifComplexity r)- _ -> 1- |]+ifComplexity = smtFunction "ifComplexity"+ $ \f -> [sCase| f of+ If c l r -> ifComplexity c * (ifComplexity l + ifComplexity r)+ _ -> 1+ |] -- | \(\mathit{ifComplexity}(f) > 0\) -- -- >>> runTP ifComplexityPos -- Lemma: ifComplexityPos Q.E.D.+-- Functions proven terminating: ifComplexity -- [Proven] ifComplexityPos :: Ɐf ∷ Formula → Bool ifComplexityPos :: TP (Proof (Forall "f" Formula -> SBool)) ifComplexityPos = inductiveLemma "ifComplexityPos" (\(Forall f) -> ifComplexity f .> 0) []@@ -95,27 +98,40 @@ -- -- >>> runTP ifComplexitySmaller -- Lemma: ifComplexityPos Q.E.D.--- Lemma: ifComplexitySmaller Q.E.D.+-- Lemma: ifComplexitySmaller+-- Step: 1 Q.E.D.+-- Result: Q.E.D.+-- Functions proven terminating: ifComplexity -- [Proven] ifComplexitySmaller :: Ɐc ∷ Formula → Ɐl ∷ Formula → Ɐr ∷ Formula → Bool ifComplexitySmaller :: TP (Proof (Forall "c" Formula -> Forall "l" Formula -> Forall "r" Formula -> SBool)) ifComplexitySmaller = do- icp <- recall "ifComplexityPos" ifComplexityPos+ icp <- recall ifComplexityPos - lemma "ifComplexitySmaller"- (\(Forall c) (Forall l) (Forall r) ->- let ic = ifComplexity (sIf c l r)- in ifComplexity c .< ic .&& ifComplexity l .< ic .&& ifComplexity r .< ic)- [proofOf icp]+ calc "ifComplexitySmaller"+ (\(Forall c) (Forall l) (Forall r) ->+ let ic = ifComplexity (sIf c l r)+ in ifComplexity c .< ic .&& ifComplexity l .< ic .&& ifComplexity r .< ic) $+ \c l r ->+ let ic = ifComplexity (sIf c l r)+ cc = ifComplexity c+ cl = ifComplexity l+ cr = ifComplexity r+ in [] |- cc .< ic .&& cl .< ic .&& cr .< ic+ ?? icp `at` Inst @"f" c+ ?? icp `at` Inst @"f" l+ ?? icp `at` Inst @"f" r+ =: sTrue+ =: qed -- * Normalization -- | Check if a formula is in normal form (no nested If in condition position). isNormal :: SFormula -> SBool-isNormal = smtFunction "isNormal" $ \f ->- [sCase|Formula f of- If c p q -> sNot (isIf c) .&& isNormal p .&& isNormal q- _ -> sTrue- |]+isNormal = smtFunction "isNormal"+ $ \f -> [sCase| f of+ If c p q -> sNot (isIf c) .&& isNormal p .&& isNormal q+ _ -> sTrue+ |] -- | Normalize a formula by eliminating nested Ifs in condition position. --@@ -129,12 +145,19 @@ -- -- Note that this transformation increases the size of the formula, but reduces its complexity. normalize :: SFormula -> SFormula-normalize = smtFunction "normalize" $ \f ->- [sCase|Formula f of- If (If p q r) left right -> normalize (sIf p (sIf q left right) (sIf r left right))- If c left right -> sIf c (normalize left) (normalize right)- _ -> f- |]+normalize = smtFunctionWithMeasure "normalize"+ ( \f -> tuple (ifComplexity f, ifDepth f)+ , [ measureLemma ifDepthNonNeg+ , measureLemma ifComplexityPos+ , measureLemmaWith z3 ifComplexitySmaller+ , measureLemmaWith z3 normalizePreservesComplexity+ ]+ )+ $ \f -> [sCase| f of+ If (If p q r) left right -> normalize (sIf p (sIf q left right) (sIf r left right))+ If c left right -> sIf c (normalize left) (normalize right)+ _ -> f+ |] -- | The normalization transformation preserves complexity. --@@ -151,6 +174,7 @@ -- Step: 6 Q.E.D. -- Step: 7 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ifComplexity -- [Proven] normalizePreservesComplexity :: Ɐp ∷ Formula → Ɐq ∷ Formula → Ɐs ∷ Formula → Ɐl ∷ Formula → Ɐr ∷ Formula → Bool normalizePreservesComplexity :: TP (Proof (Forall "p" Formula -> Forall "q" Formula -> Forall "s" Formula -> Forall "l" Formula -> Forall "r" Formula -> SBool)) normalizePreservesComplexity = do@@ -193,23 +217,21 @@ -- | Look up a variable in the binding list. If it's not in the list, then it's false. lookUp :: SInteger -> SList Binding -> SBool-lookUp = smtFunction "lookUp" $ \vid bs ->- ite (null bs)- sFalse- [sCase|Binding (head bs) of- Binding bId bVal -> ite (vid .== bId)- bVal- (lookUp vid (tail bs))- |]+lookUp = smtFunction "lookUp"+ $ \vid bs -> [sCase| bs of+ [] -> sFalse+ Binding bId bVal : rest | vid .== bId -> bVal+ | True -> lookUp vid rest+ |] -- | Check if a variable is assigned in the bindings. isAssigned :: SInteger -> SList Binding -> SBool-isAssigned = smtFunction "isAssigned" $ \vid bs ->- ite (null bs)- sFalse- [sCase|Binding (head bs) of- Binding bId _ -> bId .== vid .|| isAssigned vid (tail bs)- |]+isAssigned = smtFunction "isAssigned"+ $ \vid bs -> [sCase| bs of+ [] -> sFalse+ Binding bId _ : rst | bId .== vid -> sTrue+ | True -> isAssigned vid rst+ |] -- | Add a binding assuming the variable is true. assumeTrue :: SInteger -> SList Binding -> SList Binding@@ -223,6 +245,7 @@ -- -- >>> runTP isAssignedExtends -- Lemma: isAssignedExtends Q.E.D.+-- Functions proven terminating: isAssigned -- [Proven] isAssignedExtends :: Ɐi ∷ Integer → Ɐn ∷ Integer → Ɐv ∷ Bool → Ɐbs ∷ [Binding] → Bool isAssignedExtends :: TP (Proof (Forall "i" Integer -> Forall "n" Integer -> Forall "v" Bool -> Forall "bs" [Binding] -> SBool)) isAssignedExtends = lemma "isAssignedExtends"@@ -233,6 +256,7 @@ -- -- >>> runTP lookUpExtends -- Lemma: lookUpExtends Q.E.D.+-- Functions proven terminating: isAssigned, lookUp -- [Proven] lookUpExtends :: Ɐi ∷ Integer → Ɐn ∷ Integer → Ɐv ∷ Bool → Ɐbs ∷ [Binding] → Bool lookUpExtends :: TP (Proof (Forall "i" Integer -> Forall "n" Integer -> Forall "v" Bool -> Forall "bs" [Binding] -> SBool)) lookUpExtends = lemma "lookUpExtends"@@ -244,6 +268,7 @@ -- -- >>> runTP lookUpSame -- Lemma: lookUpSame Q.E.D.+-- Functions proven terminating: lookUp -- [Proven] lookUpSame :: Ɐn ∷ Integer → Ɐv ∷ Bool → Ɐbs ∷ [Binding] → Bool lookUpSame :: TP (Proof (Forall "n" Integer -> Forall "v" Bool -> Forall "bs" [Binding] -> SBool)) lookUpSame = lemma "lookUpSame" (\(Forall n) (Forall v) (Forall bs) -> lookUp n (sBinding n v .: bs) .== v) []@@ -252,6 +277,7 @@ -- -- >>> runTP isAssignedSame -- Lemma: isAssignedSame Q.E.D.+-- Functions proven terminating: isAssigned -- [Proven] isAssignedSame :: Ɐn ∷ Integer → Ɐv ∷ Bool → Ɐbs ∷ [Binding] → Bool isAssignedSame :: TP (Proof (Forall "n" Integer -> Forall "v" Bool -> Forall "bs" [Binding] -> SBool)) isAssignedSame = lemma "isAssignedSame" (\(Forall n) (Forall v) (Forall bs) -> isAssigned n (sBinding n v .: bs)) []@@ -260,20 +286,21 @@ -- | Evaluate a formula under a binding environment. eval :: SFormula -> SList Binding -> SBool-eval = smtFunction "eval" $ \f bs ->- [sCase|Formula f of- Var n -> lookUp n bs- If c l r -> ite (eval c bs) (eval l bs) (eval r bs)- FTrue -> sTrue- FFalse -> sFalse- |]+eval = smtFunction "eval"+ $ \f bs -> [sCase| f of+ Var n -> lookUp n bs+ If c l r | eval c bs -> eval l bs+ | True -> eval r bs+ FTrue -> sTrue+ FFalse -> sFalse+ |] -- * Tautology checking -- | Check if a normalized formula is a tautology. isTautology' :: SFormula -> SList Binding -> SBool isTautology' = smtFunction "isTautology'" $ \f bs ->- [sCase|Formula f of+ [sCase| f of -- Trivial cases FTrue -> sTrue FFalse -> sFalse@@ -319,6 +346,7 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: isAssigned, lookUp -- [Proven] lookUpStable :: Ɐa ∷ [Binding] → Ɐx ∷ Integer → Ɐb ∷ [Binding] → Bool lookUpStable :: TP (Proof (Forall "a" [Binding] -> Forall "x" Integer -> Forall "b" [Binding] -> SBool)) lookUpStable =@@ -348,13 +376,14 @@ -- Step: 1.2.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: isAssigned, lookUp -- [Proven] trueIsAssigned :: Ɐa ∷ [Binding] → Ɐx ∷ Integer → Bool trueIsAssigned :: TP (Proof (Forall "a" [Binding] -> Forall "x" Integer -> SBool)) trueIsAssigned = induct "trueIsAssigned" (\(Forall a) (Forall x) -> lookUp x a .=> isAssigned x a) $ \ih (binding, a) x ->- let vid = [sCase|Binding binding of Binding v _ -> v|]+ let vid = [sCase| binding of Binding v _ -> v|] in [lookUp x (binding .: a)] |- isAssigned x (binding .: a) =: cases [ vid .== x ==> trivial@@ -385,11 +414,12 @@ -- Step: 1.4.6 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: eval, ifComplexity, lookUp -- [Proven] evalStable :: Ɐf ∷ Formula → Ɐx ∷ Integer → Ɐv ∷ Bool → Ɐbs ∷ [Binding] → Bool evalStable :: TP (Proof (Forall "f" Formula -> Forall "x" Integer -> Forall "v" Bool -> Forall "bs" [Binding] -> SBool)) evalStable = do- icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller sInduct "evalStable" (\(Forall f) (Forall x) (Forall v) (Forall bs) -> v .== lookUp x bs .=> eval f (sBinding x v .: bs) .== eval f bs)@@ -473,15 +503,16 @@ -- Step: 1.4.Completeness Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: eval, ifComplexity, isAssigned, isNormal, isTautology', lookUp -- [Proven] tautologyImpliesEval :: Ɐf ∷ Formula → Ɐa ∷ [Binding] → Ɐb ∷ [Binding] → Bool tautologyImpliesEval :: TP (Proof (Forall "f" Formula -> Forall "a" [Binding] -> Forall "b" [Binding] -> SBool)) tautologyImpliesEval = do - icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller- lus <- recall "lookUpStable" lookUpStable- tia <- recall "trueIsAssigned" trueIsAssigned- evs <- recall "evalStable" evalStable+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller+ lus <- recall lookUpStable+ tia <- recall trueIsAssigned+ evs <- recall evalStable sInduct "tautologyImpliesEval" (\(Forall f) (Forall a) (Forall b) -> isNormal f .&& isTautology' f b .=> eval f (b ++ a))@@ -596,13 +627,14 @@ -- Step: 1.4.Completeness Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ifComplexity, ifDepth, isNormal, normalize -- [Proven] normalizeCorrect :: Ɐf ∷ Formula → Bool normalizeCorrect :: TP (Proof (Forall "f" Formula -> SBool)) normalizeCorrect = do- icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller- npc <- recall "normalizePreservesComplexity" normalizePreservesComplexity- idn <- recall "ifDepthNonNeg" ifDepthNonNeg+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller+ npc <- recall normalizePreservesComplexity+ idn <- recall ifDepthNonNeg sInductWith cvc5 "normalizeCorrect" (\(Forall f) -> isNormal (normalize f))@@ -656,11 +688,12 @@ -- Step: 1.4.2 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: ifComplexity, isNormal, normalize -- [Proven] normalizeSame :: Ɐf ∷ Formula → Bool normalizeSame :: TP (Proof (Forall "f" Formula -> SBool)) normalizeSame = do- icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller sInduct "normalizeSame" (\(Forall f) -> isNormal f .=> normalize f .== f)@@ -705,13 +738,14 @@ -- Step: 1.4.Completeness Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: eval, ifComplexity, ifDepth, lookUp, normalize -- [Proven] normalizeRespectsTruth :: Ɐf ∷ Formula → Ɐbs ∷ [Binding] → Bool normalizeRespectsTruth :: TP (Proof (Forall "f" Formula -> Forall "bs" [Binding] -> SBool)) normalizeRespectsTruth = do- icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller- npc <- recall "normalizePreservesComplexity" normalizePreservesComplexity- idn <- recall "ifDepthNonNeg" ifDepthNonNeg+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller+ npc <- recall normalizePreservesComplexity+ idn <- recall ifDepthNonNeg sInductWith cvc5 "normalizeRespectsTruth" (\(Forall f) (Forall bs) -> eval (normalize f) bs .== eval f bs)@@ -760,12 +794,13 @@ -- Step: 1 Q.E.D. -- Step: 2 Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: eval, ifComplexity, ifDepth, isAssigned, isNormal, isTautology', lookUp, normalize -- [Proven] soundness :: Ɐf ∷ Formula → Ɐbindings ∷ [Binding] → Bool soundness :: TP (Proof (Forall "f" Formula -> Forall "bindings" [Binding] -> SBool)) soundness = do- tie <- recallWith cvc5 "tautologyImpliesEval" tautologyImpliesEval- nrt <- recall "normalizeRespectsTruth" normalizeRespectsTruth- nc <- recall "normalizeCorrect" normalizeCorrect+ tie <- recallWith cvc5 tautologyImpliesEval+ nrt <- recall normalizeRespectsTruth+ nc <- recall normalizeCorrect calc "soundness" (\(Forall f) (Forall bindings) -> isTautology f .=> eval f bindings) $@@ -792,13 +827,15 @@ -- Returns whether falsification succeeded and the counterexample bindings. falsify' :: SFormula -> SList Binding -> SFalsifyResult falsify' = smtFunction "falsify'" $ \f bs ->- [sCase|Formula f of- FTrue -> sFalsifyResult sFalse []- FFalse -> sFalsifyResult sTrue bs+ [sCase| f of+ FTrue -> sFalsifyResult sFalse []+ FFalse -> sFalsifyResult sTrue bs+ Var i | isAssigned i bs, eval (sVar i) bs -> sFalsifyResult sFalse [] | isAssigned i bs -> sFalsifyResult sTrue bs | True -> sFalsifyResult sTrue (sBinding i sFalse .: bs)+ If (Var i) l r | isAssigned i bs, eval (sVar i) bs -> falsify' l bs | isAssigned i bs -> falsify' r bs@@ -831,11 +868,12 @@ -- Step: 1.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: eval, falsify', ifComplexity, isAssigned, isNormal, isTautology', lookUp -- [Proven] nonTautIsFalsified :: Ɐf ∷ Formula → Ɐbs ∷ [Binding] → Bool nonTautIsFalsified :: TP (Proof (Forall "f" Formula -> Forall "bs" [Binding] -> SBool)) nonTautIsFalsified = do- icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller sInduct "nonTautIsFalsified" (\(Forall f) (Forall bs) -> isNormal f .&& sNot (isTautology' f bs) .=> sfalsified (falsify' f bs))@@ -874,13 +912,14 @@ -- Step: 1.4 Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: eval, falsify', ifComplexity, isAssigned, lookUp -- [Proven] falsifyExtendsBindings :: Ɐf ∷ Formula → Ɐbs ∷ [Binding] → Ɐi ∷ Integer → Bool falsifyExtendsBindings :: TP (Proof (Forall "f" Formula -> Forall "bs" [Binding] -> Forall "i" Integer -> SBool)) falsifyExtendsBindings = do- icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller- iae <- recall "isAssignedExtends" isAssignedExtends- lue <- recall "lookUpExtends" lookUpExtends+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller+ iae <- recall isAssignedExtends+ lue <- recall lookUpExtends sInduct "falsifyExtendsBindings" (\(Forall f) (Forall bs) (Forall i) ->@@ -951,14 +990,15 @@ -- Step: 1.4.Completeness Q.E.D. -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D.+-- Functions proven terminating: eval, falsify', ifComplexity, isAssigned, isNormal, lookUp -- [Proven] falsifyFalsifies :: Ɐf ∷ Formula → Ɐbs ∷ [Binding] → Bool falsifyFalsifies :: TP (Proof (Forall "f" Formula -> Forall "bs" [Binding] -> SBool)) falsifyFalsifies = do- icp <- recall "ifComplexityPos" ifComplexityPos- ibs <- recall "ifComplexitySmaller" ifComplexitySmaller- feb <- recall "falsifyExtendsBindings" falsifyExtendsBindings- lus <- recall "lookUpSame" lookUpSame- ias <- recall "isAssignedSame" isAssignedSame+ icp <- recall ifComplexityPos+ ibs <- recall ifComplexitySmaller+ feb <- recall falsifyExtendsBindings+ lus <- recall lookUpSame+ ias <- recall isAssignedSame sInduct "falsifyFalsifies" (\(Forall f) (Forall bs) -> isNormal f .&& sfalsified (falsify' f bs) .=> sNot (eval f (scex (falsify' f bs))))@@ -1046,12 +1086,14 @@ -- Lemma: nonTautIsFalsified Q.E.D. -- Lemma: normalizeCorrect Q.E.D. -- Lemma: completenessHelper Q.E.D.+-- Functions proven terminating:+-- eval, falsify', ifComplexity, ifDepth, isAssigned, isNormal, isTautology', lookUp, normalize -- [Proven] completenessHelper :: Ɐf ∷ Formula → Bool completenessHelper :: TP (Proof (Forall "f" Formula -> SBool)) completenessHelper = do- ff <- recall "falsifyFalsifies" falsifyFalsifies- nti <- recall "nonTautIsFalsified" nonTautIsFalsified- nc <- recallWith z3 "normalizeCorrect" normalizeCorrect+ ff <- recall falsifyFalsifies+ nti <- recall nonTautIsFalsified+ nc <- recallWith z3 normalizeCorrect lemma "completenessHelper" (\(Forall f) -> sNot (isTautology f) .=> sNot (eval (normalize f) (scex (falsify f))))@@ -1069,11 +1111,13 @@ -- Lemma: completenessHelper Q.E.D. -- Lemma: normalizeRespectsTruth Q.E.D. -- Lemma: completeness Q.E.D.+-- Functions proven terminating:+-- eval, falsify', ifComplexity, ifDepth, isAssigned, isNormal, isTautology', lookUp, normalize -- [Proven] completeness :: Ɐf ∷ Formula → Bool completeness :: TP (Proof (Forall "f" Formula -> SBool)) completeness = do- ch <- recall "completenessHelper" completenessHelper- nrt <- recallWith z3 "normalizeRespectsTruth" normalizeRespectsTruth+ ch <- recall completenessHelper+ nrt <- recallWith z3 normalizeRespectsTruth lemma "completeness" (\(Forall f) -> sNot (isTautology f) .=> sNot (eval f (scex (falsify f))))
Documentation/SBV/Examples/TP/UpDown.hs view
@@ -49,10 +49,11 @@ -- | Keep consing the first argument on to the accumulator, until we hit zero. After that, return the second argument. -- Normally, we'd define this as a local function, but the definition needs to be visible for the proofs. upAcc :: SNat -> SList Integer -> SList Integer-upAcc = smtFunction "up" $ \n lst -> [sCase|Nat n of- Zero -> lst- Succ p -> upAcc p (n2i n .: lst)- |]+upAcc = smtFunction "up"+ $ \n lst -> [sCase| n of+ Zero -> lst+ Succ p -> upAcc p (n2i n .: lst)+ |] -- | Construct a list of size @n@, containing numbers @n-1@ down to @0@. --@@ -61,10 +62,11 @@ -- >>> down 5 -- [5,4,3,2,1] :: [SInteger] down :: SNat -> SList Integer-down = smtFunction "down" $ \n -> [sCase|Nat n of- Zero -> []- Succ p -> n2i n .: down p- |]+down = smtFunction "down"+ $ \n -> [sCase| n of+ Zero -> []+ Succ p -> n2i n .: down p+ |] -- | Prove that @reverse (down n)@ is the same as @up n@ --@@ -82,11 +84,12 @@ -- Step: 1.Completeness Q.E.D. -- Result: Q.E.D. -- Lemma: upDown Q.E.D.+-- Functions proven terminating: down, n2i, sbv.reverse, up -- [Proven] upDown :: Ɐn ∷ Nat → Bool upDown :: TP (Proof (Forall "n" Nat -> SBool)) upDown = do- n2inn <- recall "n2iNonNeg" n2iNonNeg- rc <- recall "revCons" (revCons @Integer)+ n2inn <- recall n2iNonNeg+ rc <- recall (revCons @Integer) -- We first generalize the theorem, to make it inductive upDownGen <- sInduct "upDownGen"
Documentation/SBV/Examples/TP/VM.hs view
@@ -83,15 +83,16 @@ -- | Size of an expression. Used in strong induction. size :: (SymVal nm, SymVal val) => SExpr nm val -> SInteger-size = smtFunction "exprSize" $ \expr -> [sCase|Expr expr of- Var _ -> 0- Con _ -> 0- Sqr a -> 1 + size a- Inc a -> 1 + size a- Add a b -> 1 + size a `smax` size b- Mul a b -> 1 + size a `smax` size b- Let _ a b -> 1 + size a `smax` size b- |]+size = smtFunction "exprSize"+ $ \expr -> [sCase| expr of+ Var _ -> 0+ Con _ -> 0+ Sqr a -> 1 + size a+ Inc a -> 1 + size a+ Add a b -> 1 + size a `smax` size b+ Mul a b -> 1 + size a `smax` size b+ Let _ a b -> 1 + size a `smax` size b+ |] -- | Environment, binding names to values type Env nm val = SList (nm, val)@@ -100,8 +101,9 @@ -- | Interpreter, in the usual functional style, taking an arbitrary environment. interpInEnv :: (SymVal nm, SymVal val, Num (SBV val)) => Env nm val -> SExpr nm val -> SBV val-interpInEnv = smtFunction "interpInEnv" $ \env expr ->- [sCase|Expr expr of+interpInEnv = smtFunction "interpInEnv"+ $ \env expr ->+ [sCase| expr of Var nm -> nm `SL.lookup` env Con v -> v Sqr a -> let av = interpInEnv env a in av * av@@ -151,7 +153,7 @@ -- We produce the new environment, and the new stack. execute :: (SymVal nm, SymVal val, Num (SBV val)) => EnvStack nm val -> SInstr nm val -> EnvStack nm val execute envStk instr = let (env, stk) = untuple envStk- in tuple [sCase|Instr instr of+ in tuple [sCase| instr of IPushN nm -> (env, push (nm `SL.lookup` env) stk) IPushV v -> (env, push v stk) IDup -> (env, push (top stk) stk)@@ -170,16 +172,16 @@ -- | Convert an expression to a sequence of instructions for our virtual machine. compile :: (SymVal nm, SymVal val, Num (SBV val)) => SExpr nm val -> SList (Instr nm val)-compile = smtFunction "compile" $ \expr ->- [sCase|Expr expr of- Var nm -> [sIPushN nm]- Con v -> [sIPushV v]- Sqr a -> compile a SL.++ [sIDup, sIMul]- Inc a -> compile a SL.++ [sIPushV 1, sIAdd]- Add a b -> compile a SL.++ compile b SL.++ [sIAdd]- Mul a b -> compile a SL.++ compile b SL.++ [sIMul]- Let v a b -> compile a SL.++ [sIBind v] SL.++ compile b SL.++ [sIForget]- |]+compile = smtFunction "compile"+ $ \expr -> [sCase| expr of+ Var nm -> [sIPushN nm]+ Con v -> [sIPushV v]+ Sqr a -> compile a SL.++ [sIDup, sIMul]+ Inc a -> compile a SL.++ [sIPushV 1, sIAdd]+ Add a b -> compile a SL.++ compile b SL.++ [sIAdd]+ Mul a b -> compile a SL.++ compile b SL.++ [sIMul]+ Let v a b -> compile a SL.++ [sIBind v] SL.++ compile b SL.++ [sIForget]+ |] -- | Compile and run an expression. compileAndRun :: (SymVal nm, SymVal val, Num (SBV val)) => SExpr nm val -> SBV val@@ -263,7 +265,8 @@ -- Step: 3 Q.E.D. -- Step: 4 Q.E.D. -- Result: Q.E.D.--- [Proven] correctness :: Ɐexpr ∷ (Expr [Char] Integer) → Bool+-- Functions proven terminating: compile, exprSize, interpInEnv, sbv.foldl, sbv.lookup+-- [Proven] correctness :: Ɐexpr ∷ (Expr String Integer) → Bool correctness :: forall nm val. (SymVal nm, SymVal val, Num (SBV val)) => TP (Proof (Forall "expr" (Expr nm val) -> SBool)) correctness = do @@ -317,7 +320,7 @@ .== tuple (env, push (interpInEnv env e) stk)) (\e _ _ -> size e, [proofOf measureNonNeg]) $ \ih e env stk -> []- |- [pCase|Expr e of+ |- [pCase| e of Var nm -> run (tuple (env, stk)) (compile (sVar nm)) ?? "case Var" =: run (tuple (env, stk)) [sIPushN nm]
Documentation/SBV/Examples/WeakestPreconditions/IntDiv.hs view
@@ -66,7 +66,7 @@ -- -- Note that we need to explicitly annotate each loop with its invariant and the termination -- measure. For convenience, we take those two as parameters for simplicity.-algorithm :: Invariant D -> Maybe (Measure D) -> Stmt D+algorithm :: Invariant D -> Maybe (WPMeasure D) -> Stmt D algorithm inv msr = Seq [ assert "x, y >= 0" $ \DivS{x, y} -> x .>= 0 .&& y .>= 0 , Assign $ \st@DivS{x} -> st{r = x, q = 0} , While "y <= r"@@ -92,7 +92,7 @@ noChange = [stable "x" x, stable "y" y] -- | A program is the algorithm, together with its pre- and post-conditions.-imperativeDiv :: Invariant D -> Maybe (Measure D) -> Program D+imperativeDiv :: Invariant D -> Maybe (WPMeasure D) -> Program D imperativeDiv inv msr = Program { setup = return () , precondition = pre , program = algorithm inv msr@@ -110,7 +110,7 @@ -- | The measure. In each iteration @r@ decreases, but always remains positive. -- Since @y@ is strictly positive, @r@ can serve as a measure for the loop.-measure :: Measure D+measure :: WPMeasure D measure DivS{r} = [r] -- | Check that the program terminates and the post condition holds. We have:
Documentation/SBV/Examples/WeakestPreconditions/IntSqrt.hs view
@@ -72,7 +72,7 @@ -- -- Note that we need to explicitly annotate each loop with its invariant and the termination -- measure. For convenience, we take those two as parameters for simplicity.-algorithm :: Invariant S -> Maybe (Measure S) -> Stmt S+algorithm :: Invariant S -> Maybe (WPMeasure S) -> Stmt S algorithm inv msr = Seq [ assert "x >= 0" $ \SqrtS{x} -> x .>= 0 , Assign $ \st -> st{sqrt = 0, i = 1, j = 1} , While "i <= x"@@ -102,7 +102,7 @@ noChange = [stable "x" x] -- | A program is the algorithm, together with its pre- and post-conditions.-imperativeSqrt :: Invariant S -> Maybe (Measure S) -> Program S+imperativeSqrt :: Invariant S -> Maybe (WPMeasure S) -> Program S imperativeSqrt inv msr = Program { setup = return () , precondition = pre , program = algorithm inv msr@@ -123,7 +123,7 @@ where sq n = n * n -- | The measure. In each iteration @i@ strictly increases, thus reducing the differential @x - i@-measure :: Measure S+measure :: WPMeasure S measure SqrtS{x, i} = [x - i] -- | Check that the program terminates and the post condition holds. We have:
Documentation/SBV/Examples/WeakestPreconditions/Length.hs view
@@ -67,7 +67,7 @@ -- -- Note that we need to explicitly annotate each loop with its invariant and the termination -- measure. For convenience, we take those two as parameters, so we can experiment later.-algorithm :: Invariant S -> Maybe (Measure S) -> Stmt S+algorithm :: Invariant S -> Maybe (WPMeasure S) -> Stmt S algorithm inv msr = Seq [ Assign $ \st@LenS{xs} -> st{ys = xs, l = 0} , While "! (null ys)" inv@@ -91,7 +91,7 @@ noChange = [stable "xs" xs] -- | A program is the algorithm, together with its pre- and post-conditions.-imperativeLength :: Invariant S -> Maybe (Measure S) -> Program S+imperativeLength :: Invariant S -> Maybe (WPMeasure S) -> Program S imperativeLength inv msr = Program { setup = return () , precondition = pre , program = algorithm inv msr@@ -105,7 +105,7 @@ invariant LenS{xs, ys, l} = L.length xs .== l + L.length ys -- | The measure is obviously the length of @ys@, as we peel elements off of it through the loop.-measure :: Measure S+measure :: WPMeasure S measure LenS{ys} = [L.length ys] -- * Correctness
Documentation/SBV/Examples/WeakestPreconditions/Sum.hs view
@@ -71,7 +71,7 @@ -- -- Note that we need to explicitly annotate each loop with its invariant and the termination -- measure. For convenience, we take those two as parameters, so we can experiment later.-algorithm :: Invariant S -> Maybe (Measure S) -> Stmt S+algorithm :: Invariant S -> Maybe (WPMeasure S) -> Stmt S algorithm inv msr = Seq [ Assign $ \st -> st{i = 0, s = 0} , assert "n >= 0" $ \SumS{n} -> n .>= 0 , While "i < n"@@ -99,7 +99,7 @@ noChange = [stable "n" n] -- | A program is the algorithm, together with its pre- and post-conditions.-imperativeSum :: Invariant S -> Maybe (Measure S) -> Program S+imperativeSum :: Invariant S -> Maybe (WPMeasure S) -> Program S imperativeSum inv msr = Program { setup = return () , precondition = pre , program = algorithm inv msr@@ -143,7 +143,7 @@ -- >>> correctness invariant (Just measure) -- Total correctness is established. -- Q.E.D.-correctness :: Invariant S -> Maybe (Measure S) -> IO (ProofResult (SumS Integer))+correctness :: Invariant S -> Maybe (WPMeasure S) -> IO (ProofResult (SumS Integer)) correctness inv msr = wpProveWith defaultWPCfg{wpVerbose=True} (imperativeSum inv msr) -- * Example proof attempts@@ -207,8 +207,8 @@ Following proof obligation failed: ================================== Invariant for loop "i < n" is not maintained by the body:- Before: SumS {n = 3, i = 1, s = 1}- After : SumS {n = 3, i = 2, s = 3}+ Before: SumS {n = 2, i = 1, s = 1}+ After : SumS {n = 2, i = 2, s = 3} Here, we posed the extra incorrect invariant that @s <= i@ must be maintained, and SBV found us a reachable state that violates the invariant. The /before/ state indeed satisfies @s <= i@, but the /after/ state does not. Note that the proof fails in this case not because the program@@ -224,8 +224,8 @@ Following proof obligation failed: ================================== Measure for loop "i < n" is negative:- State : SumS {n = 4, i = 3, s = 6}- Measure: -2+ State : SumS {n = 3, i = 2, s = 3}+ Measure: -1 The failure is pretty obvious in this case: Measure produces a negative value.
README.md view
@@ -2,25 +2,81 @@ [](https://github.com/LeventErkok/sbv/actions/workflows/ci.yml) -On Hackage: http://hackage.haskell.org/package/sbv+***Express properties about Haskell programs and automatically prove them using SMT solvers.*** -Express properties about Haskell programs and automatically prove them using SMT solvers.+[Hackage](http://hackage.haskell.org/package/sbv) | [Release Notes](http://github.com/LeventErkok/sbv/tree/master/CHANGES.md) | [Documentation](http://hackage.haskell.org/package/sbv/docs/Data-SBV.html) -On one end, SBV can be used as a push-button prover over many types:+SBV provides symbolic versions of Haskell types. Programs written with these types can be automatically verified, checked for satisfiability, optimized, or compiled to C — all via SMT solvers. +## SBV in 5 Minutes++Fire up GHCi with SBV:++```+$ cabal repl --build-depends sbv+```++For unbounded integers, `x + 1 .> x` is always true:+ ```haskell-$ ghci ghci> :m Data.SBV-ghci> prove $ \x -> x `shiftL` 2 .== 4 * (x::SWord8)+ghci> prove $ \x -> x + 1 .> (x :: SInteger) Q.E.D.-ghci> prove $ \x -> x `shiftL` 2 .== 2 * (x::SWord8)+```++But with machine arithmetic, overflow lurks:++```haskell+ghci> prove $ \x -> x + 1 .> (x :: SInt8) Falsifiable. Counter-example:- s0 = 32 :: Word8+ s0 = 127 :: Int8 ``` -On the other extreme, SBV can be used as an SMT-based proof assistant to prove equational and inductive program properties:+IEEE-754 floats break reflexivity of equality: ```haskell+ghci> prove $ \x -> (x :: SFloat) .== x+Falsifiable. Counter-example:+ s0 = NaN :: Float+```++What's the multiplicative inverse of 3 modulo 256?++```haskell+ghci> sat $ \x -> x * 3 .== (1 :: SWord8)+Satisfiable. Model:+ s0 = 171 :: Word8+```++Use quantifiers for named results:++```haskell+ghci> sat $ skolemize $ \(Exists @"x" x) (Exists @"y" y) -> x * y .== (96::SInteger) .&& x + y .== 28+Satisfiable. Model:+ x = 24 :: Integer+ y = 4 :: Integer+```++Optimize a cost function subject to constraints:++```haskell+ghci> :{+optimize Lexicographic $ do x <- sInteger "x"+ y <- sInteger "y"+ constrain $ x + y .== 20+ constrain $ x .>= 5+ constrain $ y .>= 5+ minimize "cost" $ x * y+:}+Optimal in an extension field:+ x = 5 :: Integer+ y = 15 :: Integer+ cost = 75 :: Integer+```++For inductive proofs and equational reasoning, SBV includes a theorem prover:++```haskell revApp :: forall a. SymVal a => TP (Proof (Forall "xs" [a] -> Forall "ys" [a] -> SBool)) revApp = induct "revApp" (\(Forall xs) (Forall ys) -> reverse (xs ++ ys) .== reverse ys ++ reverse xs) $@@ -34,9 +90,7 @@ =: qed ``` -Running this proof produces:--```haskell+``` ghci> runTP $ revApp @Integer Inductive lemma: revApp Step: Base Q.E.D.@@ -46,111 +100,102 @@ Step: 4 Q.E.D. Step: 5 Q.E.D. Result: Q.E.D.+Functions proven terminating: sbv.reverse [Proven] revApp :: Ɐxs ∷ [Integer] → Ɐys ∷ [Integer] → Bool ``` -Establishing how `reverse` distributes over `++` (at the monomorpic type of list of integers).+## Features -The function `prove` establishes theorem-hood, while `sat` finds a satisfying model if it exists. The `runTP` function-runs a proof script, establishing theorems with user guidance.+**Symbolic types** — Booleans, signed/unsigned integers (8/16/32/64-bit and arbitrary-width), unbounded integers, reals, rationals, IEEE-754 floats, characters, strings, lists, tuples, sums, optionals, sets, enumerations, algebraic data types, and uninterpreted sorts. -All satisfying models can be computed using `allSat`.-SBV can also perform static assertion checks, such as absence of division-by-0, and other user given properties.-Furthermore, SBV can perform optimization, minimizing/maximizing arithmetic goals for their optimal values.+**Verification** — `prove`/`sat`/`allSat` for property checking and model finding, `safe`/`sAssert` for assertion verification, `dsat`/`dprove` for delta-satisfiability, and QuickCheck integration. -SBV also allows for an incremental mode: Users are given a handle to the SMT solver as their programs execute, and they can issue SMTLib commands programmatically, query values, and direct the interaction using a high-level typed API. The incremental mode also allows for creation of constraints based on the current model, and access to internals of SMT solvers for advanced users. See the `runSMT` and `query` commands for details.+**Optimization** — Minimize/maximize cost functions subject to constraints via `optimize`/`maximize`/`minimize`, with support for lexicographic, independent, and Pareto objectives. -## Overview+**Quantifiers and functions** — Universal and existential quantifiers (including alternating), with skolemization for named bindings. Define SMT-level functions directly from Haskell via `smtFunction`, including recursive and mutually recursive definitions with automatic termination checking. - - [Hackage](http://hackage.haskell.org/package/sbv)- - [Release Notes](http://github.com/LeventErkok/sbv/tree/master/CHANGES.md)- -SBV library provides support for dealing with symbolic values in Haskell. It introduces the types:+**Theorem proving (TP)** — Semi-automated inductive proofs (including strong induction) with equational reasoning chains. Includes termination checking, recursive and mutually recursive definitions, productive (co-recursive) functions, and user-defined measures. - - `SBool`: Symbolic Booleans (bits).- - `SWord8`, `SWord16`, `SWord32`, `SWord64`: Symbolic Words (unsigned).- - `SInt8`, `SInt16`, `SInt32`, `SInt64`: Symbolic Ints (signed).- - `SWord N`, `SInt N`, for `N > 0`: Arbitrary sized unsigned/signed bit-vectors, parameterized by the bitsize. (Using DataKinds extension.)- - `SInteger`: Symbolic unbounded integers (signed).- - `SReal`: Symbolic infinite precision algebraic reals (signed).- - `SRational`: Symbolic rationals, ratio of two symbolic integers. (`Rational`.)- - `SFloat`: IEEE-754 single precision floating point number. (`Float`.)- - `SDouble`: IEEE-754 double precision floating point number. (`Double`.)- - `SFloatingPoint`: IEEE-754 floating point number with user specified exponent and significand sizes. (`FloatingPoint`)- - `SChar`: Symbolic characters, supporting unicode.- - `SString`: Symbolic strings.- - `SList`: Symbolic lists. (Which can be nested, i.e., lists of lists.)- - `STuple`: Symbolic tuples (upto 8-tuples, can be nested)- - `SEither`: Symbolic sums- - `SMaybe`: Symbolic optional values- - `SSet`: Symbolic sets- - Arrays of symbolic values.- - Symbolic enumerations, for arbitrary user-defined enumerated types.- - Symbolic polynomials over GF(2^n ), polynomial arithmetic, and CRCs.- - Uninterpreted constants and functions over symbolic values, with user defined axioms.- - Uninterpreted sorts, and proofs over such sorts, potentially with axioms.- - Algebraic data types, including recursive fields.- - Ability to define SMTLib functions, generated directly from Haskell versions, including support for recursive and mutually recursive functions.- - Reasoning with universal and existential quantifiers, including alternating quantifiers.- -The user can construct ordinary Haskell programs using these types, which behave like ordinary Haskell values when used concretely. However, when used with symbolic arguments, functions built out of these types can also be:+**Code generation** — Compile symbolic programs to C as straight-line programs or libraries (`compileToC`, `compileToCLib`), and generate test vectors (`genTest`). - - proven correct via an external SMT solver (the `prove` function),- - checked for satisfiability (the `sat`, and `allSat` functions),- - checked for assertion violations (the `safe` function with `sAssert` calls),- - checked for delta-satisfiability (the `dsat` and `dprove` functions),- - used in synthesis (the `sat`function with existentials),- - checked for machine-arithmetic overflow/underflow conditions,- - optimized with respect to cost functions (the `optimize`, `maximize`, and `minimize` functions),- - quick-checked,- - used for generating Haskell and C test vectors (the `genTest` function),- - compiled down to C, rendered as straight-line programs or libraries (`compileToC` and `compileToCLib` functions).- -## Picking the SMT solver to use+**SMT interaction** — Incremental mode via `runSMT`/`query` for programmatic solver interaction with a high-level typed API. Run multiple solvers simultaneously with `proveWithAny`/`proveWithAll`. -The SBV library uses third-party SMT solvers via the standard SMT-Lib interface. The following solvers are supported:+## Algebraic Data Types - - [ABC](http://www.eecs.berkeley.edu/~alanmi/abc) from University of Berkeley- - [Boolector](http://boolector.github.io/) from Johannes Kepler University- - [Bitwuzla](http://bitwuzla.github.io/) from Stanford University- - [CVC4](http://cvc4.github.io/) from Stanford University and the University of Iowa- - [CVC5](http://cvc5.github.io/) from Stanford University and the University of Iowa- - [DReal](http://dreal.github.io/) from CMU- - [MathSAT](http://mathsat.fbk.eu/) from FBK and DISI-University of Trento- - [OpenSMT](http://verify.inf.usi.ch/opensmt) from Università della Svizzera italiana- - [Yices](http://github.com/SRI-CSL/yices2) from SRI- - [Z3](http://github.com/Z3Prover/z3/wiki) from Microsoft- -Most functions have two variants: For instance `prove`/`proveWith`. The former uses the default solver, which is currently Z3. The latter expects you to pass it a configuration that picks the solver.-The valid values are `abc`, `boolector`, `bitwuzla`, `cvc4`, `cvc5`, `dReal`, `mathSAT`, `openSMT`, `yices`, and `z3`.+User-defined algebraic data types — including enumerations, recursive, and parametric types — are supported via `mkSymbolic`, with pattern matching via `sCase` (and its proof counterpart `pCase`): -See [versions](http://github.com/LeventErkok/sbv/blob/master/SMTSolverVersions.md) for a listing of the versions of these tools SBV has been tested with. Please report if you see any discrepancies!+```haskell+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE TemplateHaskell #-} -Other SMT solvers can be used with SBV as well, with a relatively easy hook-up mechanism. Please do get in touch if you plan to use SBV with any other solver.+import Data.SBV -## Using multiple solvers, simultaneously+data Expr a = Val a+ | Add (Expr a) (Expr a)+ | Mul (Expr a) (Expr a)+ deriving Show -SBV also allows for running multiple solvers at the same time, either picking the result of the first to complete, or getting results from all.-See `proveWithAny`/`proveWithAll` and `satWithAny`/`satWithAll` functions. The function `sbvAvailableSolvers` can be used to query the available solvers at run-time.+-- Make Expr symbolically available, named SExpr+mkSymbolic [''Expr] -## TP: Semi-automated theorem proving+eval :: SymVal a => (SBV a -> SBV a -> SBV a) -> (SBV a -> SBV a -> SBV a) -> SBV (Expr a) -> SBV a+eval add mul = smtFunction "eval" $ \e ->+ [sCase| e of+ Val v -> v+ Add x y -> eval add mul x `add` eval add mul y+ Mul x y -> eval add mul x `mul` eval add mul y+ |]+``` -While SMT solvers are quite powerful, there is a certain class of problems that they are just not well suited for. In particular, SMT-solvers are not good at proofs that require induction, or those that require complex chains of reasoning. Induction is necessary to reason about-any recursive algorithm, and most such proofs require carefully constructed equational steps.+The `sCase` construct supports nested pattern matching, as-patterns, guards, and wildcards, making programming with algebraic data types natural. Plain `case` expressions inside `sCase` are automatically treated as symbolic case-splits. The `pCase` variant provides the same features for proof case-splits in the theorem proving context. -SBV allows for a style of semi-automated theorem proving, called TP. which can be used to construct such proofs.-The documentation includes example proofs for many list functions, and even inductive proofs for-the familiar insertion, merge, quick-sort algorithms, along with a proof that the square-root of 2 is irrational.-While a proper theorem prover (such as Lean, Isabelle etc.) is a more appropriate choice for such proofs, with some-guidance (and acceptance of a much larger trusted code base!), SBV can be used to establish correctness of various mathematical-claims and algorithms that are usually beyond the scope of SMT solvers alone. See the documentation under-the `Documentation.SBV.Examples.TP` directory.+## Supported SMT Solvers -## Copyright, License+SBV communicates with solvers via the standard SMT-Lib interface: -The SBV library is distributed with the BSD3 license. See [COPYRIGHT](http://github.com/LeventErkok/sbv/tree/master/COPYRIGHT) for details.-The [LICENSE](http://github.com/LeventErkok/sbv/tree/master/LICENSE) file contains the [BSD3](http://en.wikipedia.org/wiki/BSD_licenses) verbiage.+| Solver | From | | Solver | From |+|--------|------|-|--------|------|+| [ABC](http://www.eecs.berkeley.edu/~alanmi/abc) | Berkeley | | [DReal](http://dreal.github.io/) | CMU |+| [Bitwuzla](http://bitwuzla.github.io/) | Stanford | | [MathSAT](http://mathsat.fbk.eu/) | FBK / Trento |+| [Boolector](http://boolector.github.io/) | JKU | | [OpenSMT](http://verify.inf.usi.ch/opensmt) | USI |+| [CVC4](http://cvc4.github.io/) | Stanford / Iowa | | [Yices](http://github.com/SRI-CSL/yices2) | SRI |+| [CVC5](http://cvc5.github.io/) | Stanford / Iowa | | [Z3](http://github.com/Z3Prover/z3/wiki) | Microsoft |++**Z3** is the default solver. Use `proveWith`, `satWith`, etc. to select a different one (e.g., `proveWith cvc5`). See [tested versions](http://github.com/LeventErkok/sbv/blob/master/SMTSolverVersions.md) for details. Other SMT-Lib compatible solvers can be hooked up with minimal effort — get in touch if you'd like to use one not listed here.++## A Selection of Examples++SBV ships with many worked examples. Here are some highlights:++| Example | Description |+|---------|-------------|+| [Sudoku](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-Puzzles-Sudoku.html) | Solve Sudoku puzzles using SMT constraints |+| [N-Queens](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-Puzzles-NQueens.html) | Solve the N-Queens placement puzzle |+| [SEND + MORE = MONEY](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-Puzzles-SendMoreMoney.html) | The classic cryptarithmetic puzzle |+| [Fish/Zebra](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-Puzzles-Fish.html) | Einstein's logic puzzle |+| [SQL Injection](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-Strings-SQLInjection.html) | Find inputs that cause SQL injection vulnerabilities |+| [Regex Crossword](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-Strings-RegexCrossword.html) | Solve regex crossword puzzles |+| [BitTricks](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-BitPrecise-BitTricks.html) | Verify bit-manipulation tricks from Stanford's bithacks collection |+| [Legato multiplier](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-BitPrecise-Legato.html) | Correctness proof of Legato's 8-bit multiplier |+| [Prefix sum](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-BitPrecise-PrefixSum.html) | Ladner-Fischer prefix-sum implementation proof |+| [AES](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-Crypto-AES.html) | AES encryption with C code generation |+| [CRC](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-CodeGeneration-CRC_USB5.html) | Symbolic CRC computation with C code generation |+| [Sqrt2 irrational](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-Sqrt2IsIrrational.html) | Prove that the square root of 2 is irrational |+| [Sorting](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-InsertionSort.html) | Prove [insertion sort](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-InsertionSort.html), [merge sort](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-MergeSort.html), and [quick sort](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-QuickSort.html) correct |+| [Kadane](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-Kadane.html) | Prove Kadane's maximum segment-sum algorithm correct |+| [McCarthy91](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-McCarthy91.html) | Prove McCarthy's 91 function meets its specification |+| [Binary search](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-BinarySearch.html) | Prove binary search correct |+| [Collatz](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-Collatz.html) | Explore properties of the Collatz sequence |+| [Infinitely many primes](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-Primes.html) | Prove there are infinitely many primes |+| [Tautology checker](http://hackage.haskell.org/package/sbv/docs/Documentation-SBV-Examples-TP-TautologyChecker.html) | A verified BDD-style tautology checker |++Browse the full collection in `Documentation.SBV.Examples` [on Hackage](http://hackage.haskell.org/package/sbv).++## License++SBV is distributed under the [BSD3](http://en.wikipedia.org/wiki/BSD_licenses) license. See [COPYRIGHT](http://github.com/LeventErkok/sbv/tree/master/COPYRIGHT) and [LICENSE](http://github.com/LeventErkok/sbv/tree/master/LICENSE) for details.++Please report bugs and feature requests at the [GitHub issue tracker](http://github.com/LeventErkok/sbv/issues). ## Thanks
SBVBenchSuite/Utils/SBVBenchFramework.hs view
@@ -73,7 +73,7 @@ spaceTo :: Char -> Char -> Char spaceTo c x | isSpace x = c- | otherwise = x+ | True = x -- | Construct a benchmark file name. The input name should be a time stamp or -- whatever you want to name the benchmark
SBVTestSuite/GoldFiles/adt_expr00.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_expr01.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_expr02.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_expr03.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_gen00.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer), valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,117 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)+[MEASURE] valid @(SBV [[Char]] -> SBV Expr -> SBV Bool): barified = "|valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)|"+[MEASURE] valid @(SBV [[Char]] -> SBV Expr -> SBV Bool): Uninterpreted ops in DAG: [("|valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)|",2)]+[MEASURE] valid @(SBV [[Char]] -> SBV Expr -> SBV Bool): recursive calls found = 6+[MEASURE] valid @(SBV [[Char]] -> SBV Expr -> SBV Bool): trying sbv.dt.size.Expr arg2+[MEASURE] valid @(SBV [[Char]] -> SBV Expr -> SBV Bool): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] valid @(SBV [[Char]] -> SBV Expr -> SBV Bool): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): valid @(SBV [[Char]] -> SBV Expr -> SBV Bool)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -72,19 +201,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))@@ -136,9 +267,11 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Let "p" (Val 3) (Let "l" (Val 6) (Add (Var "l") (Var "l"))))))+[RECV] ((s0 (Let "y"+ (Add (Val (- 2)) (Mul (Val (- 1)) (Val 3)))+ (Let "a" (Val 13) (Add (Add (Val (- 3)) (Val 2)) (Var "a")))))) -Got: (let p = 3 in (let l = 6 in (l + l)))+Got: (let y = (-2 + (-1 * 3)) in (let a = 13 in ((-3 + 2) + a))) DONE *** Solver : Z3 *** Exit code: ExitSuccess
SBVTestSuite/GoldFiles/adt_lit00.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -39,19 +160,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_lit01.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -39,19 +160,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_lit02.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -40,19 +161,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_lit03.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -40,19 +161,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_lit04.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -40,19 +161,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_lit05.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -39,19 +160,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_nested18.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -37,19 +158,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_nested23.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -37,19 +158,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_nested24.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -37,19 +158,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_nested29.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (@@ -34,19 +155,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| :: [(SString, SInteger)] -> Expr -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV Expr -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 Expr)) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_pexpr00.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (par (nm val) (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| :: [(SString, SInteger)] -> Expr String Integer -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 (Expr String Int))) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_pexpr01.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (par (nm val) (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| :: [(SString, SInteger)] -> Expr String Integer -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 (Expr String Int))) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_pexpr02.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (par (nm val) (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| :: [(SString, SInteger)] -> Expr String Integer -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 (Expr String Int))) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_pexpr03.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,109 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (par (nm val) (@@ -36,19 +157,21 @@ [GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive] [GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s9 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))- (let ((l2_s5 (seq.nth l2_s0 l2_s3)))- (let ((l2_s6 (proj_1_SBVTuple2 l2_s5)))- (let ((l2_s7 (= l2_s1 l2_s6)))- (let ((l2_s8 (proj_2_SBVTuple2 l2_s5)))- (let ((l2_s10 (- l2_s2 l2_s9)))- (let ((l2_s11 (seq.extract l2_s0 l2_s9 l2_s10)))- (let ((l2_s12 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s11 l2_s1)))- (let ((l2_s13 (ite l2_s7 l2_s8 l2_s12)))- (let ((l2_s14 (ite l2_s4 l2_s3 l2_s13)))- l2_s14))))))))))))))+ (let ((l2_s5 (not l2_s4)))+ (let ((l2_s6 (seq.nth l2_s0 l2_s3)))+ (let ((l2_s7 (proj_1_SBVTuple2 l2_s6)))+ (let ((l2_s8 (= l2_s1 l2_s7)))+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16)))))))))))))))) [GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| :: [(SString, SInteger)] -> Expr String Integer -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|] [GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 (Expr String Int))) Int (let ((l1_s2 ((as is-Val Bool) l1_s1)))
SBVTestSuite/GoldFiles/adt_pgen00.gold view
@@ -1,3 +1,21 @@+[MEASURE] Verifying termination measures for: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer), get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer), valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): barified = "|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|"+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2),("|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)|",2)]+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): recursive calls found = 6+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): trying sbv.dt.size.Expr arg2+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)+[MEASURE] Checking: get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): barified = "|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|"+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): Uninterpreted ops in DAG: [("|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|",2)]+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): recursive calls found = 1+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -14,6 +32,117 @@ ((mkSBVTuple2 (proj_1_SBVTuple2 T1) (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 String Int))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () String) ; tracks user variable "arg1"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Bool (not s5))+[GOOD] (define-fun s7 () (SBVTuple2 String Int) (seq.nth s0 s2))+[GOOD] (define-fun s8 () String (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Bool (and s6 s9))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s12 () Int (- s4 s3))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 String Int)) (seq.extract s0 s3 s12))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Int (ite s5 s2 s15))+[GOOD] (define-fun s17 () Int (seq.len s13))+[GOOD] (define-fun s18 () Bool (not s10))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s4 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)+[MEASURE] Checking: valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)+[MEASURE] valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool): barified = "|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)|"+[MEASURE] valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool): Uninterpreted ops in DAG: [("|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)|",2),("|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)|",2)]+[MEASURE] valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool): recursive calls found = 6+[MEASURE] valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool): trying sbv.dt.size.Expr arg2+[MEASURE] valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool): sbv.dt.size.Expr arg2 -> OK (structural recursion)+[MEASURE] valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool): sbv.dt.size.Expr arg2 -> OK+[MEASURE] Passed (terminating): valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums --- [GOOD] ; --- ADTs --- [GOOD] ; User defined ADT: Expr [GOOD] (declare-datatype Expr (par (nm val) (@@ -25,16 +154,16 @@ ))) [GOOD] ; --- literal constants --- [GOOD] (define-fun s1 () (Seq String) (as seq.empty (Seq String)))-[GOOD] (define-fun s3 () (Seq (SBVTuple2 String (_ BitVec 16))) (as seq.empty (Seq (SBVTuple2 String (_ BitVec 16)))))-[GOOD] (define-fun s5 () (_ BitVec 16) #x000c)+[GOOD] (define-fun s3 () (Seq (SBVTuple2 String Int)) (as seq.empty (Seq (SBVTuple2 String Int))))+[GOOD] (define-fun s5 () Int 12) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants --- [GOOD] ; --- user defined functions ----[GOOD] ; |valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| :: [SString] -> Expr String Word16 -> SBool [Recursive]-[GOOD] (define-fun-rec |valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| ((l1_s0 (Seq String)) (l1_s1 (Expr String (_ BitVec 16)))) Bool+[GOOD] ; |valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| :: [SString] -> Expr String Integer -> SBool [Recursive]+[GOOD] (define-fun-rec |valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| ((l1_s0 (Seq String)) (l1_s1 (Expr String Int))) Bool (let ((l1_s2 ((as is-Val Bool) l1_s1))) (let ((l1_s3 ((as is-Var Bool) l1_s1))) (let ((l1_s4 (getVar_1 l1_s1)))@@ -44,24 +173,24 @@ (let ((l1_s8 (and l1_s5 l1_s7))) (let ((l1_s9 ((as is-Add Bool) l1_s1))) (let ((l1_s10 (getAdd_1 l1_s1)))- (let ((l1_s11 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| l1_s0 l1_s10)))+ (let ((l1_s11 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| l1_s0 l1_s10))) (let ((l1_s12 (getAdd_2 l1_s1)))- (let ((l1_s13 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| l1_s0 l1_s12)))+ (let ((l1_s13 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| l1_s0 l1_s12))) (let ((l1_s14 (and l1_s11 l1_s13))) (let ((l1_s15 ((as is-Mul Bool) l1_s1))) (let ((l1_s16 (getMul_1 l1_s1)))- (let ((l1_s17 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| l1_s0 l1_s16)))+ (let ((l1_s17 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| l1_s0 l1_s16))) (let ((l1_s18 (getMul_2 l1_s1)))- (let ((l1_s19 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| l1_s0 l1_s18)))+ (let ((l1_s19 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| l1_s0 l1_s18))) (let ((l1_s20 (and l1_s17 l1_s19))) (let ((l1_s21 (getLet_1 l1_s1))) (let ((l1_s22 (str.in_re l1_s21 (re.++ (re.range "a" "z") (re.* (re.union (re.range "a" "z") (re.range "A" "Z") (re.range "0" "9"))))))) (let ((l1_s23 (getLet_2 l1_s1)))- (let ((l1_s24 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| l1_s0 l1_s23)))+ (let ((l1_s24 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| l1_s0 l1_s23))) (let ((l1_s25 (seq.unit l1_s21))) (let ((l1_s26 (seq.++ l1_s25 l1_s0))) (let ((l1_s27 (getLet_3 l1_s1)))- (let ((l1_s28 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| l1_s26 l1_s27)))+ (let ((l1_s28 (|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| l1_s26 l1_s27))) (let ((l1_s29 (and l1_s24 l1_s28))) (let ((l1_s30 (and l1_s22 l1_s29))) (let ((l1_s31 (ite l1_s15 l1_s20 l1_s30)))@@ -69,63 +198,64 @@ (let ((l1_s33 (ite l1_s3 l1_s8 l1_s32))) (let ((l1_s34 (or l1_s2 l1_s33))) l1_s34))))))))))))))))))))))))))))))))))-[GOOD] ; |get @(SBV [([Char],Word16)] -> SBV [Char] -> SBV Word16)| :: [(SString, SWord16)] -> SString -> SWord16 [Recursive]-[GOOD] (define-fun-rec |get @(SBV [([Char],Word16)] -> SBV [Char] -> SBV Word16)| ((l2_s0 (Seq (SBVTuple2 String (_ BitVec 16)))) (l2_s1 String)) (_ BitVec 16)+[GOOD] ; |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| :: [(SString, SInteger)] -> SString -> SInteger [Recursive]+[GOOD] (define-fun-rec |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| ((l2_s0 (Seq (SBVTuple2 String Int))) (l2_s1 String)) Int (let ((l2_s3 0))- (let ((l2_s5 #x0000))- (let ((l2_s10 1))+ (let ((l2_s11 1)) (let ((l2_s2 (seq.len l2_s0))) (let ((l2_s4 (= l2_s2 l2_s3)))+ (let ((l2_s5 (not l2_s4))) (let ((l2_s6 (seq.nth l2_s0 l2_s3))) (let ((l2_s7 (proj_1_SBVTuple2 l2_s6))) (let ((l2_s8 (= l2_s1 l2_s7)))- (let ((l2_s9 (proj_2_SBVTuple2 l2_s6)))- (let ((l2_s11 (- l2_s2 l2_s10)))- (let ((l2_s12 (seq.extract l2_s0 l2_s10 l2_s11)))- (let ((l2_s13 (|get @(SBV [([Char],Word16)] -> SBV [Char] -> SBV Word16)| l2_s12 l2_s1)))- (let ((l2_s14 (ite l2_s8 l2_s9 l2_s13)))- (let ((l2_s15 (ite l2_s4 l2_s5 l2_s14)))- l2_s15)))))))))))))))-[GOOD] ; |eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| :: [(SString, SWord16)] -> Expr String Word16 -> SWord16 [Recursive] [Refers to: |get @(SBV [([Char],Word16)] -> SBV [Char] -> SBV Word16)|]-[GOOD] (define-fun-rec |eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| ((l1_s0 (Seq (SBVTuple2 String (_ BitVec 16)))) (l1_s1 (Expr String (_ BitVec 16)))) (_ BitVec 16)+ (let ((l2_s9 (and l2_s5 l2_s8)))+ (let ((l2_s10 (proj_2_SBVTuple2 l2_s6)))+ (let ((l2_s12 (- l2_s2 l2_s11)))+ (let ((l2_s13 (seq.extract l2_s0 l2_s11 l2_s12)))+ (let ((l2_s14 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l2_s13 l2_s1)))+ (let ((l2_s15 (ite l2_s9 l2_s10 l2_s14)))+ (let ((l2_s16 (ite l2_s4 l2_s3 l2_s15)))+ l2_s16))))))))))))))))+[GOOD] ; |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| :: [(SString, SInteger)] -> Expr String Integer -> SInteger [Recursive] [Refers to: |get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)|]+[GOOD] (define-fun-rec |eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| ((l1_s0 (Seq (SBVTuple2 String Int))) (l1_s1 (Expr String Int))) Int (let ((l1_s2 ((as is-Val Bool) l1_s1))) (let ((l1_s3 (getVal_1 l1_s1))) (let ((l1_s4 ((as is-Var Bool) l1_s1))) (let ((l1_s5 (getVar_1 l1_s1)))- (let ((l1_s6 (|get @(SBV [([Char],Word16)] -> SBV [Char] -> SBV Word16)| l1_s0 l1_s5)))+ (let ((l1_s6 (|get @(SBV [([Char],Integer)] -> SBV [Char] -> SBV Integer)| l1_s0 l1_s5))) (let ((l1_s7 ((as is-Add Bool) l1_s1))) (let ((l1_s8 (getAdd_1 l1_s1)))- (let ((l1_s9 (|eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| l1_s0 l1_s8)))+ (let ((l1_s9 (|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| l1_s0 l1_s8))) (let ((l1_s10 (getAdd_2 l1_s1)))- (let ((l1_s11 (|eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| l1_s0 l1_s10)))- (let ((l1_s12 (bvadd l1_s9 l1_s11)))+ (let ((l1_s11 (|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| l1_s0 l1_s10)))+ (let ((l1_s12 (+ l1_s9 l1_s11))) (let ((l1_s13 ((as is-Mul Bool) l1_s1))) (let ((l1_s14 (getMul_1 l1_s1)))- (let ((l1_s15 (|eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| l1_s0 l1_s14)))+ (let ((l1_s15 (|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| l1_s0 l1_s14))) (let ((l1_s16 (getMul_2 l1_s1)))- (let ((l1_s17 (|eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| l1_s0 l1_s16)))- (let ((l1_s18 (bvmul l1_s15 l1_s17)))+ (let ((l1_s17 (|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| l1_s0 l1_s16)))+ (let ((l1_s18 (* l1_s15 l1_s17))) (let ((l1_s19 (getLet_1 l1_s1))) (let ((l1_s20 (getLet_2 l1_s1)))- (let ((l1_s21 (|eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| l1_s0 l1_s20)))- (let ((l1_s22 ((as mkSBVTuple2 (SBVTuple2 String (_ BitVec 16))) l1_s19 l1_s21)))+ (let ((l1_s21 (|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| l1_s0 l1_s20)))+ (let ((l1_s22 ((as mkSBVTuple2 (SBVTuple2 String Int)) l1_s19 l1_s21))) (let ((l1_s23 (seq.unit l1_s22))) (let ((l1_s24 (seq.++ l1_s23 l1_s0))) (let ((l1_s25 (getLet_3 l1_s1)))- (let ((l1_s26 (|eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| l1_s24 l1_s25)))+ (let ((l1_s26 (|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| l1_s24 l1_s25))) (let ((l1_s27 (ite l1_s13 l1_s18 l1_s26))) (let ((l1_s28 (ite l1_s7 l1_s12 l1_s27))) (let ((l1_s29 (ite l1_s4 l1_s6 l1_s28))) (let ((l1_s30 (ite l1_s2 l1_s3 l1_s29))) l1_s30)))))))))))))))))))))))))))))) [GOOD] ; --- assignments ----[GOOD] (define-fun s2 () Bool (|valid @(SBV [[Char]] -> SBV (Expr [Char] Word16) -> SBV Bool)| s1 s0))-[GOOD] (define-fun s4 () (_ BitVec 16) (|eval @(SBV [([Char],Word16)] -> SBV (Expr [Char] Word16) -> SBV Word16)| s3 s0))+[GOOD] (define-fun s2 () Bool (|valid @(SBV [[Char]] -> SBV (Expr [Char] Integer) -> SBV Bool)| s1 s0))+[GOOD] (define-fun s4 () Int (|eval @(SBV [([Char],Integer)] -> SBV (Expr [Char] Integer) -> SBV Integer)| s3 s0)) [GOOD] (define-fun s6 () Bool (= s4 s5)) [GOOD] (define-fun s7 () Bool ((as is-Let Bool) s0))-[GOOD] (define-fun s8 () (Expr String (_ BitVec 16)) (getLet_3 s0))+[GOOD] (define-fun s8 () (Expr String Int) (getLet_3 s0)) [GOOD] (define-fun s9 () Bool ((as is-Let Bool) s8))-[GOOD] (define-fun s10 () (Expr String (_ BitVec 16)) (getLet_3 s8))+[GOOD] (define-fun s10 () (Expr String Int) (getLet_3 s8)) [GOOD] (define-fun s11 () Bool ((as is-Add Bool) s10)) [GOOD] ; --- delayedEqualities --- [GOOD] ; --- formula ---@@ -137,13 +267,11 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Let "b"- (Val #x0000)- (Let "a"- (Add (Add (Add (Var "b") (Val #x0800)) (Var "b")) (Val #xf7fc))- (Add (Mul (Var "a") (Var "a")) (Var "a"))))))+[RECV] ((s0 (Let "s"+ (Let "i" (Val 1) (Mul (Val 2) (Add (Var "i") (Var "i"))))+ (Let "a" (Val 9) (Add (Val 3) (Var "a")))))) -Got: (let b = 0 in (let a = (((b + 2048) + b) + 63484) in ((a * a) + a)))+Got: (let s = (let i = 1 in (2 * (i + i))) in (let a = 9 in (3 + a))) DONE *** Solver : Z3 *** Exit code: ExitSuccess
SBVTestSuite/GoldFiles/adt_pgen01.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -37,7 +37,7 @@ [GOOD] (define-fun s33 () Int 100) [GOOD] (define-fun s43 () Int (- 1)) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -52,12 +52,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))
SBVTestSuite/GoldFiles/adt_pgen02.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))
SBVTestSuite/GoldFiles/adt_pgen03.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))
SBVTestSuite/GoldFiles/adt_pgen04.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))
SBVTestSuite/GoldFiles/adt_pgen05.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))@@ -77,7 +77,7 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Val #x0000)))+[RECV] ((s0 (Val 0))) Got: 0 DONE
SBVTestSuite/GoldFiles/adt_pgen06.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))@@ -77,7 +77,7 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Val #x000a)))+[RECV] ((s0 (Val 10))) Got: 10 DONE
SBVTestSuite/GoldFiles/adt_pgen07.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))@@ -77,7 +77,7 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Val #x000b)))+[RECV] ((s0 (Val 11))) Got: 11 DONE
SBVTestSuite/GoldFiles/adt_pgen08.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))@@ -77,9 +77,9 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Add (Val #x0000) (Val #x0000))))+[RECV] ((s0 (Add (Val 3) (Val 2)))) -Got: (0 + 0)+Got: (3 + 2) DONE *** Solver : Z3 *** Exit code: ExitSuccess
SBVTestSuite/GoldFiles/adt_pgen09.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))@@ -77,9 +77,9 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Mul (Val #x0000) (Val #x0000))))+[RECV] ((s0 (Mul (Val 3) (Val 2)))) -Got: (0 * 0)+Got: (3 * 2) DONE *** Solver : Z3 *** Exit code: ExitSuccess
SBVTestSuite/GoldFiles/adt_pgen10.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))@@ -77,9 +77,9 @@ [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0))-[RECV] ((s0 (Let "!0!" (Val #x0000) (Val #x0000))))+[RECV] ((s0 (Let "!0!" (Val 3) (Val 2)))) -Got: (let !0! = 0 in 0)+Got: (let !0! = 3 in 2) DONE *** Solver : Z3 *** Exit code: ExitSuccess
SBVTestSuite/GoldFiles/adt_pgen11.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -37,7 +37,7 @@ [GOOD] (define-fun s33 () Int 100) [GOOD] (define-fun s43 () Int 9) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -52,12 +52,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))
SBVTestSuite/GoldFiles/adt_pgen12.gold view
@@ -27,7 +27,7 @@ [GOOD] (define-fun s9 () String "c") [GOOD] (define-fun s13 () Int 1) [GOOD] (define-fun s14 () Int 2)-[GOOD] (define-fun s17 () (_ BitVec 16) #x000a)+[GOOD] (define-fun s17 () Int 10) [GOOD] (define-fun s20 () Int 3) [GOOD] (define-fun s23 () Int 4) [GOOD] (define-fun s26 () Int 5)@@ -36,7 +36,7 @@ [GOOD] (define-fun s32 () Int 8) [GOOD] (define-fun s33 () Int 100) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (Expr String (_ BitVec 16))) ; tracks user variable "a"+[GOOD] (declare-fun s0 () (Expr String Int)) ; tracks user variable "a" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants ---@@ -51,12 +51,12 @@ [GOOD] (define-fun s11 () Bool (or s8 s10)) [GOOD] (define-fun s12 () Bool (and s1 s11)) [GOOD] (define-fun s15 () Bool ((as is-Val Bool) s0))-[GOOD] (define-fun s16 () (_ BitVec 16) (getVal_1 s0))-[GOOD] (define-fun s18 () Bool (bvult s16 s17))+[GOOD] (define-fun s16 () Int (getVal_1 s0))+[GOOD] (define-fun s18 () Bool (< s16 s17)) [GOOD] (define-fun s19 () Bool (and s15 s18)) [GOOD] (define-fun s21 () Bool (= s16 s17)) [GOOD] (define-fun s22 () Bool (and s15 s21))-[GOOD] (define-fun s24 () Bool (bvugt s16 s17))+[GOOD] (define-fun s24 () Bool (> s16 s17)) [GOOD] (define-fun s25 () Bool (and s15 s24)) [GOOD] (define-fun s27 () Bool ((as is-Add Bool) s0)) [GOOD] (define-fun s29 () Bool ((as is-Mul Bool) s0))
SBVTestSuite/GoldFiles/doctest_sanity.gold view
@@ -1,3 +1,3 @@-Total: 1169; Tried: 1169; Skipped: 0; Success: 1169; Errors: 0; Failures 0-Examples: 1038; Tried: 1038; Skipped: 0; Success: 1038; Errors: 0; Failures 0-Setup: 131; Tried: 131; Skipped: 0; Success: 131; Errors: 0; Failures 0+Total: 1198; Tried: 1198; Skipped: 0; Success: 1198; Errors: 0; Failures 0+Examples: 1061; Tried: 1061; Skipped: 0; Success: 1061; Errors: 0; Failures 0+Setup: 137; Tried: 137; Skipped: 0; Success: 137; Errors: 0; Failures 0
SBVTestSuite/GoldFiles/lambda04.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])+[MEASURE] sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool]): barified = "|sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])|"+[MEASURE] sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])}: replaying 8 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -12,6 +19,92 @@ [GOOD] ; --- tuples --- [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Bool) (as seq.empty (Seq Bool)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s9 () (Seq Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Bool) (seq.unit false))+[GOOD] (define-fun s7 () Int (- s4 s2))+[GOOD] (define-fun s8 () (Seq Int) (seq.extract s0 s2 s7))+[GOOD] (define-fun s10 () (Seq Bool) (seq.++ s6 s9))+[GOOD] (define-fun s11 () (Seq Bool) (ite s5 s3 s10))+[GOOD] (define-fun s12 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Bool) (as seq.empty (Seq Bool)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s9 () (Seq Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Bool) (seq.unit false))+[GOOD] (define-fun s7 () Int (- s4 s2))+[GOOD] (define-fun s8 () (Seq Int) (seq.extract s0 s2 s7))+[GOOD] (define-fun s10 () (Seq Bool) (seq.++ s6 s9))+[GOOD] (define-fun s11 () (Seq Bool) (ite s5 s3 s10))+[GOOD] (define-fun s12 () Int (seq.len s8))+[GOOD] (define-fun s13 () Bool (not s5))+[GOOD] (define-fun s14 () Bool (> s4 s12))+[GOOD] (define-fun s15 () Bool (=> s13 s14))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants --- [GOOD] (define-fun s2 () (Seq Int) (seq.++ (seq.unit 1) (seq.unit 2) (seq.unit 3))) [GOOD] ; --- top level inputs --- [GOOD] (declare-fun s0 () (Seq Int))@@ -24,10 +117,10 @@ [GOOD] (define-fun-rec |sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])| ((l1_s0 (Seq Int))) (Seq Bool) (let ((l1_s2 0)) (let ((l1_s4 (as seq.empty (Seq Bool))))- (let ((l1_s5 (seq.unit false))) (let ((l1_s6 1)) (let ((l1_s1 (seq.len l1_s0))) (let ((l1_s3 (= l1_s1 l1_s2)))+ (let ((l1_s5 (seq.unit false))) (let ((l1_s7 (- l1_s1 l1_s6))) (let ((l1_s8 (seq.extract l1_s0 l1_s6 l1_s7))) (let ((l1_s9 (|sbv.map @(SBV Integer -> SBV Bool)_96a983e094 @(SBV [Integer] -> SBV [Bool])| l1_s8)))
SBVTestSuite/GoldFiles/lambda05.gold view
@@ -1,3 +1,198 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer]), sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq Int)) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (+ s3 s7))+[GOOD] (define-fun s9 () (Seq Int) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s0 s2 s10))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq Int)) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (+ s3 s7))+[GOOD] (define-fun s9 () (Seq Int) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s0 s2 s10))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Int (seq.len s11))+[GOOD] (define-fun s16 () Bool (not s6))+[GOOD] (define-fun s17 () Bool (> s5 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV Integer)_6e8bf9627c @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () (Seq Int)) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (+ s2 s6))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s0 s2 s9))+[GOOD] (define-fun s12 () (Seq Int) (seq.++ s8 s11))+[GOOD] (define-fun s13 () (Seq Int) (ite s5 s3 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () (Seq Int)) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (+ s2 s6))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s0 s2 s9))+[GOOD] (define-fun s12 () (Seq Int) (seq.++ s8 s11))+[GOOD] (define-fun s13 () (Seq Int) (ite s5 s3 s12))+[GOOD] (define-fun s14 () Int (seq.len s10))+[GOOD] (define-fun s15 () Bool (not s5))+[GOOD] (define-fun s16 () Bool (> s4 s14))+[GOOD] (define-fun s17 () Bool (=> s15 s16))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda06.gold view
@@ -1,3 +1,134 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer])}: replaying 27 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s28 () (Seq Int)) ; tracks user variable "__internal_sbv_s28"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (* s6 s6))+[GOOD] (define-fun s8 () Int (+ s6 s7))+[GOOD] (define-fun s9 () Int (* s6 s7))+[GOOD] (define-fun s10 () Int (+ s8 s9))+[GOOD] (define-fun s11 () Int (* s7 s7))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () Int (* s6 s11))+[GOOD] (define-fun s14 () Int (+ s12 s13))+[GOOD] (define-fun s15 () Int (* s7 s11))+[GOOD] (define-fun s16 () Int (+ s14 s15))+[GOOD] (define-fun s17 () Int (* s6 s15))+[GOOD] (define-fun s18 () Int (+ s16 s17))+[GOOD] (define-fun s19 () Int (* s11 s11))+[GOOD] (define-fun s20 () Int (+ s18 s19))+[GOOD] (define-fun s21 () Int (* s6 s19))+[GOOD] (define-fun s22 () Int (+ s20 s21))+[GOOD] (define-fun s23 () Int (* s7 s19))+[GOOD] (define-fun s24 () Int (+ s22 s23))+[GOOD] (define-fun s25 () (Seq Int) (seq.unit s24))+[GOOD] (define-fun s26 () Int (- s4 s2))+[GOOD] (define-fun s27 () (Seq Int) (seq.extract s0 s2 s26))+[GOOD] (define-fun s29 () (Seq Int) (seq.++ s25 s28))+[GOOD] (define-fun s30 () (Seq Int) (ite s5 s3 s29))+[GOOD] (define-fun s31 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s31))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer])}: replaying 27 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s28 () (Seq Int)) ; tracks user variable "__internal_sbv_s28"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (* s6 s6))+[GOOD] (define-fun s8 () Int (+ s6 s7))+[GOOD] (define-fun s9 () Int (* s6 s7))+[GOOD] (define-fun s10 () Int (+ s8 s9))+[GOOD] (define-fun s11 () Int (* s7 s7))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () Int (* s6 s11))+[GOOD] (define-fun s14 () Int (+ s12 s13))+[GOOD] (define-fun s15 () Int (* s7 s11))+[GOOD] (define-fun s16 () Int (+ s14 s15))+[GOOD] (define-fun s17 () Int (* s6 s15))+[GOOD] (define-fun s18 () Int (+ s16 s17))+[GOOD] (define-fun s19 () Int (* s11 s11))+[GOOD] (define-fun s20 () Int (+ s18 s19))+[GOOD] (define-fun s21 () Int (* s6 s19))+[GOOD] (define-fun s22 () Int (+ s20 s21))+[GOOD] (define-fun s23 () Int (* s7 s19))+[GOOD] (define-fun s24 () Int (+ s22 s23))+[GOOD] (define-fun s25 () (Seq Int) (seq.unit s24))+[GOOD] (define-fun s26 () Int (- s4 s2))+[GOOD] (define-fun s27 () (Seq Int) (seq.extract s0 s2 s26))+[GOOD] (define-fun s29 () (Seq Int) (seq.++ s25 s28))+[GOOD] (define-fun s30 () (Seq Int) (ite s5 s3 s29))+[GOOD] (define-fun s31 () Int (seq.len s27))+[GOOD] (define-fun s32 () Bool (not s5))+[GOOD] (define-fun s33 () Bool (> s4 s31))+[GOOD] (define-fun s34 () Bool (=> s32 s33))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s34))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV Integer)_b01b78a2e9 @(SBV [Integer] -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda07.gold view
@@ -1,3 +1,329 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]), sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]), sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_b97075844e @(SBV (Integer,[Integer]) -> SBV Integer), sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])+[MEASURE] sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])+[MEASURE] Checking: sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])+[MEASURE] sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]): barified = "|sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])|"+[MEASURE] sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|",1),("|sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])|",1)]+[MEASURE] sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s12 () (Seq Int)) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (seq.nth s0 s1))+[GOOD] (define-fun s7 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s1 s6))+[GOOD] (define-fun s9 () (Seq Int) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s4 s2))+[GOOD] (define-fun s11 () (Seq (Seq Int)) (seq.extract s0 s2 s10))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s3 s13))+[GOOD] (define-fun s15 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s12 () (Seq Int)) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (seq.nth s0 s1))+[GOOD] (define-fun s7 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s1 s6))+[GOOD] (define-fun s9 () (Seq Int) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s4 s2))+[GOOD] (define-fun s11 () (Seq (Seq Int)) (seq.extract s0 s2 s10))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s3 s13))+[GOOD] (define-fun s15 () Int (seq.len s11))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV [Integer] -> SBV Integer)_1b9bf3f573 @(SBV [[Integer]] -> SBV [Integer])+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_b97075844e @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_b97075844e @(SBV (Integer,[Integer]) -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_b97075844e @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): barified = "|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|"+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Int (proj_1_SBVTuple2 s10))+[GOOD] (define-fun s16 () Int (abs s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s14 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s16))+[RECV] ((s16 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit 2))))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[2]) :: (Integer, [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () (Seq Int) (proj_2_SBVTuple2 s10))+[GOOD] (define-fun s15 () Int (seq.len s14))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda08.gold view
@@ -1,3 +1,102 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64])+[MEASURE] Checking: sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64])+[MEASURE] sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64]): barified = "|sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64])|"+[MEASURE] sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64])|",1)]+[MEASURE] sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 64) #x0000000000000001)+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (_ BitVec 64)) (as seq.empty (Seq (_ BitVec 64))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ BitVec 64))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq (_ BitVec 64))) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () (_ BitVec 64) (seq.nth s0 s2))+[GOOD] (define-fun s8 () (_ BitVec 64) (bvadd s1 s7))+[GOOD] (define-fun s9 () (Seq (_ BitVec 64)) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s3))+[GOOD] (define-fun s11 () (Seq (_ BitVec 64)) (seq.extract s0 s3 s10))+[GOOD] (define-fun s13 () (Seq (_ BitVec 64)) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq (_ BitVec 64)) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Bool (>= s5 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 64) #x0000000000000001)+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (_ BitVec 64)) (as seq.empty (Seq (_ BitVec 64))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ BitVec 64))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq (_ BitVec 64))) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () (_ BitVec 64) (seq.nth s0 s2))+[GOOD] (define-fun s8 () (_ BitVec 64) (bvadd s1 s7))+[GOOD] (define-fun s9 () (Seq (_ BitVec 64)) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s3))+[GOOD] (define-fun s11 () (Seq (_ BitVec 64)) (seq.extract s0 s3 s10))+[GOOD] (define-fun s13 () (Seq (_ BitVec 64)) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq (_ BitVec 64)) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Int (seq.len s11))+[GOOD] (define-fun s16 () Bool (not s6))+[GOOD] (define-fun s17 () Bool (> s5 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Int64 -> SBV Int64)_bc2a222730 @(SBV [Int64] -> SBV [Int64]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda09.gold view
@@ -1,3 +1,102 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8])+[MEASURE] Checking: sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8])+[MEASURE] sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8]): barified = "|sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8])|"+[MEASURE] sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8])|",1)]+[MEASURE] sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x01)+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (_ BitVec 8)) (as seq.empty (Seq (_ BitVec 8))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ BitVec 8))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq (_ BitVec 8))) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () (_ BitVec 8) (seq.nth s0 s2))+[GOOD] (define-fun s8 () (_ BitVec 8) (bvadd s1 s7))+[GOOD] (define-fun s9 () (Seq (_ BitVec 8)) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s3))+[GOOD] (define-fun s11 () (Seq (_ BitVec 8)) (seq.extract s0 s3 s10))+[GOOD] (define-fun s13 () (Seq (_ BitVec 8)) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq (_ BitVec 8)) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Bool (>= s5 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x01)+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (_ BitVec 8)) (as seq.empty (Seq (_ BitVec 8))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ BitVec 8))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq (_ BitVec 8))) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () (_ BitVec 8) (seq.nth s0 s2))+[GOOD] (define-fun s8 () (_ BitVec 8) (bvadd s1 s7))+[GOOD] (define-fun s9 () (Seq (_ BitVec 8)) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s3))+[GOOD] (define-fun s11 () (Seq (_ BitVec 8)) (seq.extract s0 s3 s10))+[GOOD] (define-fun s13 () (Seq (_ BitVec 8)) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq (_ BitVec 8)) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Int (seq.len s11))+[GOOD] (define-fun s16 () Bool (not s6))+[GOOD] (define-fun s17 () Bool (> s5 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Int8 -> SBV Int8)_5111aac2ea @(SBV [Int8] -> SBV [Int8]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda10.gold view
@@ -1,3 +1,100 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () (Seq Int)) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (+ s2 s6))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s0 s2 s9))+[GOOD] (define-fun s12 () (Seq Int) (seq.++ s8 s11))+[GOOD] (define-fun s13 () (Seq Int) (ite s5 s3 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () (Seq Int)) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (+ s2 s6))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s0 s2 s9))+[GOOD] (define-fun s12 () (Seq Int) (seq.++ s8 s11))+[GOOD] (define-fun s13 () (Seq Int) (ite s5 s3 s12))+[GOOD] (define-fun s14 () Int (seq.len s10))+[GOOD] (define-fun s15 () Bool (not s5))+[GOOD] (define-fun s16 () Bool (> s4 s14))+[GOOD] (define-fun s17 () Bool (=> s15 s16))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV Integer)_aaa4562f59 @(SBV [Integer] -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda11.gold view
@@ -1,3 +1,102 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8])+[MEASURE] Checking: sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8])+[MEASURE] sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8]): barified = "|sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8])|"+[MEASURE] sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8])|",1)]+[MEASURE] sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x01)+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (_ BitVec 8)) (as seq.empty (Seq (_ BitVec 8))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ BitVec 8))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq (_ BitVec 8))) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () (_ BitVec 8) (seq.nth s0 s2))+[GOOD] (define-fun s8 () (_ BitVec 8) (bvadd s1 s7))+[GOOD] (define-fun s9 () (Seq (_ BitVec 8)) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s3))+[GOOD] (define-fun s11 () (Seq (_ BitVec 8)) (seq.extract s0 s3 s10))+[GOOD] (define-fun s13 () (Seq (_ BitVec 8)) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq (_ BitVec 8)) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Bool (>= s5 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x01)+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (_ BitVec 8)) (as seq.empty (Seq (_ BitVec 8))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ BitVec 8))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq (_ BitVec 8))) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () (_ BitVec 8) (seq.nth s0 s2))+[GOOD] (define-fun s8 () (_ BitVec 8) (bvadd s1 s7))+[GOOD] (define-fun s9 () (Seq (_ BitVec 8)) (seq.unit s8))+[GOOD] (define-fun s10 () Int (- s5 s3))+[GOOD] (define-fun s11 () (Seq (_ BitVec 8)) (seq.extract s0 s3 s10))+[GOOD] (define-fun s13 () (Seq (_ BitVec 8)) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq (_ BitVec 8)) (ite s6 s4 s13))+[GOOD] (define-fun s15 () Int (seq.len s11))+[GOOD] (define-fun s16 () Bool (not s6))+[GOOD] (define-fun s17 () Bool (> s5 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Word8 -> SBV Word8)_5111aac2ea @(SBV [Word8] -> SBV [Word8]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda12.gold view
@@ -1,3 +1,100 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]]): barified = "|sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]])|"+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq (Seq Int)) (as seq.empty (Seq (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () (Seq (Seq Int))) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () (Seq Int) (seq.unit s6))+[GOOD] (define-fun s8 () (Seq (Seq Int)) (seq.unit s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s0 s2 s9))+[GOOD] (define-fun s12 () (Seq (Seq Int)) (seq.++ s8 s11))+[GOOD] (define-fun s13 () (Seq (Seq Int)) (ite s5 s3 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]])}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq (Seq Int)) (as seq.empty (Seq (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () (Seq (Seq Int))) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s7 () (Seq Int) (seq.unit s6))+[GOOD] (define-fun s8 () (Seq (Seq Int)) (seq.unit s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s0 s2 s9))+[GOOD] (define-fun s12 () (Seq (Seq Int)) (seq.++ s8 s11))+[GOOD] (define-fun s13 () (Seq (Seq Int)) (ite s5 s3 s12))+[GOOD] (define-fun s14 () Int (seq.len s10))+[GOOD] (define-fun s15 () Bool (not s5))+[GOOD] (define-fun s16 () Bool (> s4 s14))+[GOOD] (define-fun s17 () Bool (=> s15 s16))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV [Integer])_661d2aaa20 @(SBV [Integer] -> SBV [[Integer]]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda13.gold view
@@ -1,3 +1,110 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])+[MEASURE] Checking: sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): barified = "|sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])|"+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])|",1)]+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (SBVTuple2 Int Int) (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s6))+[GOOD] (define-fun s8 () Int (proj_2_SBVTuple2 s6))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s5 s3 s14))+[GOOD] (define-fun s16 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (SBVTuple2 Int Int) (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s6))+[GOOD] (define-fun s8 () Int (proj_2_SBVTuple2 s6))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s5 s3 s14))+[GOOD] (define-fun s16 () Int (seq.len s12))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s4 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda14.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] Checking: sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): barified = "|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])|"+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])|",1)]+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying length arg1._1+[MEASURE] replayDAG {sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 19 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -15,6 +22,123 @@ (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s19 () (Seq Int)) ; tracks user variable "__internal_sbv_s19"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.len s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s4 s1))+[GOOD] (define-fun s11 () Int (seq.nth s7 s1))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.unit s12))+[GOOD] (define-fun s14 () Int (- s5 s2))+[GOOD] (define-fun s15 () (Seq Int) (seq.extract s4 s2 s14))+[GOOD] (define-fun s16 () Int (- s8 s2))+[GOOD] (define-fun s17 () (Seq Int) (seq.extract s7 s2 s16))+[GOOD] (define-fun s18 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s17))+[GOOD] (define-fun s20 () (Seq Int) (seq.++ s13 s19))+[GOOD] (define-fun s21 () (Seq Int) (ite s9 s3 s20))+[GOOD] (define-fun s22 () (Seq Int) (ite s6 s3 s21))+[GOOD] (define-fun s23 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 19 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s19 () (Seq Int)) ; tracks user variable "__internal_sbv_s19"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.len s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s4 s1))+[GOOD] (define-fun s11 () Int (seq.nth s7 s1))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.unit s12))+[GOOD] (define-fun s14 () Int (- s5 s2))+[GOOD] (define-fun s15 () (Seq Int) (seq.extract s4 s2 s14))+[GOOD] (define-fun s16 () Int (- s8 s2))+[GOOD] (define-fun s17 () (Seq Int) (seq.extract s7 s2 s16))+[GOOD] (define-fun s18 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s17))+[GOOD] (define-fun s20 () (Seq Int) (seq.++ s13 s19))+[GOOD] (define-fun s21 () (Seq Int) (ite s9 s3 s20))+[GOOD] (define-fun s22 () (Seq Int) (ite s6 s3 s21))+[GOOD] (define-fun s23 () (Seq Int) (proj_1_SBVTuple2 s18))+[GOOD] (define-fun s24 () Int (seq.len s23))+[GOOD] (define-fun s25 () Bool (not s9))+[GOOD] (define-fun s26 () Bool (not s6))+[GOOD] (define-fun s27 () Bool (and s25 s26))+[GOOD] (define-fun s28 () Bool (> s5 s24))+[GOOD] (define-fun s29 () Bool (=> s27 s28))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s29))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): length arg1._1 -> OK+[MEASURE] Passed (terminating): sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants --- [GOOD] (define-fun s2 () (Seq Int) (seq.++ (seq.unit 1) (seq.unit 2) (seq.unit 3) (seq.unit 4) (seq.unit 5))) [GOOD] (define-fun s4 () (Seq Int) (seq.++ (seq.unit 10) (seq.unit 11) (seq.unit 12) (seq.unit 13) (seq.unit 14) (seq.unit 15))) [GOOD] ; --- top level inputs ---@@ -27,27 +151,27 @@ [GOOD] ; |sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| :: ([SInteger], [SInteger]) -> [SInteger] [Recursive] [GOOD] (define-fun-rec |sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| ((l1_s0 (SBVTuple2 (Seq Int) (Seq Int)))) (Seq Int) (let ((l1_s3 0))- (let ((l1_s9 (as seq.empty (Seq Int))))- (let ((l1_s14 1))+ (let ((l1_s5 (as seq.empty (Seq Int))))+ (let ((l1_s13 1)) (let ((l1_s1 (proj_1_SBVTuple2 l1_s0))) (let ((l1_s2 (seq.len l1_s1))) (let ((l1_s4 (= l1_s2 l1_s3)))- (let ((l1_s5 (proj_2_SBVTuple2 l1_s0)))- (let ((l1_s6 (seq.len l1_s5)))- (let ((l1_s7 (= l1_s3 l1_s6)))- (let ((l1_s8 (or l1_s4 l1_s7)))- (let ((l1_s10 (seq.nth l1_s1 l1_s3)))- (let ((l1_s11 (seq.nth l1_s5 l1_s3)))- (let ((l1_s12 (+ l1_s10 l1_s11)))- (let ((l1_s13 (seq.unit l1_s12)))- (let ((l1_s15 (- l1_s2 l1_s14)))- (let ((l1_s16 (seq.extract l1_s1 l1_s14 l1_s15)))- (let ((l1_s17 (- l1_s6 l1_s14)))- (let ((l1_s18 (seq.extract l1_s5 l1_s14 l1_s17)))- (let ((l1_s19 ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) l1_s16 l1_s18)))- (let ((l1_s20 (|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| l1_s19)))- (let ((l1_s21 (seq.++ l1_s13 l1_s20)))- (let ((l1_s22 (ite l1_s8 l1_s9 l1_s21)))+ (let ((l1_s6 (proj_2_SBVTuple2 l1_s0)))+ (let ((l1_s7 (seq.len l1_s6)))+ (let ((l1_s8 (= l1_s3 l1_s7)))+ (let ((l1_s9 (seq.nth l1_s1 l1_s3)))+ (let ((l1_s10 (seq.nth l1_s6 l1_s3)))+ (let ((l1_s11 (+ l1_s9 l1_s10)))+ (let ((l1_s12 (seq.unit l1_s11)))+ (let ((l1_s14 (- l1_s2 l1_s13)))+ (let ((l1_s15 (seq.extract l1_s1 l1_s13 l1_s14)))+ (let ((l1_s16 (- l1_s7 l1_s13)))+ (let ((l1_s17 (seq.extract l1_s6 l1_s13 l1_s16)))+ (let ((l1_s18 ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) l1_s15 l1_s17)))+ (let ((l1_s19 (|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| l1_s18)))+ (let ((l1_s20 (seq.++ l1_s12 l1_s19)))+ (let ((l1_s21 (ite l1_s8 l1_s5 l1_s20)))+ (let ((l1_s22 (ite l1_s4 l1_s5 l1_s21))) l1_s22))))))))))))))))))))))) [GOOD] ; --- assignments --- [GOOD] (define-fun s3 () Bool (= s0 s2))
SBVTestSuite/GoldFiles/lambda15.gold view
@@ -1,3 +1,219 @@+[MEASURE] Verifying termination measures for: sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): barified = "|sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|"+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (+ s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (+ s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s16 () Int (abs s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s14 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s16))+[RECV] ((s16 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit 0))))+[SEND] (get-value (s12))+[RECV] ((s12 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[0]) :: (Integer, [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (+ s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (+ s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () (Seq Int) (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Int (seq.len s14))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda16.gold view
@@ -1,3 +1,219 @@+[MEASURE] Verifying termination measures for: sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): barified = "|sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)|"+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (* s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (* s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s16 () Int (abs s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s14 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 1))+[SEND] (get-value (s16))+[RECV] ((s16 1))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 1 (seq.unit 1))))+[SEND] (get-value (s12))+[RECV] ((s12 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (1,[1]) :: (Integer, [Integer])+ before = 1 :: Integer+ then = 1 :: Integer+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (* s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () Int) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (* s6 s7))+[GOOD] (define-fun s9 () Int (- s4 s2))+[GOOD] (define-fun s10 () (Seq Int) (seq.extract s3 s2 s9))+[GOOD] (define-fun s11 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s8 s10))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () (Seq Int) (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Int (seq.len s14))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldl @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda17.gold view
@@ -1,3 +1,223 @@+[MEASURE] Verifying termination measures for: sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] Checking: sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): barified = "|sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])|"+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])|",1)]+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying length arg1._1+[MEASURE] replayDAG {sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () (Seq Int) (seq.++ s8 s6))+[GOOD] (define-fun s10 () Int (- s4 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s3 s2 s10))+[GOOD] (define-fun s12 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s9 s11))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () Int (seq.len s6))+[GOOD] (define-fun s16 () Bool (>= s15 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () (Seq Int) (seq.++ s8 s6))+[GOOD] (define-fun s10 () Int (- s4 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s3 s2 s10))+[GOOD] (define-fun s12 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s9 s11))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () Int (seq.len s6))+[GOOD] (define-fun s16 () (Seq Int) (proj_1_SBVTuple2 s12))+[GOOD] (define-fun s17 () Int (seq.len s16))+[GOOD] (define-fun s18 () Bool (not s5))+[GOOD] (define-fun s19 () Bool (> s15 s17))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s20))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s15))+[RECV] ((s15 0))+[SEND] (get-value (s17))+[RECV] ((s17 1))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 (as seq.empty (Seq Int)) (seq.unit 2))))+[SEND] (get-value (s13))+[RECV] ((s13 (as seq.empty (Seq Int))))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): length arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = ([],[2]) :: ([Integer], [Integer])+ before = 0 :: Integer+ then = 1 :: Integer+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying next candidate..+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying length arg1._2+[MEASURE] replayDAG {sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () (Seq Int) (seq.++ s8 s6))+[GOOD] (define-fun s10 () Int (- s4 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s3 s2 s10))+[GOOD] (define-fun s12 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s9 s11))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s9 () (Seq Int) (seq.++ s8 s6))+[GOOD] (define-fun s10 () Int (- s4 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s3 s2 s10))+[GOOD] (define-fun s12 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s9 s11))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () (Seq Int) (proj_2_SBVTuple2 s12))+[GOOD] (define-fun s16 () Int (seq.len s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s4 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldl @(SBV ([Integer],Integer) -> SBV [Integer])_2d6951daf1 @(SBV ([Integer],[Integer]) -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda18.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]), sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)+[MEASURE] Checking: sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): barified = "|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])|"+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): Uninterpreted ops in DAG: [("|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])|",2)]+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): recursive calls found = 1+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): trying length arg1+[MEASURE] replayDAG {sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])}: replaying 16 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -15,6 +22,345 @@ (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (SBVTuple2 Int Int)) (as seq.empty (Seq (SBVTuple2 Int Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq Int)) ; tracks user variable "arg1"+[GOOD] (declare-fun s17 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "__internal_sbv_s17"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () Int (seq.len s1))+[GOOD] (define-fun s8 () Bool (= s2 s7))+[GOOD] (define-fun s9 () Int (seq.nth s0 s2))+[GOOD] (define-fun s10 () Int (seq.nth s1 s2))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.unit s11))+[GOOD] (define-fun s13 () Int (- s5 s3))+[GOOD] (define-fun s14 () (Seq Int) (seq.extract s0 s3 s13))+[GOOD] (define-fun s15 () Int (- s7 s3))+[GOOD] (define-fun s16 () (Seq Int) (seq.extract s1 s3 s15))+[GOOD] (define-fun s18 () (Seq (SBVTuple2 Int Int)) (seq.++ s12 s17))+[GOOD] (define-fun s19 () (Seq (SBVTuple2 Int Int)) (ite s8 s4 s18))+[GOOD] (define-fun s20 () (Seq (SBVTuple2 Int Int)) (ite s6 s4 s19))+[GOOD] (define-fun s21 () Bool (>= s5 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])}: replaying 16 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (SBVTuple2 Int Int)) (as seq.empty (Seq (SBVTuple2 Int Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq Int)) ; tracks user variable "arg1"+[GOOD] (declare-fun s17 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "__internal_sbv_s17"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () Int (seq.len s1))+[GOOD] (define-fun s8 () Bool (= s2 s7))+[GOOD] (define-fun s9 () Int (seq.nth s0 s2))+[GOOD] (define-fun s10 () Int (seq.nth s1 s2))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.unit s11))+[GOOD] (define-fun s13 () Int (- s5 s3))+[GOOD] (define-fun s14 () (Seq Int) (seq.extract s0 s3 s13))+[GOOD] (define-fun s15 () Int (- s7 s3))+[GOOD] (define-fun s16 () (Seq Int) (seq.extract s1 s3 s15))+[GOOD] (define-fun s18 () (Seq (SBVTuple2 Int Int)) (seq.++ s12 s17))+[GOOD] (define-fun s19 () (Seq (SBVTuple2 Int Int)) (ite s8 s4 s18))+[GOOD] (define-fun s20 () (Seq (SBVTuple2 Int Int)) (ite s6 s4 s19))+[GOOD] (define-fun s21 () Int (seq.len s14))+[GOOD] (define-fun s22 () Bool (not s8))+[GOOD] (define-fun s23 () Bool (not s6))+[GOOD] (define-fun s24 () Bool (and s22 s23))+[GOOD] (define-fun s25 () Bool (> s5 s21))+[GOOD] (define-fun s26 () Bool (=> s24 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])+[MEASURE] Checking: sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): barified = "|sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)|"+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)}: replaying 14 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) ; tracks user variable "arg"+[GOOD] (declare-fun s15 () Int) ; tracks user variable "__internal_sbv_s15"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq (SBVTuple2 Int Int)) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () (SBVTuple2 Int Int) (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s11 () Int (+ s9 s10))+[GOOD] (define-fun s12 () Int (- s4 s2))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 Int Int)) (seq.extract s3 s2 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int))) ((as mkSBVTuple2 (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) s11 s13))+[GOOD] (define-fun s16 () Int (ite s5 s6 s15))+[GOOD] (define-fun s17 () Int (abs s6))+[GOOD] (define-fun s18 () Bool (>= s17 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)}: replaying 14 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) ; tracks user variable "arg"+[GOOD] (declare-fun s15 () Int) ; tracks user variable "__internal_sbv_s15"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq (SBVTuple2 Int Int)) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () (SBVTuple2 Int Int) (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s11 () Int (+ s9 s10))+[GOOD] (define-fun s12 () Int (- s4 s2))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 Int Int)) (seq.extract s3 s2 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int))) ((as mkSBVTuple2 (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) s11 s13))+[GOOD] (define-fun s16 () Int (ite s5 s6 s15))+[GOOD] (define-fun s17 () Int (abs s6))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s14))+[GOOD] (define-fun s19 () Int (abs s18))+[GOOD] (define-fun s20 () Bool (not s5))+[GOOD] (define-fun s21 () Bool (> s17 s19))+[GOOD] (define-fun s22 () Bool (=> s20 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s17))+[RECV] ((s17 0))+[SEND] (get-value (s19))+[RECV] ((s19 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit (mkSBVTuple2 0 0)))))+[SEND] (get-value (s15))+[RECV] ((s15 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[(0,0)]) :: (Integer, [(Integer, Integer)])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)}: replaying 14 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) ; tracks user variable "arg"+[GOOD] (declare-fun s15 () Int) ; tracks user variable "__internal_sbv_s15"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq (SBVTuple2 Int Int)) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () (SBVTuple2 Int Int) (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s11 () Int (+ s9 s10))+[GOOD] (define-fun s12 () Int (- s4 s2))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 Int Int)) (seq.extract s3 s2 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int))) ((as mkSBVTuple2 (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) s11 s13))+[GOOD] (define-fun s16 () Int (ite s5 s6 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)}: replaying 14 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) ; tracks user variable "arg"+[GOOD] (declare-fun s15 () Int) ; tracks user variable "__internal_sbv_s15"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq (SBVTuple2 Int Int)) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () (SBVTuple2 Int Int) (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (proj_1_SBVTuple2 s7))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (proj_2_SBVTuple2 s7))+[GOOD] (define-fun s11 () Int (+ s9 s10))+[GOOD] (define-fun s12 () Int (- s4 s2))+[GOOD] (define-fun s13 () (Seq (SBVTuple2 Int Int)) (seq.extract s3 s2 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Int (Seq (SBVTuple2 Int Int))) ((as mkSBVTuple2 (SBVTuple2 Int (Seq (SBVTuple2 Int Int)))) s11 s13))+[GOOD] (define-fun s16 () Int (ite s5 s6 s15))+[GOOD] (define-fun s17 () (Seq (SBVTuple2 Int Int)) (proj_2_SBVTuple2 s14))+[GOOD] (define-fun s18 () Int (seq.len s17))+[GOOD] (define-fun s19 () Bool (not s5))+[GOOD] (define-fun s20 () Bool (> s4 s18))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants --- [GOOD] (define-fun s2 () (Seq Int) (seq.++ (seq.unit 1) (seq.unit 2) (seq.unit 3) (seq.unit 4) (seq.unit 5))) [GOOD] (define-fun s4 () Int 0) [GOOD] (define-fun s5 () (Seq Int) (seq.++ (seq.unit 10) (seq.unit 11) (seq.unit 12) (seq.unit 13) (seq.unit 14) (seq.unit 15)))@@ -28,24 +374,24 @@ [GOOD] ; |sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| :: [SInteger] -> [SInteger] -> [(SInteger, SInteger)] [Recursive] [GOOD] (define-fun-rec |sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| ((l1_s0 (Seq Int)) (l1_s1 (Seq Int))) (Seq (SBVTuple2 Int Int)) (let ((l1_s3 0))- (let ((l1_s8 (as seq.empty (Seq (SBVTuple2 Int Int)))))- (let ((l1_s13 1))+ (let ((l1_s5 (as seq.empty (Seq (SBVTuple2 Int Int)))))+ (let ((l1_s12 1)) (let ((l1_s2 (seq.len l1_s0))) (let ((l1_s4 (= l1_s2 l1_s3)))- (let ((l1_s5 (seq.len l1_s1)))- (let ((l1_s6 (= l1_s3 l1_s5)))- (let ((l1_s7 (or l1_s4 l1_s6)))- (let ((l1_s9 (seq.nth l1_s0 l1_s3)))- (let ((l1_s10 (seq.nth l1_s1 l1_s3)))- (let ((l1_s11 ((as mkSBVTuple2 (SBVTuple2 Int Int)) l1_s9 l1_s10)))- (let ((l1_s12 (seq.unit l1_s11)))- (let ((l1_s14 (- l1_s2 l1_s13)))- (let ((l1_s15 (seq.extract l1_s0 l1_s13 l1_s14)))- (let ((l1_s16 (- l1_s5 l1_s13)))- (let ((l1_s17 (seq.extract l1_s1 l1_s13 l1_s16)))- (let ((l1_s18 (|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| l1_s15 l1_s17)))- (let ((l1_s19 (seq.++ l1_s12 l1_s18)))- (let ((l1_s20 (ite l1_s7 l1_s8 l1_s19)))+ (let ((l1_s6 (seq.len l1_s1)))+ (let ((l1_s7 (= l1_s3 l1_s6)))+ (let ((l1_s8 (seq.nth l1_s0 l1_s3)))+ (let ((l1_s9 (seq.nth l1_s1 l1_s3)))+ (let ((l1_s10 ((as mkSBVTuple2 (SBVTuple2 Int Int)) l1_s8 l1_s9)))+ (let ((l1_s11 (seq.unit l1_s10)))+ (let ((l1_s13 (- l1_s2 l1_s12)))+ (let ((l1_s14 (seq.extract l1_s0 l1_s12 l1_s13)))+ (let ((l1_s15 (- l1_s6 l1_s12)))+ (let ((l1_s16 (seq.extract l1_s1 l1_s12 l1_s15)))+ (let ((l1_s17 (|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| l1_s14 l1_s16)))+ (let ((l1_s18 (seq.++ l1_s11 l1_s17)))+ (let ((l1_s19 (ite l1_s7 l1_s5 l1_s18)))+ (let ((l1_s20 (ite l1_s4 l1_s5 l1_s19))) l1_s20)))))))))))))))))))) [GOOD] ; |sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)| :: (SInteger, [(SInteger, SInteger)]) -> SInteger [Recursive] [GOOD] (define-fun-rec |sbv.foldl @(SBV (Integer,(Integer,Integer)) -> SBV Integer)_f29a298542 @(SBV (Integer,[(Integer,Integer)]) -> SBV Integer)| ((l1_s0 (SBVTuple2 Int (Seq (SBVTuple2 Int Int))))) Int
SBVTestSuite/GoldFiles/lambda19.gold view
@@ -1,3 +1,219 @@+[MEASURE] Verifying termination measures for: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): barified = "|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|"+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Int (proj_1_SBVTuple2 s10))+[GOOD] (define-fun s16 () Int (abs s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s14 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s16))+[RECV] ((s16 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit 2))))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[2]) :: (Integer, [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () (Seq Int) (proj_2_SBVTuple2 s10))+[GOOD] (define-fun s15 () Int (seq.len s14))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda20.gold view
@@ -1,3 +1,219 @@+[MEASURE] Verifying termination measures for: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): barified = "|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)|"+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (* s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (* s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Int (proj_1_SBVTuple2 s10))+[GOOD] (define-fun s16 () Int (abs s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s14 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s16))+[RECV] ((s16 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit 2))))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[2]) :: (Integer, [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (* s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (* s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () (Seq Int) (proj_2_SBVTuple2 s10))+[GOOD] (define-fun s15 () Int (seq.len s14))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_dd270bb7de @(SBV (Integer,[Integer]) -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda21.gold view
@@ -1,3 +1,223 @@+[MEASURE] Verifying termination measures for: sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] Checking: sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): barified = "|sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])|"+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying length arg1._1+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s10 () (Seq Int)) ; tracks user variable "__internal_sbv_s10"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (- s4 s2))+[GOOD] (define-fun s8 () (Seq Int) (seq.extract s3 s2 s7))+[GOOD] (define-fun s9 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s6 s8))+[GOOD] (define-fun s11 () Int (seq.nth s3 s1))+[GOOD] (define-fun s12 () (Seq Int) (seq.unit s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s10 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () Int (seq.len s6))+[GOOD] (define-fun s16 () Bool (>= s15 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s10 () (Seq Int)) ; tracks user variable "__internal_sbv_s10"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (- s4 s2))+[GOOD] (define-fun s8 () (Seq Int) (seq.extract s3 s2 s7))+[GOOD] (define-fun s9 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s6 s8))+[GOOD] (define-fun s11 () Int (seq.nth s3 s1))+[GOOD] (define-fun s12 () (Seq Int) (seq.unit s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s10 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () Int (seq.len s6))+[GOOD] (define-fun s16 () (Seq Int) (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s17 () Int (seq.len s16))+[GOOD] (define-fun s18 () Bool (not s5))+[GOOD] (define-fun s19 () Bool (> s15 s17))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s20))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s15))+[RECV] ((s15 0))+[SEND] (get-value (s17))+[RECV] ((s17 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 (as seq.empty (Seq Int)) (seq.unit 2))))+[SEND] (get-value (s10))+[RECV] ((s10 (as seq.empty (Seq Int))))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): length arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = ([],[2]) :: ([Integer], [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying next candidate..+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s10 () (Seq Int)) ; tracks user variable "__internal_sbv_s10"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (- s4 s2))+[GOOD] (define-fun s8 () (Seq Int) (seq.extract s3 s2 s7))+[GOOD] (define-fun s9 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s6 s8))+[GOOD] (define-fun s11 () Int (seq.nth s3 s1))+[GOOD] (define-fun s12 () (Seq Int) (seq.unit s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s10 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s10 () (Seq Int)) ; tracks user variable "__internal_sbv_s10"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (- s4 s2))+[GOOD] (define-fun s8 () (Seq Int) (seq.extract s3 s2 s7))+[GOOD] (define-fun s9 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s6 s8))+[GOOD] (define-fun s11 () Int (seq.nth s3 s1))+[GOOD] (define-fun s12 () (Seq Int) (seq.unit s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s10 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s5 s6 s13))+[GOOD] (define-fun s15 () (Seq Int) (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s16 () Int (seq.len s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s4 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,[Integer]) -> SBV [Integer])_5c3e05abf3 @(SBV ([Integer],[Integer]) -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda22.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])+[MEASURE] Checking: sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): barified = "|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])|"+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): Uninterpreted ops in DAG: [("|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])|",2)]+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): recursive calls found = 1+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): trying length arg1+[MEASURE] replayDAG {sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])}: replaying 16 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -15,6 +22,118 @@ (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (SBVTuple2 Int Int)) (as seq.empty (Seq (SBVTuple2 Int Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq Int)) ; tracks user variable "arg1"+[GOOD] (declare-fun s17 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "__internal_sbv_s17"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () Int (seq.len s1))+[GOOD] (define-fun s8 () Bool (= s2 s7))+[GOOD] (define-fun s9 () Int (seq.nth s0 s2))+[GOOD] (define-fun s10 () Int (seq.nth s1 s2))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.unit s11))+[GOOD] (define-fun s13 () Int (- s5 s3))+[GOOD] (define-fun s14 () (Seq Int) (seq.extract s0 s3 s13))+[GOOD] (define-fun s15 () Int (- s7 s3))+[GOOD] (define-fun s16 () (Seq Int) (seq.extract s1 s3 s15))+[GOOD] (define-fun s18 () (Seq (SBVTuple2 Int Int)) (seq.++ s12 s17))+[GOOD] (define-fun s19 () (Seq (SBVTuple2 Int Int)) (ite s8 s4 s18))+[GOOD] (define-fun s20 () (Seq (SBVTuple2 Int Int)) (ite s6 s4 s19))+[GOOD] (define-fun s21 () Bool (>= s5 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])}: replaying 16 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (SBVTuple2 Int Int)) (as seq.empty (Seq (SBVTuple2 Int Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq Int)) ; tracks user variable "arg1"+[GOOD] (declare-fun s17 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "__internal_sbv_s17"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () Int (seq.len s1))+[GOOD] (define-fun s8 () Bool (= s2 s7))+[GOOD] (define-fun s9 () Int (seq.nth s0 s2))+[GOOD] (define-fun s10 () Int (seq.nth s1 s2))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.unit s11))+[GOOD] (define-fun s13 () Int (- s5 s3))+[GOOD] (define-fun s14 () (Seq Int) (seq.extract s0 s3 s13))+[GOOD] (define-fun s15 () Int (- s7 s3))+[GOOD] (define-fun s16 () (Seq Int) (seq.extract s1 s3 s15))+[GOOD] (define-fun s18 () (Seq (SBVTuple2 Int Int)) (seq.++ s12 s17))+[GOOD] (define-fun s19 () (Seq (SBVTuple2 Int Int)) (ite s8 s4 s18))+[GOOD] (define-fun s20 () (Seq (SBVTuple2 Int Int)) (ite s6 s4 s19))+[GOOD] (define-fun s21 () Int (seq.len s14))+[GOOD] (define-fun s22 () Bool (not s8))+[GOOD] (define-fun s23 () Bool (not s6))+[GOOD] (define-fun s24 () Bool (and s22 s23))+[GOOD] (define-fun s25 () Bool (> s5 s21))+[GOOD] (define-fun s26 () Bool (=> s24 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants --- [GOOD] (define-fun s3 () (Seq Int) (seq.++ (seq.unit 1) (seq.unit 2) (seq.unit 3) (seq.unit 4) (seq.unit 5) (seq.unit 6) (seq.unit 7) (seq.unit 8) (seq.unit 9) (seq.unit 10))) [GOOD] (define-fun s5 () (Seq Int) (seq.++ (seq.unit 11) (seq.unit 12) (seq.unit 13) (seq.unit 14) (seq.unit 15) (seq.unit 16) (seq.unit 17) (seq.unit 18) (seq.unit 19) (seq.unit 20))) [GOOD] ; --- top level inputs ---@@ -28,24 +147,24 @@ [GOOD] ; |sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| :: [SInteger] -> [SInteger] -> [(SInteger, SInteger)] [Recursive] [GOOD] (define-fun-rec |sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| ((l1_s0 (Seq Int)) (l1_s1 (Seq Int))) (Seq (SBVTuple2 Int Int)) (let ((l1_s3 0))- (let ((l1_s8 (as seq.empty (Seq (SBVTuple2 Int Int)))))- (let ((l1_s13 1))+ (let ((l1_s5 (as seq.empty (Seq (SBVTuple2 Int Int)))))+ (let ((l1_s12 1)) (let ((l1_s2 (seq.len l1_s0))) (let ((l1_s4 (= l1_s2 l1_s3)))- (let ((l1_s5 (seq.len l1_s1)))- (let ((l1_s6 (= l1_s3 l1_s5)))- (let ((l1_s7 (or l1_s4 l1_s6)))- (let ((l1_s9 (seq.nth l1_s0 l1_s3)))- (let ((l1_s10 (seq.nth l1_s1 l1_s3)))- (let ((l1_s11 ((as mkSBVTuple2 (SBVTuple2 Int Int)) l1_s9 l1_s10)))- (let ((l1_s12 (seq.unit l1_s11)))- (let ((l1_s14 (- l1_s2 l1_s13)))- (let ((l1_s15 (seq.extract l1_s0 l1_s13 l1_s14)))- (let ((l1_s16 (- l1_s5 l1_s13)))- (let ((l1_s17 (seq.extract l1_s1 l1_s13 l1_s16)))- (let ((l1_s18 (|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| l1_s15 l1_s17)))- (let ((l1_s19 (seq.++ l1_s12 l1_s18)))- (let ((l1_s20 (ite l1_s7 l1_s8 l1_s19)))+ (let ((l1_s6 (seq.len l1_s1)))+ (let ((l1_s7 (= l1_s3 l1_s6)))+ (let ((l1_s8 (seq.nth l1_s0 l1_s3)))+ (let ((l1_s9 (seq.nth l1_s1 l1_s3)))+ (let ((l1_s10 ((as mkSBVTuple2 (SBVTuple2 Int Int)) l1_s8 l1_s9)))+ (let ((l1_s11 (seq.unit l1_s10)))+ (let ((l1_s13 (- l1_s2 l1_s12)))+ (let ((l1_s14 (seq.extract l1_s0 l1_s12 l1_s13)))+ (let ((l1_s15 (- l1_s6 l1_s12)))+ (let ((l1_s16 (seq.extract l1_s1 l1_s12 l1_s15)))+ (let ((l1_s17 (|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| l1_s14 l1_s16)))+ (let ((l1_s18 (seq.++ l1_s11 l1_s17)))+ (let ((l1_s19 (ite l1_s7 l1_s5 l1_s18)))+ (let ((l1_s20 (ite l1_s4 l1_s5 l1_s19))) l1_s20)))))))))))))))))))) [GOOD] ; --- assignments --- [GOOD] (define-fun s4 () Bool (= s0 s3))
SBVTestSuite/GoldFiles/lambda23.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]), sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]), sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): barified = "|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])|"+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): Uninterpreted ops in DAG: [("|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])|",2)]+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): recursive calls found = 1+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): trying length arg1+[MEASURE] replayDAG {sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])}: replaying 16 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -15,6 +22,439 @@ (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (SBVTuple2 Int Int)) (as seq.empty (Seq (SBVTuple2 Int Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq Int)) ; tracks user variable "arg1"+[GOOD] (declare-fun s17 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "__internal_sbv_s17"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () Int (seq.len s1))+[GOOD] (define-fun s8 () Bool (= s2 s7))+[GOOD] (define-fun s9 () Int (seq.nth s0 s2))+[GOOD] (define-fun s10 () Int (seq.nth s1 s2))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.unit s11))+[GOOD] (define-fun s13 () Int (- s5 s3))+[GOOD] (define-fun s14 () (Seq Int) (seq.extract s0 s3 s13))+[GOOD] (define-fun s15 () Int (- s7 s3))+[GOOD] (define-fun s16 () (Seq Int) (seq.extract s1 s3 s15))+[GOOD] (define-fun s18 () (Seq (SBVTuple2 Int Int)) (seq.++ s12 s17))+[GOOD] (define-fun s19 () (Seq (SBVTuple2 Int Int)) (ite s8 s4 s18))+[GOOD] (define-fun s20 () (Seq (SBVTuple2 Int Int)) (ite s6 s4 s19))+[GOOD] (define-fun s21 () Bool (>= s5 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])}: replaying 16 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] (define-fun s4 () (Seq (SBVTuple2 Int Int)) (as seq.empty (Seq (SBVTuple2 Int Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq Int)) ; tracks user variable "arg1"+[GOOD] (declare-fun s17 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "__internal_sbv_s17"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s2 s5))+[GOOD] (define-fun s7 () Int (seq.len s1))+[GOOD] (define-fun s8 () Bool (= s2 s7))+[GOOD] (define-fun s9 () Int (seq.nth s0 s2))+[GOOD] (define-fun s10 () Int (seq.nth s1 s2))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.unit s11))+[GOOD] (define-fun s13 () Int (- s5 s3))+[GOOD] (define-fun s14 () (Seq Int) (seq.extract s0 s3 s13))+[GOOD] (define-fun s15 () Int (- s7 s3))+[GOOD] (define-fun s16 () (Seq Int) (seq.extract s1 s3 s15))+[GOOD] (define-fun s18 () (Seq (SBVTuple2 Int Int)) (seq.++ s12 s17))+[GOOD] (define-fun s19 () (Seq (SBVTuple2 Int Int)) (ite s8 s4 s18))+[GOOD] (define-fun s20 () (Seq (SBVTuple2 Int Int)) (ite s6 s4 s19))+[GOOD] (define-fun s21 () Int (seq.len s14))+[GOOD] (define-fun s22 () Bool (not s8))+[GOOD] (define-fun s23 () Bool (not s6))+[GOOD] (define-fun s24 () Bool (and s22 s23))+[GOOD] (define-fun s25 () Bool (> s5 s21))+[GOOD] (define-fun s26 () Bool (=> s24 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])+[MEASURE] Checking: sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): barified = "|sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])|"+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])|",1)]+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (SBVTuple2 Int Int) (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s6))+[GOOD] (define-fun s8 () Int (proj_2_SBVTuple2 s6))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s5 s3 s14))+[GOOD] (define-fun s16 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (SBVTuple2 Int Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () (SBVTuple2 Int Int) (seq.nth s0 s1))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s6))+[GOOD] (define-fun s8 () Int (proj_2_SBVTuple2 s6))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq (SBVTuple2 Int Int)) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s5 s3 s14))+[GOOD] (define-fun s16 () Int (seq.len s12))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s4 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): barified = "|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|"+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Int (proj_1_SBVTuple2 s10))+[GOOD] (define-fun s16 () Int (abs s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s14 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s16))+[RECV] ((s16 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit 2))))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[2]) :: (Integer, [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () (Seq Int) (proj_2_SBVTuple2 s10))+[GOOD] (define-fun s15 () Int (seq.len s14))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants --- [GOOD] (define-fun s3 () (Seq Int) (seq.++ (seq.unit 1) (seq.unit 2) (seq.unit 3) (seq.unit 4) (seq.unit 5) (seq.unit 6) (seq.unit 7) (seq.unit 8) (seq.unit 9) (seq.unit 10))) [GOOD] (define-fun s5 () (Seq Int) (seq.++ (seq.unit 10) (seq.unit 9) (seq.unit 8) (seq.unit 7) (seq.unit 6) (seq.unit 5) (seq.unit 4) (seq.unit 3) (seq.unit 2) (seq.unit 1))) [GOOD] (define-fun s7 () Int 0)@@ -29,24 +469,24 @@ [GOOD] ; |sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| :: [SInteger] -> [SInteger] -> [(SInteger, SInteger)] [Recursive] [GOOD] (define-fun-rec |sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| ((l1_s0 (Seq Int)) (l1_s1 (Seq Int))) (Seq (SBVTuple2 Int Int)) (let ((l1_s3 0))- (let ((l1_s8 (as seq.empty (Seq (SBVTuple2 Int Int)))))- (let ((l1_s13 1))+ (let ((l1_s5 (as seq.empty (Seq (SBVTuple2 Int Int)))))+ (let ((l1_s12 1)) (let ((l1_s2 (seq.len l1_s0))) (let ((l1_s4 (= l1_s2 l1_s3)))- (let ((l1_s5 (seq.len l1_s1)))- (let ((l1_s6 (= l1_s3 l1_s5)))- (let ((l1_s7 (or l1_s4 l1_s6)))- (let ((l1_s9 (seq.nth l1_s0 l1_s3)))- (let ((l1_s10 (seq.nth l1_s1 l1_s3)))- (let ((l1_s11 ((as mkSBVTuple2 (SBVTuple2 Int Int)) l1_s9 l1_s10)))- (let ((l1_s12 (seq.unit l1_s11)))- (let ((l1_s14 (- l1_s2 l1_s13)))- (let ((l1_s15 (seq.extract l1_s0 l1_s13 l1_s14)))- (let ((l1_s16 (- l1_s5 l1_s13)))- (let ((l1_s17 (seq.extract l1_s1 l1_s13 l1_s16)))- (let ((l1_s18 (|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| l1_s15 l1_s17)))- (let ((l1_s19 (seq.++ l1_s12 l1_s18)))- (let ((l1_s20 (ite l1_s7 l1_s8 l1_s19)))+ (let ((l1_s6 (seq.len l1_s1)))+ (let ((l1_s7 (= l1_s3 l1_s6)))+ (let ((l1_s8 (seq.nth l1_s0 l1_s3)))+ (let ((l1_s9 (seq.nth l1_s1 l1_s3)))+ (let ((l1_s10 ((as mkSBVTuple2 (SBVTuple2 Int Int)) l1_s8 l1_s9)))+ (let ((l1_s11 (seq.unit l1_s10)))+ (let ((l1_s13 (- l1_s2 l1_s12)))+ (let ((l1_s14 (seq.extract l1_s0 l1_s12 l1_s13)))+ (let ((l1_s15 (- l1_s6 l1_s12)))+ (let ((l1_s16 (seq.extract l1_s1 l1_s12 l1_s15)))+ (let ((l1_s17 (|sbv.zip @(SBV [Integer] -> SBV [Integer] -> SBV [(Integer,Integer)])| l1_s14 l1_s16)))+ (let ((l1_s18 (seq.++ l1_s11 l1_s17)))+ (let ((l1_s19 (ite l1_s7 l1_s5 l1_s18)))+ (let ((l1_s20 (ite l1_s4 l1_s5 l1_s19))) l1_s20)))))))))))))))))))) [GOOD] ; |sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])| :: [(SInteger, SInteger)] -> [SInteger] [Recursive] [GOOD] (define-fun-rec |sbv.map @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV [(Integer,Integer)] -> SBV [Integer])| ((l1_s0 (Seq (SBVTuple2 Int Int)))) (Seq Int)
SBVTestSuite/GoldFiles/lambda24.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] Checking: sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): barified = "|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])|"+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])|",1)]+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying length arg1._1+[MEASURE] replayDAG {sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 19 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -15,6 +22,123 @@ (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s19 () (Seq Int)) ; tracks user variable "__internal_sbv_s19"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.len s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s4 s1))+[GOOD] (define-fun s11 () Int (seq.nth s7 s1))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.unit s12))+[GOOD] (define-fun s14 () Int (- s5 s2))+[GOOD] (define-fun s15 () (Seq Int) (seq.extract s4 s2 s14))+[GOOD] (define-fun s16 () Int (- s8 s2))+[GOOD] (define-fun s17 () (Seq Int) (seq.extract s7 s2 s16))+[GOOD] (define-fun s18 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s17))+[GOOD] (define-fun s20 () (Seq Int) (seq.++ s13 s19))+[GOOD] (define-fun s21 () (Seq Int) (ite s9 s3 s20))+[GOOD] (define-fun s22 () (Seq Int) (ite s6 s3 s21))+[GOOD] (define-fun s23 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 19 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s19 () (Seq Int)) ; tracks user variable "__internal_sbv_s19"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.len s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s4 s1))+[GOOD] (define-fun s11 () Int (seq.nth s7 s1))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.unit s12))+[GOOD] (define-fun s14 () Int (- s5 s2))+[GOOD] (define-fun s15 () (Seq Int) (seq.extract s4 s2 s14))+[GOOD] (define-fun s16 () Int (- s8 s2))+[GOOD] (define-fun s17 () (Seq Int) (seq.extract s7 s2 s16))+[GOOD] (define-fun s18 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s17))+[GOOD] (define-fun s20 () (Seq Int) (seq.++ s13 s19))+[GOOD] (define-fun s21 () (Seq Int) (ite s9 s3 s20))+[GOOD] (define-fun s22 () (Seq Int) (ite s6 s3 s21))+[GOOD] (define-fun s23 () (Seq Int) (proj_1_SBVTuple2 s18))+[GOOD] (define-fun s24 () Int (seq.len s23))+[GOOD] (define-fun s25 () Bool (not s9))+[GOOD] (define-fun s26 () Bool (not s6))+[GOOD] (define-fun s27 () Bool (and s25 s26))+[GOOD] (define-fun s28 () Bool (> s5 s24))+[GOOD] (define-fun s29 () Bool (=> s27 s28))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s29))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): length arg1._1 -> OK+[MEASURE] Passed (terminating): sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants --- [GOOD] (define-fun s3 () (Seq Int) (seq.++ (seq.unit 1) (seq.unit 2) (seq.unit 3) (seq.unit 4) (seq.unit 5) (seq.unit 6) (seq.unit 7) (seq.unit 8) (seq.unit 9) (seq.unit 10))) [GOOD] (define-fun s5 () (Seq Int) (seq.++ (seq.unit 11) (seq.unit 12) (seq.unit 13) (seq.unit 14) (seq.unit 15) (seq.unit 16) (seq.unit 17) (seq.unit 18) (seq.unit 19) (seq.unit 20))) [GOOD] ; --- top level inputs ---@@ -28,27 +152,27 @@ [GOOD] ; |sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| :: ([SInteger], [SInteger]) -> [SInteger] [Recursive] [GOOD] (define-fun-rec |sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| ((l1_s0 (SBVTuple2 (Seq Int) (Seq Int)))) (Seq Int) (let ((l1_s3 0))- (let ((l1_s9 (as seq.empty (Seq Int))))- (let ((l1_s14 1))+ (let ((l1_s5 (as seq.empty (Seq Int))))+ (let ((l1_s13 1)) (let ((l1_s1 (proj_1_SBVTuple2 l1_s0))) (let ((l1_s2 (seq.len l1_s1))) (let ((l1_s4 (= l1_s2 l1_s3)))- (let ((l1_s5 (proj_2_SBVTuple2 l1_s0)))- (let ((l1_s6 (seq.len l1_s5)))- (let ((l1_s7 (= l1_s3 l1_s6)))- (let ((l1_s8 (or l1_s4 l1_s7)))- (let ((l1_s10 (seq.nth l1_s1 l1_s3)))- (let ((l1_s11 (seq.nth l1_s5 l1_s3)))- (let ((l1_s12 (+ l1_s10 l1_s11)))- (let ((l1_s13 (seq.unit l1_s12)))- (let ((l1_s15 (- l1_s2 l1_s14)))- (let ((l1_s16 (seq.extract l1_s1 l1_s14 l1_s15)))- (let ((l1_s17 (- l1_s6 l1_s14)))- (let ((l1_s18 (seq.extract l1_s5 l1_s14 l1_s17)))- (let ((l1_s19 ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) l1_s16 l1_s18)))- (let ((l1_s20 (|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| l1_s19)))- (let ((l1_s21 (seq.++ l1_s13 l1_s20)))- (let ((l1_s22 (ite l1_s8 l1_s9 l1_s21)))+ (let ((l1_s6 (proj_2_SBVTuple2 l1_s0)))+ (let ((l1_s7 (seq.len l1_s6)))+ (let ((l1_s8 (= l1_s3 l1_s7)))+ (let ((l1_s9 (seq.nth l1_s1 l1_s3)))+ (let ((l1_s10 (seq.nth l1_s6 l1_s3)))+ (let ((l1_s11 (+ l1_s9 l1_s10)))+ (let ((l1_s12 (seq.unit l1_s11)))+ (let ((l1_s14 (- l1_s2 l1_s13)))+ (let ((l1_s15 (seq.extract l1_s1 l1_s13 l1_s14)))+ (let ((l1_s16 (- l1_s7 l1_s13)))+ (let ((l1_s17 (seq.extract l1_s6 l1_s13 l1_s16)))+ (let ((l1_s18 ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) l1_s15 l1_s17)))+ (let ((l1_s19 (|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| l1_s18)))+ (let ((l1_s20 (seq.++ l1_s12 l1_s19)))+ (let ((l1_s21 (ite l1_s8 l1_s5 l1_s20)))+ (let ((l1_s22 (ite l1_s4 l1_s5 l1_s21))) l1_s22))))))))))))))))))))))) [GOOD] ; --- assignments --- [GOOD] (define-fun s4 () Bool (= s0 s3))
SBVTestSuite/GoldFiles/lambda25.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]), sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] Checking: sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): barified = "|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])|"+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])|",1)]+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): trying length arg1._1+[MEASURE] replayDAG {sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 19 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -15,6 +22,338 @@ (proj_2_SBVTuple2 T2)))))) [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s19 () (Seq Int)) ; tracks user variable "__internal_sbv_s19"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.len s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s4 s1))+[GOOD] (define-fun s11 () Int (seq.nth s7 s1))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.unit s12))+[GOOD] (define-fun s14 () Int (- s5 s2))+[GOOD] (define-fun s15 () (Seq Int) (seq.extract s4 s2 s14))+[GOOD] (define-fun s16 () Int (- s8 s2))+[GOOD] (define-fun s17 () (Seq Int) (seq.extract s7 s2 s16))+[GOOD] (define-fun s18 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s17))+[GOOD] (define-fun s20 () (Seq Int) (seq.++ s13 s19))+[GOOD] (define-fun s21 () (Seq Int) (ite s9 s3 s20))+[GOOD] (define-fun s22 () (Seq Int) (ite s6 s3 s21))+[GOOD] (define-fun s23 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])}: replaying 19 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s19 () (Seq Int)) ; tracks user variable "__internal_sbv_s19"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.len s7))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s4 s1))+[GOOD] (define-fun s11 () Int (seq.nth s7 s1))+[GOOD] (define-fun s12 () Int (+ s10 s11))+[GOOD] (define-fun s13 () (Seq Int) (seq.unit s12))+[GOOD] (define-fun s14 () Int (- s5 s2))+[GOOD] (define-fun s15 () (Seq Int) (seq.extract s4 s2 s14))+[GOOD] (define-fun s16 () Int (- s8 s2))+[GOOD] (define-fun s17 () (Seq Int) (seq.extract s7 s2 s16))+[GOOD] (define-fun s18 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s17))+[GOOD] (define-fun s20 () (Seq Int) (seq.++ s13 s19))+[GOOD] (define-fun s21 () (Seq Int) (ite s9 s3 s20))+[GOOD] (define-fun s22 () (Seq Int) (ite s6 s3 s21))+[GOOD] (define-fun s23 () (Seq Int) (proj_1_SBVTuple2 s18))+[GOOD] (define-fun s24 () Int (seq.len s23))+[GOOD] (define-fun s25 () Bool (not s9))+[GOOD] (define-fun s26 () Bool (not s6))+[GOOD] (define-fun s27 () Bool (and s25 s26))+[GOOD] (define-fun s28 () Bool (> s5 s24))+[GOOD] (define-fun s29 () Bool (=> s27 s28))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s29))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer]): length arg1._1 -> OK+[MEASURE] Passed (terminating): sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): barified = "|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|"+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying abs arg1._1+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Int (abs s6))+[GOOD] (define-fun s15 () Int (proj_1_SBVTuple2 s10))+[GOOD] (define-fun s16 () Int (abs s15))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s14 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s16))+[RECV] ((s16 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit 2))))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[2]) :: (Integer, [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying next candidate..+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s7 () Int (seq.nth s3 s1))+[GOOD] (define-fun s8 () Int (- s4 s2))+[GOOD] (define-fun s9 () (Seq Int) (seq.extract s3 s2 s8))+[GOOD] (define-fun s10 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s9))+[GOOD] (define-fun s12 () Int (+ s7 s11))+[GOOD] (define-fun s13 () Int (ite s5 s6 s12))+[GOOD] (define-fun s14 () (Seq Int) (proj_2_SBVTuple2 s10))+[GOOD] (define-fun s15 () Int (seq.len s14))+[GOOD] (define-fun s16 () Bool (not s5))+[GOOD] (define-fun s17 () Bool (> s4 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants --- [GOOD] (define-fun s3 () (Seq Int) (seq.++ (seq.unit 1) (seq.unit 2) (seq.unit 3) (seq.unit 4) (seq.unit 5) (seq.unit 6) (seq.unit 7) (seq.unit 8) (seq.unit 9) (seq.unit 10))) [GOOD] (define-fun s5 () (Seq Int) (seq.++ (seq.unit 10) (seq.unit 9) (seq.unit 8) (seq.unit 7) (seq.unit 6) (seq.unit 5) (seq.unit 4) (seq.unit 3) (seq.unit 2) (seq.unit 1))) [GOOD] (define-fun s7 () Int 0)@@ -29,27 +368,27 @@ [GOOD] ; |sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| :: ([SInteger], [SInteger]) -> [SInteger] [Recursive] [GOOD] (define-fun-rec |sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| ((l1_s0 (SBVTuple2 (Seq Int) (Seq Int)))) (Seq Int) (let ((l1_s3 0))- (let ((l1_s9 (as seq.empty (Seq Int))))- (let ((l1_s14 1))+ (let ((l1_s5 (as seq.empty (Seq Int))))+ (let ((l1_s13 1)) (let ((l1_s1 (proj_1_SBVTuple2 l1_s0))) (let ((l1_s2 (seq.len l1_s1))) (let ((l1_s4 (= l1_s2 l1_s3)))- (let ((l1_s5 (proj_2_SBVTuple2 l1_s0)))- (let ((l1_s6 (seq.len l1_s5)))- (let ((l1_s7 (= l1_s3 l1_s6)))- (let ((l1_s8 (or l1_s4 l1_s7)))- (let ((l1_s10 (seq.nth l1_s1 l1_s3)))- (let ((l1_s11 (seq.nth l1_s5 l1_s3)))- (let ((l1_s12 (+ l1_s10 l1_s11)))- (let ((l1_s13 (seq.unit l1_s12)))- (let ((l1_s15 (- l1_s2 l1_s14)))- (let ((l1_s16 (seq.extract l1_s1 l1_s14 l1_s15)))- (let ((l1_s17 (- l1_s6 l1_s14)))- (let ((l1_s18 (seq.extract l1_s5 l1_s14 l1_s17)))- (let ((l1_s19 ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) l1_s16 l1_s18)))- (let ((l1_s20 (|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| l1_s19)))- (let ((l1_s21 (seq.++ l1_s13 l1_s20)))- (let ((l1_s22 (ite l1_s8 l1_s9 l1_s21)))+ (let ((l1_s6 (proj_2_SBVTuple2 l1_s0)))+ (let ((l1_s7 (seq.len l1_s6)))+ (let ((l1_s8 (= l1_s3 l1_s7)))+ (let ((l1_s9 (seq.nth l1_s1 l1_s3)))+ (let ((l1_s10 (seq.nth l1_s6 l1_s3)))+ (let ((l1_s11 (+ l1_s9 l1_s10)))+ (let ((l1_s12 (seq.unit l1_s11)))+ (let ((l1_s14 (- l1_s2 l1_s13)))+ (let ((l1_s15 (seq.extract l1_s1 l1_s13 l1_s14)))+ (let ((l1_s16 (- l1_s7 l1_s13)))+ (let ((l1_s17 (seq.extract l1_s6 l1_s13 l1_s16)))+ (let ((l1_s18 ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) l1_s15 l1_s17)))+ (let ((l1_s19 (|sbv.zipWith @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV ([Integer],[Integer]) -> SBV [Integer])| l1_s18)))+ (let ((l1_s20 (seq.++ l1_s12 l1_s19)))+ (let ((l1_s21 (ite l1_s8 l1_s5 l1_s20)))+ (let ((l1_s22 (ite l1_s4 l1_s5 l1_s21))) l1_s22))))))))))))))))))))))) [GOOD] ; |sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)| :: (SInteger, [SInteger]) -> SInteger [Recursive] [GOOD] (define-fun-rec |sbv.foldr @(SBV (Integer,Integer) -> SBV Integer)_1fd06f7602 @(SBV (Integer,[Integer]) -> SBV Integer)| ((l1_s0 (SBVTuple2 Int (Seq Int)))) Int
SBVTestSuite/GoldFiles/lambda27.gold view
@@ -1,3 +1,114 @@+[MEASURE] Verifying termination measures for: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): barified = "|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)|"+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (= s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (and s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (= s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (and s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s18 () Int (seq.len s17))+[GOOD] (define-fun s19 () Bool (not s6))+[GOOD] (define-fun s20 () Bool (and s10 s19))+[GOOD] (define-fun s21 () Bool (> s5 s18))+[GOOD] (define-fun s22 () Bool (=> s20 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda28.gold view
@@ -1,3 +1,114 @@+[MEASURE] Verifying termination measures for: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): barified = "|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)|"+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (= s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (and s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (= s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (and s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s18 () Int (seq.len s17))+[GOOD] (define-fun s19 () Bool (not s6))+[GOOD] (define-fun s20 () Bool (and s10 s19))+[GOOD] (define-fun s21 () Bool (> s5 s18))+[GOOD] (define-fun s22 () Bool (=> s20 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_574b56f8c4 @(SBV (Bool,[Integer]) -> SBV Bool) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda29.gold view
@@ -1,3 +1,115 @@+[MEASURE] Verifying termination measures for: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool): barified = "|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool)|"+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (distinct s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (or s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (distinct s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (or s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s18 () Int (seq.len s17))+[GOOD] (define-fun s19 () Bool (not s10))+[GOOD] (define-fun s20 () Bool (not s6))+[GOOD] (define-fun s21 () Bool (and s19 s20))+[GOOD] (define-fun s22 () Bool (> s5 s18))+[GOOD] (define-fun s23 () Bool (=> s21 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_01257e6724 @(SBV (Bool,[Integer]) -> SBV Bool) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda30.gold view
@@ -1,3 +1,115 @@+[MEASURE] Verifying termination measures for: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] Checking: sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool)+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool): barified = "|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool)|"+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool): Uninterpreted ops in DAG: [("|sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool)|",1)]+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool): recursive calls found = 1+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool): trying length arg1._2+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (= s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (or s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool)}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Bool (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () Bool) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (mod s8 s3))+[GOOD] (define-fun s10 () Bool (= s1 s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Bool (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () Bool (or s10 s14))+[GOOD] (define-fun s16 () Bool (ite s6 s7 s15))+[GOOD] (define-fun s17 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s18 () Int (seq.len s17))+[GOOD] (define-fun s19 () Bool (not s10))+[GOOD] (define-fun s20 () Bool (not s6))+[GOOD] (define-fun s21 () Bool (and s19 s20))+[GOOD] (define-fun s22 () Bool (> s5 s18))+[GOOD] (define-fun s23 () Bool (=> s21 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.foldr @(SBV (Integer,Bool) -> SBV Bool)_7182762f14 @(SBV (Bool,[Integer]) -> SBV Bool) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda31.gold view
@@ -1,3 +1,108 @@+[MEASURE] Verifying termination measures for: sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s9 s14 s13))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s4 s15))+[GOOD] (define-fun s17 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s9 s14 s13))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s4 s15))+[GOOD] (define-fun s17 () Int (seq.len s12))+[GOOD] (define-fun s18 () Bool (not s9))+[GOOD] (define-fun s19 () Bool (not s6))+[GOOD] (define-fun s20 () Bool (and s18 s19))+[GOOD] (define-fun s21 () Bool (> s5 s17))+[GOOD] (define-fun s22 () Bool (=> s20 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.filter @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda32.gold view
@@ -1,3 +1,108 @@+[MEASURE] Verifying termination measures for: sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (distinct s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s9 s14 s13))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s4 s15))+[GOOD] (define-fun s17 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (distinct s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s9 s14 s13))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s4 s15))+[GOOD] (define-fun s17 () Int (seq.len s12))+[GOOD] (define-fun s18 () Bool (not s9))+[GOOD] (define-fun s19 () Bool (not s6))+[GOOD] (define-fun s20 () Bool (and s18 s19))+[GOOD] (define-fun s21 () Bool (> s5 s17))+[GOOD] (define-fun s22 () Bool (=> s20 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.filter @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda47.gold view
@@ -1,3 +1,84 @@+[MEASURE] Verifying termination measures for: sumToN @(SBV Integer -> SBV Integer)+[MEASURE] Checking: sumToN @(SBV Integer -> SBV Integer)+[MEASURE] sumToN @(SBV Integer -> SBV Integer): barified = "|sumToN @(SBV Integer -> SBV Integer)|"+[MEASURE] sumToN @(SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|sumToN @(SBV Integer -> SBV Integer)|",1)]+[MEASURE] sumToN @(SBV Integer -> SBV Integer): recursive calls found = 1+[MEASURE] sumToN @(SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {sumToN @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sumToN @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sumToN @(SBV Integer -> SBV Integer): abs arg1 -> OK+[MEASURE] Passed (terminating): sumToN @(SBV Integer -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda48.gold view
@@ -1,3 +1,92 @@+[MEASURE] Verifying termination measures for: list_length @(SBV [Integer] -> SBV Integer)+[MEASURE] Checking: list_length @(SBV [Integer] -> SBV Integer)+[MEASURE] list_length @(SBV [Integer] -> SBV Integer): barified = "|list_length @(SBV [Integer] -> SBV Integer)|"+[MEASURE] list_length @(SBV [Integer] -> SBV Integer): Uninterpreted ops in DAG: [("|list_length @(SBV [Integer] -> SBV Integer)|",1)]+[MEASURE] list_length @(SBV [Integer] -> SBV Integer): recursive calls found = 1+[MEASURE] list_length @(SBV [Integer] -> SBV Integer): trying length arg1+[MEASURE] replayDAG {list_length @(SBV [Integer] -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (seq.len s0))+[GOOD] (define-fun s4 () Bool (= s1 s3))+[GOOD] (define-fun s5 () Int (- s3 s2))+[GOOD] (define-fun s6 () (Seq Int) (seq.extract s0 s2 s5))+[GOOD] (define-fun s8 () Int (+ s2 s7))+[GOOD] (define-fun s9 () Int (ite s4 s1 s8))+[GOOD] (define-fun s10 () Bool (>= s3 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {list_length @(SBV [Integer] -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (seq.len s0))+[GOOD] (define-fun s4 () Bool (= s1 s3))+[GOOD] (define-fun s5 () Int (- s3 s2))+[GOOD] (define-fun s6 () (Seq Int) (seq.extract s0 s2 s5))+[GOOD] (define-fun s8 () Int (+ s2 s7))+[GOOD] (define-fun s9 () Int (ite s4 s1 s8))+[GOOD] (define-fun s10 () Int (seq.len s6))+[GOOD] (define-fun s11 () Bool (not s4))+[GOOD] (define-fun s12 () Bool (> s3 s10))+[GOOD] (define-fun s13 () Bool (=> s11 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] list_length @(SBV [Integer] -> SBV Integer): length arg1 -> OK+[MEASURE] Passed (terminating): list_length @(SBV [Integer] -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda49.gold view
@@ -1,3 +1,141 @@+[MEASURE] Verifying termination measures for: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] Checking: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): verifying with 0 helper(s)+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s19 () Bool (>= s18 s1))+[GOOD] (define-fun s20 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s21 () Bool (>= s20 s1))+[GOOD] (define-fun s22 () Bool (and s19 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (abs s5))+[GOOD] (define-fun s19 () Bool (< s5 s1))+[GOOD] (define-fun s20 () Int (ite s19 s2 s1))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s18 s20))+[GOOD] (define-fun s22 () Int (abs s8))+[GOOD] (define-fun s23 () Bool (< s8 s1))+[GOOD] (define-fun s24 () Int (ite s23 s2 s1))+[GOOD] (define-fun s25 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s22 s24))+[GOOD] (define-fun s26 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s27 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s28 () Bool (< s26 s27))+[GOOD] (define-fun s29 () Bool (= s26 s27))+[GOOD] (define-fun s30 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s31 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s32 () Bool (< s30 s31))+[GOOD] (define-fun s33 () Bool (and s29 s32))+[GOOD] (define-fun s34 () Bool (or s28 s33))+[GOOD] (define-fun s35 () Bool (=> s4 s34))+[GOOD] (define-fun s36 () Bool (not s7))+[GOOD] (define-fun s37 () Bool (not s4))+[GOOD] (define-fun s38 () Bool (and s36 s37))+[GOOD] (define-fun s39 () Int (proj_1_SBVTuple2 s25))+[GOOD] (define-fun s40 () Bool (< s39 s27))+[GOOD] (define-fun s41 () Bool (= s27 s39))+[GOOD] (define-fun s42 () Int (proj_2_SBVTuple2 s25))+[GOOD] (define-fun s43 () Bool (< s42 s31))+[GOOD] (define-fun s44 () Bool (and s41 s43))+[GOOD] (define-fun s45 () Bool (or s40 s44))+[GOOD] (define-fun s46 () Bool (=> s38 s45))+[GOOD] (define-fun s47 () Bool (and s35 s46))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s47))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): isEvenOdd @(SBV Integer -> SBV (Bool,Bool)) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda50.gold view
@@ -1,3 +1,141 @@+[MEASURE] Verifying termination measures for: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] Checking: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): verifying with 0 helper(s)+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s19 () Bool (>= s18 s1))+[GOOD] (define-fun s20 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s21 () Bool (>= s20 s1))+[GOOD] (define-fun s22 () Bool (and s19 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (abs s5))+[GOOD] (define-fun s19 () Bool (< s5 s1))+[GOOD] (define-fun s20 () Int (ite s19 s2 s1))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s18 s20))+[GOOD] (define-fun s22 () Int (abs s8))+[GOOD] (define-fun s23 () Bool (< s8 s1))+[GOOD] (define-fun s24 () Int (ite s23 s2 s1))+[GOOD] (define-fun s25 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s22 s24))+[GOOD] (define-fun s26 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s27 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s28 () Bool (< s26 s27))+[GOOD] (define-fun s29 () Bool (= s26 s27))+[GOOD] (define-fun s30 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s31 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s32 () Bool (< s30 s31))+[GOOD] (define-fun s33 () Bool (and s29 s32))+[GOOD] (define-fun s34 () Bool (or s28 s33))+[GOOD] (define-fun s35 () Bool (=> s4 s34))+[GOOD] (define-fun s36 () Bool (not s7))+[GOOD] (define-fun s37 () Bool (not s4))+[GOOD] (define-fun s38 () Bool (and s36 s37))+[GOOD] (define-fun s39 () Int (proj_1_SBVTuple2 s25))+[GOOD] (define-fun s40 () Bool (< s39 s27))+[GOOD] (define-fun s41 () Bool (= s27 s39))+[GOOD] (define-fun s42 () Int (proj_2_SBVTuple2 s25))+[GOOD] (define-fun s43 () Bool (< s42 s31))+[GOOD] (define-fun s44 () Bool (and s41 s43))+[GOOD] (define-fun s45 () Bool (or s40 s44))+[GOOD] (define-fun s46 () Bool (=> s38 s45))+[GOOD] (define-fun s47 () Bool (and s35 s46))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s47))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): isEvenOdd @(SBV Integer -> SBV (Bool,Bool)) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda51.gold view
@@ -1,3 +1,141 @@+[MEASURE] Verifying termination measures for: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] Checking: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): verifying with 0 helper(s)+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s19 () Bool (>= s18 s1))+[GOOD] (define-fun s20 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s21 () Bool (>= s20 s1))+[GOOD] (define-fun s22 () Bool (and s19 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (abs s5))+[GOOD] (define-fun s19 () Bool (< s5 s1))+[GOOD] (define-fun s20 () Int (ite s19 s2 s1))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s18 s20))+[GOOD] (define-fun s22 () Int (abs s8))+[GOOD] (define-fun s23 () Bool (< s8 s1))+[GOOD] (define-fun s24 () Int (ite s23 s2 s1))+[GOOD] (define-fun s25 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s22 s24))+[GOOD] (define-fun s26 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s27 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s28 () Bool (< s26 s27))+[GOOD] (define-fun s29 () Bool (= s26 s27))+[GOOD] (define-fun s30 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s31 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s32 () Bool (< s30 s31))+[GOOD] (define-fun s33 () Bool (and s29 s32))+[GOOD] (define-fun s34 () Bool (or s28 s33))+[GOOD] (define-fun s35 () Bool (=> s4 s34))+[GOOD] (define-fun s36 () Bool (not s7))+[GOOD] (define-fun s37 () Bool (not s4))+[GOOD] (define-fun s38 () Bool (and s36 s37))+[GOOD] (define-fun s39 () Int (proj_1_SBVTuple2 s25))+[GOOD] (define-fun s40 () Bool (< s39 s27))+[GOOD] (define-fun s41 () Bool (= s27 s39))+[GOOD] (define-fun s42 () Int (proj_2_SBVTuple2 s25))+[GOOD] (define-fun s43 () Bool (< s42 s31))+[GOOD] (define-fun s44 () Bool (and s41 s43))+[GOOD] (define-fun s45 () Bool (or s40 s44))+[GOOD] (define-fun s46 () Bool (=> s38 s45))+[GOOD] (define-fun s47 () Bool (and s35 s46))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s47))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): isEvenOdd @(SBV Integer -> SBV (Bool,Bool)) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda52.gold view
@@ -1,3 +1,141 @@+[MEASURE] Verifying termination measures for: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] Checking: isEvenOdd @(SBV Integer -> SBV (Bool,Bool))+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): verifying with 0 helper(s)+[MEASURE] isEvenOdd @(SBV Integer -> SBV (Bool,Bool)): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s19 () Bool (>= s18 s1))+[GOOD] (define-fun s20 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s21 () Bool (>= s20 s1))+[GOOD] (define-fun s22 () Bool (and s19 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {isEvenOdd @(SBV Integer -> SBV (Bool,Bool))}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (SBVTuple2 Bool Bool) (mkSBVTuple2 true false))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s9 () (SBVTuple2 Bool Bool)) ; tracks user variable "__internal_sbv_s9"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (< s0 s1))+[GOOD] (define-fun s5 () Int (- s0))+[GOOD] (define-fun s7 () Bool (= s0 s1))+[GOOD] (define-fun s8 () Int (- s0 s2))+[GOOD] (define-fun s10 () Bool (proj_2_SBVTuple2 s9))+[GOOD] (define-fun s11 () Bool (proj_1_SBVTuple2 s9))+[GOOD] (define-fun s12 () (SBVTuple2 Bool Bool) ((as mkSBVTuple2 (SBVTuple2 Bool Bool)) s10 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Bool Bool) (ite s7 s3 s12))+[GOOD] (define-fun s14 () (SBVTuple2 Bool Bool) (ite s4 s6 s13))+[GOOD] (define-fun s15 () Int (abs s0))+[GOOD] (define-fun s16 () Int (ite s4 s2 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Int (abs s5))+[GOOD] (define-fun s19 () Bool (< s5 s1))+[GOOD] (define-fun s20 () Int (ite s19 s2 s1))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s18 s20))+[GOOD] (define-fun s22 () Int (abs s8))+[GOOD] (define-fun s23 () Bool (< s8 s1))+[GOOD] (define-fun s24 () Int (ite s23 s2 s1))+[GOOD] (define-fun s25 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s22 s24))+[GOOD] (define-fun s26 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s27 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s28 () Bool (< s26 s27))+[GOOD] (define-fun s29 () Bool (= s26 s27))+[GOOD] (define-fun s30 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s31 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s32 () Bool (< s30 s31))+[GOOD] (define-fun s33 () Bool (and s29 s32))+[GOOD] (define-fun s34 () Bool (or s28 s33))+[GOOD] (define-fun s35 () Bool (=> s4 s34))+[GOOD] (define-fun s36 () Bool (not s7))+[GOOD] (define-fun s37 () Bool (not s4))+[GOOD] (define-fun s38 () Bool (and s36 s37))+[GOOD] (define-fun s39 () Int (proj_1_SBVTuple2 s25))+[GOOD] (define-fun s40 () Bool (< s39 s27))+[GOOD] (define-fun s41 () Bool (= s27 s39))+[GOOD] (define-fun s42 () Int (proj_2_SBVTuple2 s25))+[GOOD] (define-fun s43 () Bool (< s42 s31))+[GOOD] (define-fun s44 () Bool (and s41 s43))+[GOOD] (define-fun s45 () Bool (or s40 s44))+[GOOD] (define-fun s46 () Bool (=> s38 s45))+[GOOD] (define-fun s47 () Bool (and s35 s46))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s47))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): isEvenOdd @(SBV Integer -> SBV (Bool,Bool)) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda53.gold view
@@ -24,19 +24,13 @@ [GOOD] ; --- delayedEqualities --- [GOOD] ; --- formula --- [GOOD] (assert s2)-[GOOD] (declare-fun s3 () Int)-[GOOD] (define-fun s4 () Int (|foo @(SBV Integer -> SBV Integer)| s3))-[GOOD] (define-fun s5 () Bool (= s3 s4))-[GOOD] (assert s5) [SEND] (check-sat) [RECV] sat [SEND] (get-value (s0)) [RECV] ((s0 0))-[SEND] (get-value (s3))-[RECV] ((s3 0)) *** Solver : Z3 *** Exit code: ExitSuccess RESULT:+Satisfiable. Model: s0 = 0 :: Integer- s3 = 0 :: Integer
SBVTestSuite/GoldFiles/lambda54.gold view
@@ -1,3 +1,7 @@+[MEASURE] Verifying termination measures for: foo @(SBV Integer -> SBV Integer)+[MEASURE] Checking: foo @(SBV Integer -> SBV Integer)+[MEASURE] foo @(SBV Integer -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): foo @(SBV Integer -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda55.gold view
@@ -1,3 +1,7 @@+[MEASURE] Verifying termination measures for: foo @(SBV Integer -> SBV Integer)+[MEASURE] Checking: foo @(SBV Integer -> SBV Integer)+[MEASURE] foo @(SBV Integer -> SBV Integer): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): foo @(SBV Integer -> SBV Integer) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda56.gold view
@@ -1,3 +1,8 @@+[MEASURE] Verifying termination measures for: foo @(SBV Integer -> SBV Integer), bar @(SBV Integer -> SBV Integer)+[MEASURE] Checking: foo @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {bar :: SBV Integer -> SBV Integer, foo :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -9,44 +14,445 @@ [GOOD] ; --- tuples --- [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s5 () Int 0) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () Int)+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants --- [GOOD] ; --- user defined functions ----[GOOD] ; |bar @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |foo @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger-[GOOD] (define-funs-rec- ((|bar @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int)- (|foo @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int))- (; Definition of: |bar @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |foo @(SBV Integer -> SBV Integer)|]- (let ((l2_s2 1))- (let ((l2_s1 (|foo @(SBV Integer -> SBV Integer)| l2_s0)))- (let ((l2_s3 (+ l2_s1 l2_s2)))- l2_s3)))- ; Definition of: |foo @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |bar @(SBV Integer -> SBV Integer)|]- (let ((l1_s2 1))- (let ((l1_s1 (|bar @(SBV Integer -> SBV Integer)| l1_s0)))- (let ((l1_s3 (+ l1_s1 l1_s2)))- l1_s3))))) [GOOD] ; --- assignments ----[GOOD] (define-fun s1 () Int (|foo @(SBV Integer -> SBV Integer)| s0))-[GOOD] (define-fun s2 () Int (|bar @(SBV Integer -> SBV Integer)| s0)) [GOOD] (define-fun s3 () Int (+ s1 s2))-[GOOD] (define-fun s4 () Bool (= s0 s3))+[GOOD] (define-fun s4 () Int (abs s0))+[GOOD] (define-fun s6 () Bool (>= s4 s5)) [GOOD] ; --- delayedEqualities --- [GOOD] ; --- formula ----[GOOD] (assert s4)-[GOOD] (declare-fun s5 () Int)-[GOOD] (define-fun s6 () Int (|foo @(SBV Integer -> SBV Integer)| s5))-[GOOD] (define-fun s7 () Int (|bar @(SBV Integer -> SBV Integer)| s5))-[GOOD] (define-fun s8 () Int (+ s6 s7))-[GOOD] (define-fun s9 () Bool (= s5 s8))-[GOOD] (assert s9)+[GOOD] (assert (not s6)) [SEND] (check-sat) [RECV] unsat *** Solver : Z3 *** Exit code: ExitSuccess+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s4 () Int (abs s0))+[GOOD] (define-fun s5 () Bool (=> true false))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s5))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s4))+[RECV] ((s4 0))+[SEND] (get-value (s4))+[RECV] ((s4 0))+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s2))+[RECV] ((s2 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bar @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 0 :: Integer+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] Mutual group: measure abs arg1 failed, trying next+[MEASURE] Mutual group: trying measure smax 0 arg1 for all members+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s4 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s5 () Bool (<= s4 s0))+[GOOD] (define-fun s6 () Int (ite s5 s0 s4))+[GOOD] (define-fun s7 () Bool (>= s6 s4))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s7))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s4 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s5 () Bool (<= s4 s0))+[GOOD] (define-fun s6 () Int (ite s5 s0 s4))+[GOOD] (define-fun s7 () Bool (=> true false))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s7))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s6))+[RECV] ((s6 0))+[SEND] (get-value (s6))+[RECV] ((s6 0))+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s2))+[RECV] ((s2 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bar @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 0 :: Integer+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] Mutual group: measure smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure abs arg1 + smax 0 arg1 for all members+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s5 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s4 () Int (abs s0))+[GOOD] (define-fun s6 () Bool (<= s5 s0))+[GOOD] (define-fun s7 () Int (ite s6 s0 s5))+[GOOD] (define-fun s8 () Int (+ s4 s7))+[GOOD] (define-fun s9 () Bool (>= s8 s5))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s5 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s4 () Int (abs s0))+[GOOD] (define-fun s6 () Bool (<= s5 s0))+[GOOD] (define-fun s7 () Int (ite s6 s0 s5))+[GOOD] (define-fun s8 () Int (+ s4 s7))+[GOOD] (define-fun s9 () Bool (=> true false))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s2))+[RECV] ((s2 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bar @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 0 :: Integer+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] Mutual group: measure abs arg1 + smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure (abs arg1, smax 0 arg1) for all members+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s5 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s4 () Int (abs s0))+[GOOD] (define-fun s6 () Bool (<= s5 s0))+[GOOD] (define-fun s7 () Int (ite s6 s0 s5))+[GOOD] (define-fun s8 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s4 s7))+[GOOD] (define-fun s9 () Int (proj_1_SBVTuple2 s8))+[GOOD] (define-fun s10 () Bool (>= s9 s5))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s8))+[GOOD] (define-fun s12 () Bool (>= s11 s5))+[GOOD] (define-fun s13 () Bool (and s10 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s5 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s4 () Int (abs s0))+[GOOD] (define-fun s6 () Bool (<= s5 s0))+[GOOD] (define-fun s7 () Int (ite s6 s0 s5))+[GOOD] (define-fun s8 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s4 s7))+[GOOD] (define-fun s9 () Int (proj_1_SBVTuple2 s8))+[GOOD] (define-fun s10 () Int (proj_2_SBVTuple2 s8))+[GOOD] (define-fun s11 () Bool (=> true false))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s11))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s8))+[RECV] ((s8 (mkSBVTuple2 0 0)))+[SEND] (get-value (s8))+[RECV] ((s8 (mkSBVTuple2 0 0)))+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s2))+[RECV] ((s2 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bar @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 0 :: Integer+ before = (0,0) :: (Integer, Integer)+ then = (0,0) :: (Integer, Integer)+[MEASURE] Mutual group: measure (abs arg1, smax 0 arg1) failed, trying next+[MEASURE] Mutual group: trying measure (smax 0 arg1, abs arg1) for all members+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s4 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s5 () Bool (<= s4 s0))+[GOOD] (define-fun s6 () Int (ite s5 s0 s4))+[GOOD] (define-fun s7 () Int (abs s0))+[GOOD] (define-fun s8 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s6 s7))+[GOOD] (define-fun s9 () Int (proj_1_SBVTuple2 s8))+[GOOD] (define-fun s10 () Bool (>= s9 s4))+[GOOD] (define-fun s11 () Int (proj_2_SBVTuple2 s8))+[GOOD] (define-fun s12 () Bool (>= s11 s4))+[GOOD] (define-fun s13 () Bool (and s10 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bar @(SBV Integer -> SBV Integer), foo @(SBV Integer -> SBV Integer)}: replaying 2 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 1)+[GOOD] (define-fun s4 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "__internal_sbv_s2"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s5 () Bool (<= s4 s0))+[GOOD] (define-fun s6 () Int (ite s5 s0 s4))+[GOOD] (define-fun s7 () Int (abs s0))+[GOOD] (define-fun s8 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s6 s7))+[GOOD] (define-fun s9 () Int (proj_1_SBVTuple2 s8))+[GOOD] (define-fun s10 () Int (proj_2_SBVTuple2 s8))+[GOOD] (define-fun s11 () Bool (=> true false))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s11))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s8))+[RECV] ((s8 (mkSBVTuple2 0 0)))+[SEND] (get-value (s8))+[RECV] ((s8 (mkSBVTuple2 0 0)))+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s2))+[RECV] ((s2 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bar @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 0 :: Integer+ before = (0,0) :: (Integer, Integer)+ then = (0,0) :: (Integer, Integer)+[MEASURE] Mutual group: measure (smax 0 arg1, abs arg1) failed, trying next -RESULT:-All good, expecting: Unsat+EXCEPTION CAUGHT:++*** Data.SBV: Cannot determine a termination measure for mutual recursion group.+***+*** bar :: SBV Integer -> SBV Integer+*** foo :: SBV Integer -> SBV Integer+***+*** Please use 'smtFunctionWithMeasure' to provide explicit measures.+
SBVTestSuite/GoldFiles/lambda57.gold view
@@ -1,3 +1,8 @@+[MEASURE] Verifying termination measures for: f1 @(SBV Word8 -> SBV Word8), f1 @(SBV Word8 -> SBV Word8), f2 @(SBV Word8 -> SBV Word8), f2 @(SBV Word8 -> SBV Word8), f3 @(SBV Word8 -> SBV Word8), f3 @(SBV Word8 -> SBV Word8), f4 @(SBV Word8 -> SBV Word8), f4 @(SBV Word8 -> SBV Word8)+[MEASURE] Checking: f1 @(SBV Word8 -> SBV Word8)+[MEASURE] Checking mutual recursion group: {f1 :: SBV Word8 -> SBV Word8, f2 :: SBV Word8 -> SBV Word8, f3 :: SBV Word8 -> SBV Word8, f4 :: SBV Word8 -> SBV Word8}+[MEASURE] Mutual group: trying measure arg1 for all members+[MEASURE] replayDAG {f1 @(SBV Word8 -> SBV Word8), f2 @(SBV Word8 -> SBV Word8), f3 @(SBV Word8 -> SBV Word8), f4 @(SBV Word8 -> SBV Word8)}: replaying 8 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -5,93 +10,111 @@ [GOOD] (set-option :smtlib2_compliant true) [GOOD] (set-option :diagnostic-output-channel "stdout") [GOOD] (set-option :produce-models true)-[GOOD] (set-logic ALL) ; external query, using all logics.+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all. [GOOD] ; --- tuples --- [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x00)+[GOOD] (define-fun s2 () (_ BitVec 8) #x01)+[GOOD] (define-fun s3 () (_ BitVec 8) #x02)+[GOOD] (define-fun s13 () Int 0) [GOOD] ; --- top level inputs ----[GOOD] (declare-fun s0 () (_ BitVec 8))+[GOOD] (declare-fun s0 () (_ BitVec 8)) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s8" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables --- [GOOD] ; --- uninterpreted constants --- [GOOD] ; --- user defined functions ----[GOOD] ; |f1 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8, |f2 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8, |f3 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8, |f4 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8-[GOOD] (define-funs-rec- ((|f1 @(SBV Word8 -> SBV Word8)| ((l1_s0 (_ BitVec 8))) (_ BitVec 8))- (|f2 @(SBV Word8 -> SBV Word8)| ((l2_s0 (_ BitVec 8))) (_ BitVec 8))- (|f3 @(SBV Word8 -> SBV Word8)| ((l3_s0 (_ BitVec 8))) (_ BitVec 8))- (|f4 @(SBV Word8 -> SBV Word8)| ((l4_s0 (_ BitVec 8))) (_ BitVec 8)))- (; Definition of: |f1 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8. [Refers to: |f1 @(SBV Word8 -> SBV Word8)|, |f2 @(SBV Word8 -> SBV Word8)|]- (let ((l1_s1 #x00))- (let ((l1_s3 #x01))- (let ((l1_s6 #x02))- (let ((l1_s2 (= l1_s0 l1_s1)))- (let ((l1_s4 (bvsub l1_s0 l1_s3)))- (let ((l1_s5 (|f1 @(SBV Word8 -> SBV Word8)| l1_s4)))- (let ((l1_s7 (bvsub l1_s0 l1_s6)))- (let ((l1_s8 (|f2 @(SBV Word8 -> SBV Word8)| l1_s7)))- (let ((l1_s9 (bvadd l1_s5 l1_s8)))- (let ((l1_s10 (bvadd l1_s3 l1_s9)))- (let ((l1_s11 (ite l1_s2 l1_s1 l1_s10)))- l1_s11)))))))))))- ; Definition of: |f2 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8. [Refers to: |f2 @(SBV Word8 -> SBV Word8)|, |f3 @(SBV Word8 -> SBV Word8)|]- (let ((l2_s1 #x00))- (let ((l2_s3 #x01))- (let ((l2_s6 #x02))- (let ((l2_s2 (= l2_s0 l2_s1)))- (let ((l2_s4 (bvsub l2_s0 l2_s3)))- (let ((l2_s5 (|f2 @(SBV Word8 -> SBV Word8)| l2_s4)))- (let ((l2_s7 (bvsub l2_s0 l2_s6)))- (let ((l2_s8 (|f3 @(SBV Word8 -> SBV Word8)| l2_s7)))- (let ((l2_s9 (bvadd l2_s5 l2_s8)))- (let ((l2_s10 (bvadd l2_s3 l2_s9)))- (let ((l2_s11 (ite l2_s2 l2_s1 l2_s10)))- l2_s11)))))))))))- ; Definition of: |f3 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8. [Refers to: |f3 @(SBV Word8 -> SBV Word8)|, |f4 @(SBV Word8 -> SBV Word8)|]- (let ((l3_s1 #x00))- (let ((l3_s3 #x01))- (let ((l3_s6 #x02))- (let ((l3_s2 (= l3_s0 l3_s1)))- (let ((l3_s4 (bvsub l3_s0 l3_s3)))- (let ((l3_s5 (|f3 @(SBV Word8 -> SBV Word8)| l3_s4)))- (let ((l3_s7 (bvsub l3_s0 l3_s6)))- (let ((l3_s8 (|f4 @(SBV Word8 -> SBV Word8)| l3_s7)))- (let ((l3_s9 (bvadd l3_s5 l3_s8)))- (let ((l3_s10 (bvadd l3_s3 l3_s9)))- (let ((l3_s11 (ite l3_s2 l3_s1 l3_s10)))- l3_s11)))))))))))- ; Definition of: |f4 @(SBV Word8 -> SBV Word8)| :: SWord8 -> SWord8. [Refers to: |f1 @(SBV Word8 -> SBV Word8)|, |f4 @(SBV Word8 -> SBV Word8)|]- (let ((l4_s1 #x00))- (let ((l4_s3 #x01))- (let ((l4_s6 #x02))- (let ((l4_s2 (= l4_s0 l4_s1)))- (let ((l4_s4 (bvsub l4_s0 l4_s3)))- (let ((l4_s5 (|f4 @(SBV Word8 -> SBV Word8)| l4_s4)))- (let ((l4_s7 (bvsub l4_s0 l4_s6)))- (let ((l4_s8 (|f1 @(SBV Word8 -> SBV Word8)| l4_s7)))- (let ((l4_s9 (bvadd l4_s5 l4_s8)))- (let ((l4_s10 (bvadd l4_s3 l4_s9)))- (let ((l4_s11 (ite l4_s2 l4_s1 l4_s10)))- l4_s11))))))))))))) [GOOD] ; --- assignments ----[GOOD] (define-fun s1 () (_ BitVec 8) (|f1 @(SBV Word8 -> SBV Word8)| s0))-[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] (define-fun s4 () Bool (= s0 s1))+[GOOD] (define-fun s5 () (_ BitVec 8) (bvsub s0 s2))+[GOOD] (define-fun s7 () (_ BitVec 8) (bvsub s0 s3))+[GOOD] (define-fun s9 () (_ BitVec 8) (bvadd s6 s8))+[GOOD] (define-fun s10 () (_ BitVec 8) (bvadd s2 s9))+[GOOD] (define-fun s11 () (_ BitVec 8) (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (ubv_to_int s0))+[GOOD] (define-fun s14 () Bool (>= s12 s13)) [GOOD] ; --- delayedEqualities --- [GOOD] ; --- formula ----[GOOD] (assert s2)-[GOOD] (declare-fun s3 () (_ BitVec 8))-[GOOD] (define-fun s4 () (_ BitVec 8) (|f1 @(SBV Word8 -> SBV Word8)| s3))-[GOOD] (define-fun s5 () Bool (= s3 s4))-[GOOD] (assert s5)+[GOOD] (assert (not s14)) [SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1 @(SBV Word8 -> SBV Word8), f2 @(SBV Word8 -> SBV Word8), f3 @(SBV Word8 -> SBV Word8), f4 @(SBV Word8 -> SBV Word8)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x00)+[GOOD] (define-fun s2 () (_ BitVec 8) #x01)+[GOOD] (define-fun s3 () (_ BitVec 8) #x02)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (_ BitVec 8)) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (= s0 s1))+[GOOD] (define-fun s5 () (_ BitVec 8) (bvsub s0 s2))+[GOOD] (define-fun s7 () (_ BitVec 8) (bvsub s0 s3))+[GOOD] (define-fun s9 () (_ BitVec 8) (bvadd s6 s8))+[GOOD] (define-fun s10 () (_ BitVec 8) (bvadd s2 s9))+[GOOD] (define-fun s11 () (_ BitVec 8) (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (ubv_to_int s0))+[GOOD] (define-fun s13 () Int (ubv_to_int s5))+[GOOD] (define-fun s14 () Int (ubv_to_int s7))+[GOOD] (define-fun s15 () Bool (not s4))+[GOOD] (define-fun s16 () Bool (> s12 s13))+[GOOD] (define-fun s17 () Bool (=> s15 s16))+[GOOD] (define-fun s18 () Bool (> s12 s14))+[GOOD] (define-fun s19 () Bool (=> s15 s18))+[GOOD] (define-fun s20 () Bool (and s17 s19))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s20))+[SEND] (check-sat) [RECV] sat+[SEND] (get-value (s12))+[RECV] ((s12 1))+[SEND] (get-value (s13))+[RECV] ((s13 0))+[SEND] (get-value (s14))+[RECV] ((s14 255)) [SEND] (get-value (s0))-[RECV] ((s0 #x00))-[SEND] (get-value (s3))-[RECV] ((s3 #x00))+[RECV] ((s0 #x01))+[SEND] (get-value (s6))+[RECV] ((s6 #x00))+[SEND] (get-value (s8))+[RECV] ((s8 #x00)) *** Solver : Z3 *** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for f1 @(SBV Word8 -> SBV Word8): Falsifiable. Counter-example:+ arg = 1 :: Word8+ before = 1 :: Integer+ then[1] = 0 :: Integer+ then[2] = 255 :: Integer+[MEASURE] Mutual group: measure arg1 failed, trying next -RESULT:- s0 = 0 :: Word8- s3 = 0 :: Word8+EXCEPTION CAUGHT:++*** Data.SBV: Cannot determine a termination measure for mutual recursion group.+***+*** f1 :: SBV Word8 -> SBV Word8+*** f2 :: SBV Word8 -> SBV Word8+*** f3 :: SBV Word8 -> SBV Word8+*** f4 :: SBV Word8 -> SBV Word8+***+*** Please use 'smtFunctionWithMeasure' to provide explicit measures.+
+ SBVTestSuite/GoldFiles/lambda57a.gold view
@@ -0,0 +1,928 @@+[MEASURE] Verifying termination measures for: f1i @(SBV Integer -> SBV Integer), f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f1i @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {f1i :: SBV Integer -> SBV Integer, f2i :: SBV Integer -> SBV Integer, f3i :: SBV Integer -> SBV Integer, f4i :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Int (abs s5))+[GOOD] (define-fun s14 () Int (abs s7))+[GOOD] (define-fun s15 () Bool (not s4))+[GOOD] (define-fun s16 () Bool (> s12 s13))+[GOOD] (define-fun s17 () Bool (=> s15 s16))+[GOOD] (define-fun s18 () Bool (> s12 s14))+[GOOD] (define-fun s19 () Bool (=> s15 s18))+[GOOD] (define-fun s20 () Bool (and s17 s19))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s20))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s12))+[RECV] ((s12 1))+[SEND] (get-value (s13))+[RECV] ((s13 0))+[SEND] (get-value (s14))+[RECV] ((s14 1))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s6))+[RECV] ((s6 0))+[SEND] (get-value (s8))+[RECV] ((s8 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for f1i @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 1 :: Integer+ then[1] = 0 :: Integer+ then[2] = 1 :: Integer+[MEASURE] Mutual group: measure abs arg1 failed, trying next+[MEASURE] Mutual group: trying measure smax 0 arg1 for all members+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f1i @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f2i @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f3i @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer), f2i @(SBV Integer -> SBV Integer), f3i @(SBV Integer -> SBV Integer), f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f4i @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: measure smax 0 arg1 works for all members+[MEASURE] Passed (terminating): f1i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f1i @(SBV Integer -> SBV Integer)+[MEASURE] f1i @(SBV Integer -> SBV Integer): barified = "|f1i @(SBV Integer -> SBV Integer)|"+[MEASURE] f1i @(SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|f1i @(SBV Integer -> SBV Integer)|",1),("|f2i @(SBV Integer -> SBV Integer)|",1)]+[MEASURE] f1i @(SBV Integer -> SBV Integer): recursive calls found = 1+[MEASURE] f1i @(SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Int (abs s5))+[GOOD] (define-fun s14 () Bool (not s4))+[GOOD] (define-fun s15 () Bool (> s12 s13))+[GOOD] (define-fun s16 () Bool (=> s14 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] f1i @(SBV Integer -> SBV Integer): abs arg1 -> OK+[MEASURE] Passed (terminating): f1i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f2i @(SBV Integer -> SBV Integer)+[MEASURE] f2i @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): f2i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f2i @(SBV Integer -> SBV Integer)+[MEASURE] f2i @(SBV Integer -> SBV Integer): barified = "|f2i @(SBV Integer -> SBV Integer)|"+[MEASURE] f2i @(SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|f2i @(SBV Integer -> SBV Integer)|",1),("|f3i @(SBV Integer -> SBV Integer)|",1)]+[MEASURE] f2i @(SBV Integer -> SBV Integer): recursive calls found = 1+[MEASURE] f2i @(SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {f2i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f2i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Int (abs s5))+[GOOD] (define-fun s14 () Bool (not s4))+[GOOD] (define-fun s15 () Bool (> s12 s13))+[GOOD] (define-fun s16 () Bool (=> s14 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] f2i @(SBV Integer -> SBV Integer): abs arg1 -> OK+[MEASURE] Passed (terminating): f2i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f3i @(SBV Integer -> SBV Integer)+[MEASURE] f3i @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): f3i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f3i @(SBV Integer -> SBV Integer)+[MEASURE] f3i @(SBV Integer -> SBV Integer): barified = "|f3i @(SBV Integer -> SBV Integer)|"+[MEASURE] f3i @(SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|f3i @(SBV Integer -> SBV Integer)|",1),("|f4i @(SBV Integer -> SBV Integer)|",1)]+[MEASURE] f3i @(SBV Integer -> SBV Integer): recursive calls found = 1+[MEASURE] f3i @(SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {f3i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f3i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Int (abs s5))+[GOOD] (define-fun s14 () Bool (not s4))+[GOOD] (define-fun s15 () Bool (> s12 s13))+[GOOD] (define-fun s16 () Bool (=> s14 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] f3i @(SBV Integer -> SBV Integer): abs arg1 -> OK+[MEASURE] Passed (terminating): f3i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f4i @(SBV Integer -> SBV Integer)+[MEASURE] f4i @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): f4i @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f4i @(SBV Integer -> SBV Integer)+[MEASURE] f4i @(SBV Integer -> SBV Integer): barified = "|f4i @(SBV Integer -> SBV Integer)|"+[MEASURE] f4i @(SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|f4i @(SBV Integer -> SBV Integer)|",1),("|f1i @(SBV Integer -> SBV Integer)|",1)]+[MEASURE] f4i @(SBV Integer -> SBV Integer): recursive calls found = 1+[MEASURE] f4i @(SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f4i @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () Int (abs s5))+[GOOD] (define-fun s14 () Bool (not s4))+[GOOD] (define-fun s15 () Bool (> s12 s13))+[GOOD] (define-fun s16 () Bool (=> s14 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] f4i @(SBV Integer -> SBV Integer): abs arg1 -> OK+[MEASURE] Passed (terminating): f4i @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |f1i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |f2i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |f3i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |f4i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|f1i @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|f2i @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int)+ (|f3i @(SBV Integer -> SBV Integer)| ((l3_s0 Int)) Int)+ (|f4i @(SBV Integer -> SBV Integer)| ((l4_s0 Int)) Int))+ (; Definition of: |f1i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f1i @(SBV Integer -> SBV Integer)|, |f2i @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s6 2))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|f1i @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s7 (- l1_s0 l1_s6)))+ (let ((l1_s8 (|f2i @(SBV Integer -> SBV Integer)| l1_s7)))+ (let ((l1_s9 (+ l1_s5 l1_s8)))+ (let ((l1_s10 (+ l1_s3 l1_s9)))+ (let ((l1_s11 (ite l1_s2 l1_s1 l1_s10)))+ l1_s11)))))))))))+ ; Definition of: |f2i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f2i @(SBV Integer -> SBV Integer)|, |f3i @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s6 2))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|f2i @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s7 (- l2_s0 l2_s6)))+ (let ((l2_s8 (|f3i @(SBV Integer -> SBV Integer)| l2_s7)))+ (let ((l2_s9 (+ l2_s5 l2_s8)))+ (let ((l2_s10 (+ l2_s3 l2_s9)))+ (let ((l2_s11 (ite l2_s2 l2_s1 l2_s10)))+ l2_s11)))))))))))+ ; Definition of: |f3i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f3i @(SBV Integer -> SBV Integer)|, |f4i @(SBV Integer -> SBV Integer)|]+ (let ((l3_s1 0))+ (let ((l3_s3 1))+ (let ((l3_s6 2))+ (let ((l3_s2 (<= l3_s0 l3_s1)))+ (let ((l3_s4 (- l3_s0 l3_s3)))+ (let ((l3_s5 (|f3i @(SBV Integer -> SBV Integer)| l3_s4)))+ (let ((l3_s7 (- l3_s0 l3_s6)))+ (let ((l3_s8 (|f4i @(SBV Integer -> SBV Integer)| l3_s7)))+ (let ((l3_s9 (+ l3_s5 l3_s8)))+ (let ((l3_s10 (+ l3_s3 l3_s9)))+ (let ((l3_s11 (ite l3_s2 l3_s1 l3_s10)))+ l3_s11)))))))))))+ ; Definition of: |f4i @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f1i @(SBV Integer -> SBV Integer)|, |f4i @(SBV Integer -> SBV Integer)|]+ (let ((l4_s1 0))+ (let ((l4_s3 1))+ (let ((l4_s6 2))+ (let ((l4_s2 (<= l4_s0 l4_s1)))+ (let ((l4_s4 (- l4_s0 l4_s3)))+ (let ((l4_s5 (|f4i @(SBV Integer -> SBV Integer)| l4_s4)))+ (let ((l4_s7 (- l4_s0 l4_s6)))+ (let ((l4_s8 (|f1i @(SBV Integer -> SBV Integer)| l4_s7)))+ (let ((l4_s9 (+ l4_s5 l4_s8)))+ (let ((l4_s10 (+ l4_s3 l4_s9)))+ (let ((l4_s11 (ite l4_s2 l4_s1 l4_s10)))+ l4_s11)))))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|f1i @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[GOOD] (declare-fun s3 () Int)+[GOOD] (define-fun s4 () Int (|f1i @(SBV Integer -> SBV Integer)| s3))+[GOOD] (define-fun s5 () Bool (= s3 s4))+[GOOD] (assert s5)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s3))+[RECV] ((s3 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+ s0 = 0 :: Integer+ s3 = 0 :: Integer
+ SBVTestSuite/GoldFiles/lambda57b.gold view
@@ -0,0 +1,824 @@+[MEASURE] Verifying termination measures for: f1m @(SBV Integer -> SBV Integer), f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f1m @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {f1m :: SBV Integer -> SBV Integer, f2m :: SBV Integer -> SBV Integer, f3m :: SBV Integer -> SBV Integer, f4m :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f1m @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f2m @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f3m @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer), f2m @(SBV Integer -> SBV Integer), f3m @(SBV Integer -> SBV Integer), f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (<= s1 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s1))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (> s13 s15))+[GOOD] (define-fun s20 () Bool (=> s18 s19))+[GOOD] (define-fun s21 () Bool (> s13 s17))+[GOOD] (define-fun s22 () Bool (=> s18 s21))+[GOOD] (define-fun s23 () Bool (and s20 s22))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for f4m @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: user-provided measure works for all members+[MEASURE] Passed (terminating): f1m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f1m @(SBV Integer -> SBV Integer)+[MEASURE] f1m @(SBV Integer -> SBV Integer): verifying with 0 helper(s)+[MEASURE] f1m @(SBV Integer -> SBV Integer): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (not s4))+[GOOD] (define-fun s17 () Bool (> s13 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): f1m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f2m @(SBV Integer -> SBV Integer)+[MEASURE] f2m @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): f2m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f2m @(SBV Integer -> SBV Integer)+[MEASURE] f2m @(SBV Integer -> SBV Integer): verifying with 0 helper(s)+[MEASURE] f2m @(SBV Integer -> SBV Integer): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {f2m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f2m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (not s4))+[GOOD] (define-fun s17 () Bool (> s13 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): f2m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f3m @(SBV Integer -> SBV Integer)+[MEASURE] f3m @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): f3m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f3m @(SBV Integer -> SBV Integer)+[MEASURE] f3m @(SBV Integer -> SBV Integer): verifying with 0 helper(s)+[MEASURE] f3m @(SBV Integer -> SBV Integer): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {f3m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f3m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (not s4))+[GOOD] (define-fun s17 () Bool (> s13 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): f3m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f4m @(SBV Integer -> SBV Integer)+[MEASURE] f4m @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): f4m @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f4m @(SBV Integer -> SBV Integer)+[MEASURE] f4m @(SBV Integer -> SBV Integer): verifying with 0 helper(s)+[MEASURE] f4m @(SBV Integer -> SBV Integer): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f4m @(SBV Integer -> SBV Integer)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s1))+[GOOD] (define-fun s5 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (+ s6 s8))+[GOOD] (define-fun s10 () Int (+ s2 s9))+[GOOD] (define-fun s11 () Int (ite s4 s1 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s0))+[GOOD] (define-fun s13 () Int (ite s12 s0 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s5))+[GOOD] (define-fun s15 () Int (ite s14 s5 s1))+[GOOD] (define-fun s16 () Bool (not s4))+[GOOD] (define-fun s17 () Bool (> s13 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): f4m @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |f1m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |f2m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |f3m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |f4m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|f1m @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|f2m @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int)+ (|f3m @(SBV Integer -> SBV Integer)| ((l3_s0 Int)) Int)+ (|f4m @(SBV Integer -> SBV Integer)| ((l4_s0 Int)) Int))+ (; Definition of: |f1m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f1m @(SBV Integer -> SBV Integer)|, |f2m @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s6 2))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|f1m @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s7 (- l1_s0 l1_s6)))+ (let ((l1_s8 (|f2m @(SBV Integer -> SBV Integer)| l1_s7)))+ (let ((l1_s9 (+ l1_s5 l1_s8)))+ (let ((l1_s10 (+ l1_s3 l1_s9)))+ (let ((l1_s11 (ite l1_s2 l1_s1 l1_s10)))+ l1_s11)))))))))))+ ; Definition of: |f2m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f2m @(SBV Integer -> SBV Integer)|, |f3m @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s6 2))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|f2m @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s7 (- l2_s0 l2_s6)))+ (let ((l2_s8 (|f3m @(SBV Integer -> SBV Integer)| l2_s7)))+ (let ((l2_s9 (+ l2_s5 l2_s8)))+ (let ((l2_s10 (+ l2_s3 l2_s9)))+ (let ((l2_s11 (ite l2_s2 l2_s1 l2_s10)))+ l2_s11)))))))))))+ ; Definition of: |f3m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f3m @(SBV Integer -> SBV Integer)|, |f4m @(SBV Integer -> SBV Integer)|]+ (let ((l3_s1 0))+ (let ((l3_s3 1))+ (let ((l3_s6 2))+ (let ((l3_s2 (<= l3_s0 l3_s1)))+ (let ((l3_s4 (- l3_s0 l3_s3)))+ (let ((l3_s5 (|f3m @(SBV Integer -> SBV Integer)| l3_s4)))+ (let ((l3_s7 (- l3_s0 l3_s6)))+ (let ((l3_s8 (|f4m @(SBV Integer -> SBV Integer)| l3_s7)))+ (let ((l3_s9 (+ l3_s5 l3_s8)))+ (let ((l3_s10 (+ l3_s3 l3_s9)))+ (let ((l3_s11 (ite l3_s2 l3_s1 l3_s10)))+ l3_s11)))))))))))+ ; Definition of: |f4m @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |f1m @(SBV Integer -> SBV Integer)|, |f4m @(SBV Integer -> SBV Integer)|]+ (let ((l4_s1 0))+ (let ((l4_s3 1))+ (let ((l4_s6 2))+ (let ((l4_s2 (<= l4_s0 l4_s1)))+ (let ((l4_s4 (- l4_s0 l4_s3)))+ (let ((l4_s5 (|f4m @(SBV Integer -> SBV Integer)| l4_s4)))+ (let ((l4_s7 (- l4_s0 l4_s6)))+ (let ((l4_s8 (|f1m @(SBV Integer -> SBV Integer)| l4_s7)))+ (let ((l4_s9 (+ l4_s5 l4_s8)))+ (let ((l4_s10 (+ l4_s3 l4_s9)))+ (let ((l4_s11 (ite l4_s2 l4_s1 l4_s10)))+ l4_s11)))))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|f1m @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[GOOD] (declare-fun s3 () Int)+[GOOD] (define-fun s4 () Int (|f1m @(SBV Integer -> SBV Integer)| s3))+[GOOD] (define-fun s5 () Bool (= s3 s4))+[GOOD] (assert s5)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s3))+[RECV] ((s3 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+ s0 = 0 :: Integer+ s3 = 0 :: Integer
+ SBVTestSuite/GoldFiles/lambda57c.gold view
@@ -0,0 +1,225 @@+[MEASURE] Verifying termination measures for: f1w @(SBV Word8 -> SBV Word8), f1w @(SBV Word8 -> SBV Word8), f2w @(SBV Word8 -> SBV Word8), f2w @(SBV Word8 -> SBV Word8), f3w @(SBV Word8 -> SBV Word8), f3w @(SBV Word8 -> SBV Word8), f4w @(SBV Word8 -> SBV Word8), f4w @(SBV Word8 -> SBV Word8)+[MEASURE] Checking: f1w @(SBV Word8 -> SBV Word8)+[MEASURE] Checking mutual recursion group: {f1w :: SBV Word8 -> SBV Word8, f2w :: SBV Word8 -> SBV Word8, f3w :: SBV Word8 -> SBV Word8, f4w :: SBV Word8 -> SBV Word8}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {f1w @(SBV Word8 -> SBV Word8), f2w @(SBV Word8 -> SBV Word8), f3w @(SBV Word8 -> SBV Word8), f4w @(SBV Word8 -> SBV Word8)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x00)+[GOOD] (define-fun s2 () (_ BitVec 8) #x01)+[GOOD] (define-fun s3 () (_ BitVec 8) #x02)+[GOOD] (define-fun s13 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (_ BitVec 8)) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (= s0 s1))+[GOOD] (define-fun s5 () (_ BitVec 8) (bvsub s0 s2))+[GOOD] (define-fun s7 () (_ BitVec 8) (bvsub s0 s3))+[GOOD] (define-fun s9 () (_ BitVec 8) (bvadd s6 s8))+[GOOD] (define-fun s10 () (_ BitVec 8) (bvadd s2 s9))+[GOOD] (define-fun s11 () (_ BitVec 8) (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (ubv_to_int s0))+[GOOD] (define-fun s14 () Bool (>= s12 s13))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1w @(SBV Word8 -> SBV Word8), f2w @(SBV Word8 -> SBV Word8), f3w @(SBV Word8 -> SBV Word8), f4w @(SBV Word8 -> SBV Word8)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x00)+[GOOD] (define-fun s2 () (_ BitVec 8) #x01)+[GOOD] (define-fun s3 () (_ BitVec 8) #x02)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (_ BitVec 8)) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (= s0 s1))+[GOOD] (define-fun s5 () (_ BitVec 8) (bvsub s0 s2))+[GOOD] (define-fun s7 () (_ BitVec 8) (bvsub s0 s3))+[GOOD] (define-fun s9 () (_ BitVec 8) (bvadd s6 s8))+[GOOD] (define-fun s10 () (_ BitVec 8) (bvadd s2 s9))+[GOOD] (define-fun s11 () (_ BitVec 8) (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (ubv_to_int s0))+[GOOD] (define-fun s13 () Int (ubv_to_int s5))+[GOOD] (define-fun s14 () Int (ubv_to_int s7))+[GOOD] (define-fun s15 () Bool (not s4))+[GOOD] (define-fun s16 () Bool (> s12 s13))+[GOOD] (define-fun s17 () Bool (=> s15 s16))+[GOOD] (define-fun s18 () Bool (> s12 s14))+[GOOD] (define-fun s19 () Bool (=> s15 s18))+[GOOD] (define-fun s20 () Bool (and s17 s19))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s20))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s12))+[RECV] ((s12 1))+[SEND] (get-value (s13))+[RECV] ((s13 0))+[SEND] (get-value (s14))+[RECV] ((s14 255))+[SEND] (get-value (s0))+[RECV] ((s0 #x01))+[SEND] (get-value (s6))+[RECV] ((s6 #x00))+[SEND] (get-value (s8))+[RECV] ((s8 #x00))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for f1w @(SBV Word8 -> SBV Word8): Falsifiable. Counter-example:+ arg = 1 :: Word8+ before = 1 :: Integer+ then[1] = 0 :: Integer+ then[2] = 255 :: Integer+[MEASURE] Mutual group: user-provided measure failed, falling back to auto-guess+[MEASURE] Mutual group: trying measure arg1 for all members+[MEASURE] replayDAG {f1w @(SBV Word8 -> SBV Word8), f2w @(SBV Word8 -> SBV Word8), f3w @(SBV Word8 -> SBV Word8), f4w @(SBV Word8 -> SBV Word8)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x00)+[GOOD] (define-fun s2 () (_ BitVec 8) #x01)+[GOOD] (define-fun s3 () (_ BitVec 8) #x02)+[GOOD] (define-fun s13 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (_ BitVec 8)) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (= s0 s1))+[GOOD] (define-fun s5 () (_ BitVec 8) (bvsub s0 s2))+[GOOD] (define-fun s7 () (_ BitVec 8) (bvsub s0 s3))+[GOOD] (define-fun s9 () (_ BitVec 8) (bvadd s6 s8))+[GOOD] (define-fun s10 () (_ BitVec 8) (bvadd s2 s9))+[GOOD] (define-fun s11 () (_ BitVec 8) (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (ubv_to_int s0))+[GOOD] (define-fun s14 () Bool (>= s12 s13))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f1w @(SBV Word8 -> SBV Word8), f2w @(SBV Word8 -> SBV Word8), f3w @(SBV Word8 -> SBV Word8), f4w @(SBV Word8 -> SBV Word8)}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () (_ BitVec 8) #x00)+[GOOD] (define-fun s2 () (_ BitVec 8) #x01)+[GOOD] (define-fun s3 () (_ BitVec 8) #x02)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (_ BitVec 8)) ; tracks user variable "arg"+[GOOD] (declare-fun s6 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s6"+[GOOD] (declare-fun s8 () (_ BitVec 8)) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (= s0 s1))+[GOOD] (define-fun s5 () (_ BitVec 8) (bvsub s0 s2))+[GOOD] (define-fun s7 () (_ BitVec 8) (bvsub s0 s3))+[GOOD] (define-fun s9 () (_ BitVec 8) (bvadd s6 s8))+[GOOD] (define-fun s10 () (_ BitVec 8) (bvadd s2 s9))+[GOOD] (define-fun s11 () (_ BitVec 8) (ite s4 s1 s10))+[GOOD] (define-fun s12 () Int (ubv_to_int s0))+[GOOD] (define-fun s13 () Int (ubv_to_int s5))+[GOOD] (define-fun s14 () Int (ubv_to_int s7))+[GOOD] (define-fun s15 () Bool (not s4))+[GOOD] (define-fun s16 () Bool (> s12 s13))+[GOOD] (define-fun s17 () Bool (=> s15 s16))+[GOOD] (define-fun s18 () Bool (> s12 s14))+[GOOD] (define-fun s19 () Bool (=> s15 s18))+[GOOD] (define-fun s20 () Bool (and s17 s19))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s20))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s12))+[RECV] ((s12 1))+[SEND] (get-value (s13))+[RECV] ((s13 0))+[SEND] (get-value (s14))+[RECV] ((s14 255))+[SEND] (get-value (s0))+[RECV] ((s0 #x01))+[SEND] (get-value (s6))+[RECV] ((s6 #x00))+[SEND] (get-value (s8))+[RECV] ((s8 #x00))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for f1w @(SBV Word8 -> SBV Word8): Falsifiable. Counter-example:+ arg = 1 :: Word8+ before = 1 :: Integer+ then[1] = 0 :: Integer+ then[2] = 255 :: Integer+[MEASURE] Mutual group: measure arg1 failed, trying next++EXCEPTION CAUGHT:++*** Data.SBV: Cannot determine a termination measure for mutual recursion group.+***+*** f1w :: SBV Word8 -> SBV Word8+*** f2w :: SBV Word8 -> SBV Word8+*** f3w :: SBV Word8 -> SBV Word8+*** f4w :: SBV Word8 -> SBV Word8+***+*** The user-provided measure did not work, and auto-guessing also failed.+
SBVTestSuite/GoldFiles/lambda81.gold view
@@ -1,3 +1,210 @@+[MEASURE] Verifying termination measures for: sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer]), sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer])}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 4)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq Int)) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Bool (> s7 s3))+[GOOD] (define-fun s9 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s10 () Int (- s5 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s0 s2 s10))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s8 s13 s12))+[GOOD] (define-fun s15 () (Seq Int) (ite s6 s4 s14))+[GOOD] (define-fun s16 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer])}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 4)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s12 () (Seq Int)) ; tracks user variable "__internal_sbv_s12"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Bool (> s7 s3))+[GOOD] (define-fun s9 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s10 () Int (- s5 s2))+[GOOD] (define-fun s11 () (Seq Int) (seq.extract s0 s2 s10))+[GOOD] (define-fun s13 () (Seq Int) (seq.++ s9 s12))+[GOOD] (define-fun s14 () (Seq Int) (ite s8 s13 s12))+[GOOD] (define-fun s15 () (Seq Int) (ite s6 s4 s14))+[GOOD] (define-fun s16 () Int (seq.len s11))+[GOOD] (define-fun s17 () Bool (not s8))+[GOOD] (define-fun s18 () Bool (not s6))+[GOOD] (define-fun s19 () Bool (and s17 s18))+[GOOD] (define-fun s20 () Bool (> s5 s16))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.filter @(SBV Integer -> SBV Bool)_f7406d70a9 @(SBV [Integer] -> SBV [Integer])+[MEASURE] Checking: sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer])+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer]): barified = "|sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer])|"+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer])|",1)]+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer]): trying length arg1+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () (Seq Int)) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (seq.nth s7 s1))+[GOOD] (define-fun s9 () Bool (> s6 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s6))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s9 s14 s13))+[GOOD] (define-fun s16 () (Seq Int) (ite s5 s3 s15))+[GOOD] (define-fun s17 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer])}: replaying 12 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () (Seq Int)) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s13 () (Seq Int)) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (seq.nth s7 s1))+[GOOD] (define-fun s9 () Bool (> s6 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s6))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq Int) (ite s9 s14 s13))+[GOOD] (define-fun s16 () (Seq Int) (ite s5 s3 s15))+[GOOD] (define-fun s17 () Int (seq.len s12))+[GOOD] (define-fun s18 () Bool (not s9))+[GOOD] (define-fun s19 () Bool (not s5))+[GOOD] (define-fun s20 () Bool (and s18 s19))+[GOOD] (define-fun s21 () Bool (> s4 s17))+[GOOD] (define-fun s22 () Bool (=> s20 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.filter @(SBV Integer -> SBV Bool)_2611d6a22d @(SBV [Integer] -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda82.gold view
@@ -1,3 +1,124 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]]): barified = "|sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]])|"+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]]): Uninterpreted ops in DAG: [("|sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]])}: replaying 18 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 4)+[GOOD] (define-fun s4 () Int 5)+[GOOD] (define-fun s5 () Int 6)+[GOOD] (define-fun s6 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] (define-fun s7 () (Seq (Seq Int)) (as seq.empty (Seq (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s23 () (Seq (Seq Int))) ; tracks user variable "__internal_sbv_s23"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s8 () Int (seq.len s0))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s0 s1))+[GOOD] (define-fun s11 () Int (+ s3 s10))+[GOOD] (define-fun s12 () (Seq Int) (seq.unit s11))+[GOOD] (define-fun s13 () Int (+ s4 s10))+[GOOD] (define-fun s14 () (Seq Int) (seq.unit s13))+[GOOD] (define-fun s15 () Int (+ s5 s10))+[GOOD] (define-fun s16 () (Seq Int) (seq.unit s15))+[GOOD] (define-fun s17 () (Seq Int) (seq.++ s16 s6))+[GOOD] (define-fun s18 () (Seq Int) (seq.++ s14 s17))+[GOOD] (define-fun s19 () (Seq Int) (seq.++ s12 s18))+[GOOD] (define-fun s20 () (Seq (Seq Int)) (seq.unit s19))+[GOOD] (define-fun s21 () Int (- s8 s2))+[GOOD] (define-fun s22 () (Seq Int) (seq.extract s0 s2 s21))+[GOOD] (define-fun s24 () (Seq (Seq Int)) (seq.++ s20 s23))+[GOOD] (define-fun s25 () (Seq (Seq Int)) (ite s9 s7 s24))+[GOOD] (define-fun s26 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]])}: replaying 18 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 4)+[GOOD] (define-fun s4 () Int 5)+[GOOD] (define-fun s5 () Int 6)+[GOOD] (define-fun s6 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] (define-fun s7 () (Seq (Seq Int)) (as seq.empty (Seq (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s23 () (Seq (Seq Int))) ; tracks user variable "__internal_sbv_s23"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s8 () Int (seq.len s0))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () Int (seq.nth s0 s1))+[GOOD] (define-fun s11 () Int (+ s3 s10))+[GOOD] (define-fun s12 () (Seq Int) (seq.unit s11))+[GOOD] (define-fun s13 () Int (+ s4 s10))+[GOOD] (define-fun s14 () (Seq Int) (seq.unit s13))+[GOOD] (define-fun s15 () Int (+ s5 s10))+[GOOD] (define-fun s16 () (Seq Int) (seq.unit s15))+[GOOD] (define-fun s17 () (Seq Int) (seq.++ s16 s6))+[GOOD] (define-fun s18 () (Seq Int) (seq.++ s14 s17))+[GOOD] (define-fun s19 () (Seq Int) (seq.++ s12 s18))+[GOOD] (define-fun s20 () (Seq (Seq Int)) (seq.unit s19))+[GOOD] (define-fun s21 () Int (- s8 s2))+[GOOD] (define-fun s22 () (Seq Int) (seq.extract s0 s2 s21))+[GOOD] (define-fun s24 () (Seq (Seq Int)) (seq.++ s20 s23))+[GOOD] (define-fun s25 () (Seq (Seq Int)) (ite s9 s7 s24))+[GOOD] (define-fun s26 () Int (seq.len s22))+[GOOD] (define-fun s27 () Bool (not s9))+[GOOD] (define-fun s28 () Bool (> s8 s26))+[GOOD] (define-fun s29 () Bool (=> s27 s28))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s29))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV [Integer])_136c80b6a3 @(SBV [Integer] -> SBV [[Integer]]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda85.gold view
@@ -1,3 +1,124 @@+[MEASURE] Verifying termination measures for: sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer]))+[MEASURE] Checking: sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer]))+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer])): barified = "|sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer]))|"+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer])): Uninterpreted ops in DAG: [("|sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer]))|",1)]+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer])): recursive calls found = 1+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer])): trying length arg1+[MEASURE] replayDAG {sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer]))}: replaying 17 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (SBVTuple2 (Seq Int) (Seq Int)) (mkSBVTuple2 (as seq.empty (Seq Int)) (as seq.empty (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s17 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s16))+[GOOD] (define-fun s18 () (Seq Int) (seq.++ s10 s16))+[GOOD] (define-fun s19 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s14 s18))+[GOOD] (define-fun s20 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s9 s17 s19))+[GOOD] (define-fun s21 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s6 s4 s20))+[GOOD] (define-fun s22 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer]))}: replaying 17 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (SBVTuple2 (Seq Int) (Seq Int)) (mkSBVTuple2 (as seq.empty (Seq Int)) (as seq.empty (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (= s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s17 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s16))+[GOOD] (define-fun s18 () (Seq Int) (seq.++ s10 s16))+[GOOD] (define-fun s19 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s14 s18))+[GOOD] (define-fun s20 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s9 s17 s19))+[GOOD] (define-fun s21 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s6 s4 s20))+[GOOD] (define-fun s22 () Int (seq.len s12))+[GOOD] (define-fun s23 () Bool (not s9))+[GOOD] (define-fun s24 () Bool (not s6))+[GOOD] (define-fun s25 () Bool (and s23 s24))+[GOOD] (define-fun s26 () Bool (> s5 s22))+[GOOD] (define-fun s27 () Bool (=> s25 s26))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s27))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer])): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.partition @(SBV Integer -> SBV Bool)_72b7bf5d4c @(SBV [Integer] -> SBV ([Integer],[Integer])) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda86.gold view
@@ -1,3 +1,124 @@+[MEASURE] Verifying termination measures for: sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer]))+[MEASURE] Checking: sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer]))+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer])): barified = "|sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer]))|"+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer])): Uninterpreted ops in DAG: [("|sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer]))|",1)]+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer])): recursive calls found = 1+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer])): trying length arg1+[MEASURE] replayDAG {sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer]))}: replaying 17 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (SBVTuple2 (Seq Int) (Seq Int)) (mkSBVTuple2 (as seq.empty (Seq Int)) (as seq.empty (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (distinct s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s17 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s16))+[GOOD] (define-fun s18 () (Seq Int) (seq.++ s10 s16))+[GOOD] (define-fun s19 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s14 s18))+[GOOD] (define-fun s20 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s9 s17 s19))+[GOOD] (define-fun s21 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s6 s4 s20))+[GOOD] (define-fun s22 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer]))}: replaying 17 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () Int 2)+[GOOD] (define-fun s4 () (SBVTuple2 (Seq Int) (Seq Int)) (mkSBVTuple2 (as seq.empty (Seq Int)) (as seq.empty (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s13 () (SBVTuple2 (Seq Int) (Seq Int))) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Int (seq.len s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () Int (mod s7 s3))+[GOOD] (define-fun s9 () Bool (distinct s1 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s7))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq Int) (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s17 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s15 s16))+[GOOD] (define-fun s18 () (Seq Int) (seq.++ s10 s16))+[GOOD] (define-fun s19 () (SBVTuple2 (Seq Int) (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 (Seq Int) (Seq Int))) s14 s18))+[GOOD] (define-fun s20 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s9 s17 s19))+[GOOD] (define-fun s21 () (SBVTuple2 (Seq Int) (Seq Int)) (ite s6 s4 s20))+[GOOD] (define-fun s22 () Int (seq.len s12))+[GOOD] (define-fun s23 () Bool (not s9))+[GOOD] (define-fun s24 () Bool (not s6))+[GOOD] (define-fun s25 () Bool (and s23 s24))+[GOOD] (define-fun s26 () Bool (> s5 s22))+[GOOD] (define-fun s27 () Bool (=> s25 s26))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s27))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer])): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.partition @(SBV Integer -> SBV Bool)_cb04f986c4 @(SBV [Integer] -> SBV ([Integer],[Integer])) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/lambda87.gold view
@@ -1,3 +1,343 @@+[MEASURE] Verifying termination measures for: sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]), sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]), sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_3339bda50c @(SBV (Integer,[Integer]) -> SBV [Integer]), sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] Checking: sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]): barified = "|sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])|"+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]): Uninterpreted ops in DAG: [("|sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])|",1),("|sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])|",1)]+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]): recursive calls found = 1+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]): trying length arg1+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq (Seq Int)) (as seq.empty (Seq (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () (Seq Int)) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s9 () (Seq Int)) ; tracks user variable "__internal_sbv_s9"+[GOOD] (declare-fun s13 () (Seq (Seq Int))) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s7))+[GOOD] (define-fun s10 () (Seq (Seq Int)) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq (Seq Int)) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq (Seq Int)) (ite s5 s3 s14))+[GOOD] (define-fun s16 () Bool (>= s4 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])}: replaying 11 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq (Seq Int)) (as seq.empty (Seq (Seq Int))))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq Int)) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () (Seq Int)) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s9 () (Seq Int)) ; tracks user variable "__internal_sbv_s9"+[GOOD] (declare-fun s13 () (Seq (Seq Int))) ; tracks user variable "__internal_sbv_s13"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s1 s4))+[GOOD] (define-fun s6 () Int (seq.nth s0 s1))+[GOOD] (define-fun s8 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s6 s7))+[GOOD] (define-fun s10 () (Seq (Seq Int)) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s4 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s0 s2 s11))+[GOOD] (define-fun s14 () (Seq (Seq Int)) (seq.++ s10 s13))+[GOOD] (define-fun s15 () (Seq (Seq Int)) (ite s5 s3 s14))+[GOOD] (define-fun s16 () Int (seq.len s12))+[GOOD] (define-fun s17 () Bool (not s5))+[GOOD] (define-fun s18 () Bool (> s4 s16))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s19))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]]): length arg1 -> OK+[MEASURE] Passed (terminating): sbv.map @(SBV Integer -> SBV [Integer])_8a19cac1b3 @(SBV [Integer] -> SBV [[Integer]])+[MEASURE] Checking: sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_3339bda50c @(SBV (Integer,[Integer]) -> SBV [Integer])+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_3339bda50c @(SBV (Integer,[Integer]) -> SBV [Integer]): not in a multi-member cycle, skipping mutual check+[MEASURE] Passed (terminating): sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_3339bda50c @(SBV (Integer,[Integer]) -> SBV [Integer])+[MEASURE] Checking: sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): barified = "|sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])|"+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): Uninterpreted ops in DAG: [("|sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])|",1)]+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): recursive calls found = 1+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): trying abs arg1._1+[MEASURE] replayDAG {sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () (Seq Int)) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s3 s15))+[GOOD] (define-fun s17 () Int (abs s7))+[GOOD] (define-fun s18 () Bool (>= s17 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () (Seq Int)) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s3 s15))+[GOOD] (define-fun s17 () Int (abs s7))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s19 () Int (abs s18))+[GOOD] (define-fun s20 () Bool (not s6))+[GOOD] (define-fun s21 () Bool (> s17 s19))+[GOOD] (define-fun s22 () Bool (=> s20 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s17))+[RECV] ((s17 0))+[SEND] (get-value (s19))+[RECV] ((s19 0))+[SEND] (get-value (s0))+[RECV] ((s0 (mkSBVTuple2 0 (seq.unit 2))))+[SEND] (get-value (s14))+[RECV] ((s14 (as seq.empty (Seq Int))))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): abs arg1._1 failed strict decrease: Falsifiable. Counter-example:+ arg = (0,[2]) :: (Integer, [Integer])+ before = 0 :: Integer+ then = 0 :: Integer+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): trying next candidate..+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): trying length arg1._2+[MEASURE] replayDAG {sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () (Seq Int)) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s3 s15))+[GOOD] (define-fun s17 () Bool (>= s5 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s17))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer])}: replaying 13 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] (define-fun s3 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (SBVTuple2 Int (Seq Int))) ; tracks user variable "arg"+[GOOD] (declare-fun s14 () (Seq Int)) ; tracks user variable "__internal_sbv_s14"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () (Seq Int) (proj_2_SBVTuple2 s0))+[GOOD] (define-fun s5 () Int (seq.len s4))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Int (proj_1_SBVTuple2 s0))+[GOOD] (define-fun s8 () Int (seq.nth s4 s1))+[GOOD] (define-fun s9 () Int (+ s7 s8))+[GOOD] (define-fun s10 () (Seq Int) (seq.unit s9))+[GOOD] (define-fun s11 () Int (- s5 s2))+[GOOD] (define-fun s12 () (Seq Int) (seq.extract s4 s2 s11))+[GOOD] (define-fun s13 () (SBVTuple2 Int (Seq Int)) ((as mkSBVTuple2 (SBVTuple2 Int (Seq Int))) s7 s12))+[GOOD] (define-fun s15 () (Seq Int) (seq.++ s10 s14))+[GOOD] (define-fun s16 () (Seq Int) (ite s6 s3 s15))+[GOOD] (define-fun s17 () (Seq Int) (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s18 () Int (seq.len s17))+[GOOD] (define-fun s19 () Bool (not s6))+[GOOD] (define-fun s20 () Bool (> s5 s18))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]): length arg1._2 -> OK+[MEASURE] Passed (terminating): sbv.closureMap @(SBV Integer -> SBV Integer -> SBV Integer)_d8dc9e6fbd @(SBV (Integer,[Integer]) -> SBV [Integer]) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)
SBVTestSuite/GoldFiles/listFloat2.gold view
@@ -1,3 +1,10 @@+[MEASURE] Verifying termination measures for: listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)+[MEASURE] Checking: listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)+[MEASURE] listEq @(SBV [Float] -> SBV [Float] -> SBV Bool): barified = "|listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)|"+[MEASURE] listEq @(SBV [Float] -> SBV [Float] -> SBV Bool): Uninterpreted ops in DAG: [("|listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)|",2)]+[MEASURE] listEq @(SBV [Float] -> SBV [Float] -> SBV Bool): recursive calls found = 1+[MEASURE] listEq @(SBV [Float] -> SBV [Float] -> SBV Bool): trying length arg1+[MEASURE] replayDAG {listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)}: replaying 16 node(s) ** Calling: z3 -nw -in -smt2 [GOOD] ; Automatically generated by SBV. Do not edit. [GOOD] (set-option :print-success true)@@ -12,7 +19,111 @@ [GOOD] ; --- tuples --- [GOOD] ; --- sums --- [GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1) [GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ FloatingPoint 8 24))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq (_ FloatingPoint 8 24))) ; tracks user variable "arg1"+[GOOD] (declare-fun s15 () Bool) ; tracks user variable "__internal_sbv_s15"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Int (seq.len s1))+[GOOD] (define-fun s7 () Bool (= s2 s6))+[GOOD] (define-fun s8 () (_ FloatingPoint 8 24) (seq.nth s0 s2))+[GOOD] (define-fun s9 () (_ FloatingPoint 8 24) (seq.nth s1 s2))+[GOOD] (define-fun s10 () Bool (fp.eq s8 s9))+[GOOD] (define-fun s11 () Int (- s4 s3))+[GOOD] (define-fun s12 () (Seq (_ FloatingPoint 8 24)) (seq.extract s0 s3 s11))+[GOOD] (define-fun s13 () Int (- s6 s3))+[GOOD] (define-fun s14 () (Seq (_ FloatingPoint 8 24)) (seq.extract s1 s3 s13))+[GOOD] (define-fun s16 () Bool (and s10 s15))+[GOOD] (define-fun s17 () Bool (not s7))+[GOOD] (define-fun s18 () Bool (and s16 s17))+[GOOD] (define-fun s19 () Bool (ite s5 s7 s18))+[GOOD] (define-fun s20 () Bool (>= s4 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s20))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)}: replaying 16 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () (Seq (_ FloatingPoint 8 24))) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () (Seq (_ FloatingPoint 8 24))) ; tracks user variable "arg1"+[GOOD] (declare-fun s15 () Bool) ; tracks user variable "__internal_sbv_s15"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Int (seq.len s0))+[GOOD] (define-fun s5 () Bool (= s2 s4))+[GOOD] (define-fun s6 () Int (seq.len s1))+[GOOD] (define-fun s7 () Bool (= s2 s6))+[GOOD] (define-fun s8 () (_ FloatingPoint 8 24) (seq.nth s0 s2))+[GOOD] (define-fun s9 () (_ FloatingPoint 8 24) (seq.nth s1 s2))+[GOOD] (define-fun s10 () Bool (fp.eq s8 s9))+[GOOD] (define-fun s11 () Int (- s4 s3))+[GOOD] (define-fun s12 () (Seq (_ FloatingPoint 8 24)) (seq.extract s0 s3 s11))+[GOOD] (define-fun s13 () Int (- s6 s3))+[GOOD] (define-fun s14 () (Seq (_ FloatingPoint 8 24)) (seq.extract s1 s3 s13))+[GOOD] (define-fun s16 () Bool (and s10 s15))+[GOOD] (define-fun s17 () Bool (not s7))+[GOOD] (define-fun s18 () Bool (and s16 s17))+[GOOD] (define-fun s19 () Bool (ite s5 s7 s18))+[GOOD] (define-fun s20 () Int (seq.len s12))+[GOOD] (define-fun s21 () Bool (not s5))+[GOOD] (define-fun s22 () Bool (and s17 s21))+[GOOD] (define-fun s23 () Bool (and s10 s22))+[GOOD] (define-fun s24 () Bool (> s4 s20))+[GOOD] (define-fun s25 () Bool (=> s23 s24))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s25))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] listEq @(SBV [Float] -> SBV [Float] -> SBV Bool): length arg1 -> OK+[MEASURE] Passed (terminating): listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs --- [GOOD] (declare-fun s0 () (_ FloatingPoint 8 24)) ; tracks user variable "x" [GOOD] ; --- constant tables --- [GOOD] ; --- non-constant tables ---@@ -35,8 +146,10 @@ (let ((l1_s14 (seq.extract l1_s1 l1_s10 l1_s13))) (let ((l1_s15 (|listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)| l1_s12 l1_s14))) (let ((l1_s16 (and l1_s9 l1_s15)))- (let ((l1_s17 (ite l1_s4 l1_s6 l1_s16)))- l1_s17)))))))))))))))))+ (let ((l1_s17 (not l1_s6)))+ (let ((l1_s18 (and l1_s16 l1_s17)))+ (let ((l1_s19 (ite l1_s4 l1_s6 l1_s18)))+ l1_s19))))))))))))))))))) [GOOD] ; --- assignments --- [GOOD] (define-fun s1 () (Seq (_ FloatingPoint 8 24)) (seq.unit s0)) [GOOD] (define-fun s2 () Bool (|listEq @(SBV [Float] -> SBV [Float] -> SBV Bool)| s1 s1))
+ SBVTestSuite/GoldFiles/recursive10_mutual.gold view
@@ -0,0 +1,212 @@+[MEASURE] Verifying termination measures for: mf @(SBV Integer -> SBV Integer), mg @(SBV Integer -> SBV Integer)+[MEASURE] Checking: mf @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {mf :: SBV Integer -> SBV Integer, mg :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {mf @(SBV Integer -> SBV Integer), mg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {mf @(SBV Integer -> SBV Integer), mg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for mf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {mf @(SBV Integer -> SBV Integer), mg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {mf @(SBV Integer -> SBV Integer), mg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for mg @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: measure abs arg1 works for all members+[MEASURE] Passed (terminating): mf @(SBV Integer -> SBV Integer)+[MEASURE] Checking: mg @(SBV Integer -> SBV Integer)+[MEASURE] mg @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): mg @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |mf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |mg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|mf @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|mg @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int))+ (; Definition of: |mf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |mg @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|mg @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7)))))))+ ; Definition of: |mg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |mf @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|mf @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|mf @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive11_chain.gold view
@@ -0,0 +1,299 @@+[MEASURE] Verifying termination measures for: ca @(SBV Integer -> SBV Integer), cb @(SBV Integer -> SBV Integer), cc @(SBV Integer -> SBV Integer)+[MEASURE] Checking: ca @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {ca :: SBV Integer -> SBV Integer, cb :: SBV Integer -> SBV Integer, cc :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {ca @(SBV Integer -> SBV Integer), cb @(SBV Integer -> SBV Integer), cc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ca @(SBV Integer -> SBV Integer), cb @(SBV Integer -> SBV Integer), cc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for ca @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {ca @(SBV Integer -> SBV Integer), cb @(SBV Integer -> SBV Integer), cc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ca @(SBV Integer -> SBV Integer), cb @(SBV Integer -> SBV Integer), cc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for cb @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {ca @(SBV Integer -> SBV Integer), cb @(SBV Integer -> SBV Integer), cc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ca @(SBV Integer -> SBV Integer), cb @(SBV Integer -> SBV Integer), cc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for cc @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: measure abs arg1 works for all members+[MEASURE] Passed (terminating): ca @(SBV Integer -> SBV Integer)+[MEASURE] Checking: cb @(SBV Integer -> SBV Integer)+[MEASURE] cb @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): cb @(SBV Integer -> SBV Integer)+[MEASURE] Checking: cc @(SBV Integer -> SBV Integer)+[MEASURE] cc @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): cc @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |ca @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |cb @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |cc @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|ca @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|cb @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int)+ (|cc @(SBV Integer -> SBV Integer)| ((l3_s0 Int)) Int))+ (; Definition of: |ca @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |cb @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|cb @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7)))))))+ ; Definition of: |cb @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |cc @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|cc @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))+ ; Definition of: |cc @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |ca @(SBV Integer -> SBV Integer)|]+ (let ((l3_s1 0))+ (let ((l3_s3 1))+ (let ((l3_s2 (<= l3_s0 l3_s1)))+ (let ((l3_s4 (- l3_s0 l3_s3)))+ (let ((l3_s5 (|ca @(SBV Integer -> SBV Integer)| l3_s4)))+ (let ((l3_s6 (+ l3_s3 l3_s5)))+ (let ((l3_s7 (ite l3_s2 l3_s1 l3_s6)))+ l3_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|ca @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive12_badMutual.gold view
@@ -0,0 +1,526 @@+[MEASURE] Verifying termination measures for: bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)+[MEASURE] Checking: bf @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {bf :: SBV Integer -> SBV Integer, bg :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s8))+[RECV] ((s8 1))+[SEND] (get-value (s9))+[RECV] ((s9 2))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 1 :: Integer+ then = 2 :: Integer+[MEASURE] Mutual group: measure abs arg1 failed, trying next+[MEASURE] Mutual group: trying measure smax 0 arg1 for all members+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Bool (<= s1 s4))+[GOOD] (define-fun s11 () Int (ite s10 s4 s1))+[GOOD] (define-fun s12 () Bool (not s3))+[GOOD] (define-fun s13 () Bool (> s9 s11))+[GOOD] (define-fun s14 () Bool (=> s12 s13))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s9))+[RECV] ((s9 1))+[SEND] (get-value (s11))+[RECV] ((s11 2))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 1 :: Integer+ then = 2 :: Integer+[MEASURE] Mutual group: measure smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure abs arg1 + smax 0 arg1 for all members+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () Int (+ s8 s10))+[GOOD] (define-fun s12 () Bool (>= s11 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () Int (+ s8 s10))+[GOOD] (define-fun s12 () Int (abs s4))+[GOOD] (define-fun s13 () Bool (<= s1 s4))+[GOOD] (define-fun s14 () Int (ite s13 s4 s1))+[GOOD] (define-fun s15 () Int (+ s12 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Bool (> s11 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s11))+[RECV] ((s11 2))+[SEND] (get-value (s15))+[RECV] ((s15 4))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 2 :: Integer+ then = 4 :: Integer+[MEASURE] Mutual group: measure abs arg1 + smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure (abs arg1, smax 0 arg1) for all members+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s8 s10))+[GOOD] (define-fun s12 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] (define-fun s14 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Bool (and s13 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s8 s10))+[GOOD] (define-fun s12 () Int (abs s4))+[GOOD] (define-fun s13 () Bool (<= s1 s4))+[GOOD] (define-fun s14 () Int (ite s13 s4 s1))+[GOOD] (define-fun s15 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s12 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Int (proj_1_SBVTuple2 s15))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s19 () Bool (< s17 s18))+[GOOD] (define-fun s20 () Bool (= s17 s18))+[GOOD] (define-fun s21 () Int (proj_2_SBVTuple2 s15))+[GOOD] (define-fun s22 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s23 () Bool (< s21 s22))+[GOOD] (define-fun s24 () Bool (and s20 s23))+[GOOD] (define-fun s25 () Bool (or s19 s24))+[GOOD] (define-fun s26 () Bool (=> s16 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s11))+[RECV] ((s11 (mkSBVTuple2 1 1)))+[SEND] (get-value (s15))+[RECV] ((s15 (mkSBVTuple2 2 2)))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = (1,1) :: (Integer, Integer)+ then = (2,2) :: (Integer, Integer)+[MEASURE] Mutual group: measure (abs arg1, smax 0 arg1) failed, trying next+[MEASURE] Mutual group: trying measure (smax 0 arg1, abs arg1) for all members+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] (define-fun s14 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Bool (and s13 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf @(SBV Integer -> SBV Integer), bg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s4))+[GOOD] (define-fun s13 () Int (ite s12 s4 s1))+[GOOD] (define-fun s14 () Int (abs s4))+[GOOD] (define-fun s15 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s13 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Int (proj_1_SBVTuple2 s15))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s19 () Bool (< s17 s18))+[GOOD] (define-fun s20 () Bool (= s17 s18))+[GOOD] (define-fun s21 () Int (proj_2_SBVTuple2 s15))+[GOOD] (define-fun s22 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s23 () Bool (< s21 s22))+[GOOD] (define-fun s24 () Bool (and s20 s23))+[GOOD] (define-fun s25 () Bool (or s19 s24))+[GOOD] (define-fun s26 () Bool (=> s16 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s11))+[RECV] ((s11 (mkSBVTuple2 1 1)))+[SEND] (get-value (s15))+[RECV] ((s15 (mkSBVTuple2 2 2)))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = (1,1) :: (Integer, Integer)+ then = (2,2) :: (Integer, Integer)+[MEASURE] Mutual group: measure (smax 0 arg1, abs arg1) failed, trying next++EXCEPTION:++*** Data.SBV: Cannot determine a termination measure for mutual recursion group.+***+*** bf :: SBV Integer -> SBV Integer+*** bg :: SBV Integer -> SBV Integer+***+*** Please use 'smtFunctionWithMeasure' to provide explicit measures.+
+ SBVTestSuite/GoldFiles/recursive13_mutualMeasure.gold view
@@ -0,0 +1,212 @@+[MEASURE] Verifying termination measures for: ef @(SBV Integer -> SBV Integer), eg @(SBV Integer -> SBV Integer)+[MEASURE] Checking: ef @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {ef :: SBV Integer -> SBV Integer, eg :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {ef @(SBV Integer -> SBV Integer), eg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ef @(SBV Integer -> SBV Integer), eg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for ef @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {ef @(SBV Integer -> SBV Integer), eg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ef @(SBV Integer -> SBV Integer), eg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for eg @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: user-provided measure works for all members+[MEASURE] Passed (terminating): ef @(SBV Integer -> SBV Integer)+[MEASURE] Checking: eg @(SBV Integer -> SBV Integer)+[MEASURE] eg @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): eg @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |ef @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |eg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|ef @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|eg @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int))+ (; Definition of: |ef @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |eg @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|eg @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7)))))))+ ; Definition of: |eg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |ef @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|ef @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|ef @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive14_badMutualMeasure.gold view
@@ -0,0 +1,294 @@+[MEASURE] Verifying termination measures for: hf @(SBV Integer -> SBV Integer), hg @(SBV Integer -> SBV Integer)+[MEASURE] Checking: hf @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {hf :: SBV Integer -> SBV Integer, hg :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {hf @(SBV Integer -> SBV Integer), hg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert false)+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {hf @(SBV Integer -> SBV Integer), hg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (not s3))+[GOOD] (define-fun s9 () Bool (=> s8 false))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s2))+[RECV] ((s2 1))+[SEND] (get-value (s2))+[RECV] ((s2 1))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for hf @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 1 :: Integer+ then = 1 :: Integer+[MEASURE] Mutual group: user-provided measure failed, falling back to auto-guess+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {hf @(SBV Integer -> SBV Integer), hg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {hf @(SBV Integer -> SBV Integer), hg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for hf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {hf @(SBV Integer -> SBV Integer), hg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {hf @(SBV Integer -> SBV Integer), hg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for hg @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: measure abs arg1 works for all members+[MEASURE] Passed (terminating): hf @(SBV Integer -> SBV Integer)+[MEASURE] Checking: hg @(SBV Integer -> SBV Integer)+[MEASURE] hg @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): hg @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |hf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |hg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|hf @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|hg @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int))+ (; Definition of: |hf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |hg @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|hg @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7)))))))+ ; Definition of: |hg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |hf @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|hf @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|hf @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive15_mixedMutualMeasure.gold view
@@ -0,0 +1,212 @@+[MEASURE] Verifying termination measures for: xf @(SBV Integer -> SBV Integer), xg @(SBV Integer -> SBV Integer)+[MEASURE] Checking: xf @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {xf :: SBV Integer -> SBV Integer, xg :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {xf @(SBV Integer -> SBV Integer), xg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {xf @(SBV Integer -> SBV Integer), xg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for xf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {xf @(SBV Integer -> SBV Integer), xg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {xf @(SBV Integer -> SBV Integer), xg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for xg @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: user-provided measure works for all members+[MEASURE] Passed (terminating): xf @(SBV Integer -> SBV Integer)+[MEASURE] Checking: xg @(SBV Integer -> SBV Integer)+[MEASURE] xg @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): xg @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |xf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |xg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|xf @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|xg @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int))+ (; Definition of: |xf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |xg @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|xg @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7)))))))+ ; Definition of: |xg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |xf @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|xf @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|xf @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive16_badMixedMutualMeasure.gold view
@@ -0,0 +1,1135 @@+[MEASURE] Verifying termination measures for: yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)+[MEASURE] Checking: yf @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {yf :: SBV Integer -> SBV Integer, yg :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for yf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s8))+[RECV] ((s8 1))+[SEND] (get-value (s9))+[RECV] ((s9 2))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for yg @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 1 :: Integer+ then = 2 :: Integer+[MEASURE] Mutual group: user-provided measure failed, falling back to auto-guess+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for yf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s8))+[RECV] ((s8 1))+[SEND] (get-value (s9))+[RECV] ((s9 2))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for yg @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 1 :: Integer+ then = 2 :: Integer+[MEASURE] Mutual group: measure abs arg1 failed, trying next+[MEASURE] Mutual group: trying measure smax 0 arg1 for all members+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Bool (<= s1 s4))+[GOOD] (define-fun s11 () Int (ite s10 s4 s1))+[GOOD] (define-fun s12 () Bool (not s3))+[GOOD] (define-fun s13 () Bool (> s9 s11))+[GOOD] (define-fun s14 () Bool (=> s12 s13))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for yf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Bool (<= s1 s4))+[GOOD] (define-fun s11 () Int (ite s10 s4 s1))+[GOOD] (define-fun s12 () Bool (not s3))+[GOOD] (define-fun s13 () Bool (> s9 s11))+[GOOD] (define-fun s14 () Bool (=> s12 s13))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s9))+[RECV] ((s9 1))+[SEND] (get-value (s11))+[RECV] ((s11 2))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for yg @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 1 :: Integer+ then = 2 :: Integer+[MEASURE] Mutual group: measure smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure abs arg1 + smax 0 arg1 for all members+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () Int (+ s8 s10))+[GOOD] (define-fun s12 () Bool (>= s11 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () Int (+ s8 s10))+[GOOD] (define-fun s12 () Int (abs s4))+[GOOD] (define-fun s13 () Bool (<= s1 s4))+[GOOD] (define-fun s14 () Int (ite s13 s4 s1))+[GOOD] (define-fun s15 () Int (+ s12 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Bool (> s11 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for yf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () Int (+ s8 s10))+[GOOD] (define-fun s12 () Bool (>= s11 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () Int (+ s8 s10))+[GOOD] (define-fun s12 () Int (abs s4))+[GOOD] (define-fun s13 () Bool (<= s1 s4))+[GOOD] (define-fun s14 () Int (ite s13 s4 s1))+[GOOD] (define-fun s15 () Int (+ s12 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Bool (> s11 s15))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s11))+[RECV] ((s11 2))+[SEND] (get-value (s15))+[RECV] ((s15 4))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for yg @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = 2 :: Integer+ then = 4 :: Integer+[MEASURE] Mutual group: measure abs arg1 + smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure (abs arg1, smax 0 arg1) for all members+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s8 s10))+[GOOD] (define-fun s12 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] (define-fun s14 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Bool (and s13 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s8 s10))+[GOOD] (define-fun s12 () Int (abs s4))+[GOOD] (define-fun s13 () Bool (<= s1 s4))+[GOOD] (define-fun s14 () Int (ite s13 s4 s1))+[GOOD] (define-fun s15 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s12 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Int (proj_1_SBVTuple2 s15))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s19 () Bool (< s17 s18))+[GOOD] (define-fun s20 () Bool (= s17 s18))+[GOOD] (define-fun s21 () Int (proj_2_SBVTuple2 s15))+[GOOD] (define-fun s22 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s23 () Bool (< s21 s22))+[GOOD] (define-fun s24 () Bool (and s20 s23))+[GOOD] (define-fun s25 () Bool (or s19 s24))+[GOOD] (define-fun s26 () Bool (=> s16 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for yf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s8 s10))+[GOOD] (define-fun s12 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] (define-fun s14 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Bool (and s13 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (<= s1 s0))+[GOOD] (define-fun s10 () Int (ite s9 s0 s1))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s8 s10))+[GOOD] (define-fun s12 () Int (abs s4))+[GOOD] (define-fun s13 () Bool (<= s1 s4))+[GOOD] (define-fun s14 () Int (ite s13 s4 s1))+[GOOD] (define-fun s15 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s12 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Int (proj_1_SBVTuple2 s15))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s19 () Bool (< s17 s18))+[GOOD] (define-fun s20 () Bool (= s17 s18))+[GOOD] (define-fun s21 () Int (proj_2_SBVTuple2 s15))+[GOOD] (define-fun s22 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s23 () Bool (< s21 s22))+[GOOD] (define-fun s24 () Bool (and s20 s23))+[GOOD] (define-fun s25 () Bool (or s19 s24))+[GOOD] (define-fun s26 () Bool (=> s16 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s11))+[RECV] ((s11 (mkSBVTuple2 1 1)))+[SEND] (get-value (s15))+[RECV] ((s15 (mkSBVTuple2 2 2)))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for yg @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = (1,1) :: (Integer, Integer)+ then = (2,2) :: (Integer, Integer)+[MEASURE] Mutual group: measure (abs arg1, smax 0 arg1) failed, trying next+[MEASURE] Mutual group: trying measure (smax 0 arg1, abs arg1) for all members+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] (define-fun s14 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Bool (and s13 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s4))+[GOOD] (define-fun s13 () Int (ite s12 s4 s1))+[GOOD] (define-fun s14 () Int (abs s4))+[GOOD] (define-fun s15 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s13 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Int (proj_1_SBVTuple2 s15))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s19 () Bool (< s17 s18))+[GOOD] (define-fun s20 () Bool (= s17 s18))+[GOOD] (define-fun s21 () Int (proj_2_SBVTuple2 s15))+[GOOD] (define-fun s22 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s23 () Bool (< s21 s22))+[GOOD] (define-fun s24 () Bool (and s20 s23))+[GOOD] (define-fun s25 () Bool (or s19 s24))+[GOOD] (define-fun s26 () Bool (=> s16 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for yf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s13 () Bool (>= s12 s1))+[GOOD] (define-fun s14 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Bool (and s13 s15))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {yf @(SBV Integer -> SBV Integer), yg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (+ s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (<= s1 s0))+[GOOD] (define-fun s9 () Int (ite s8 s0 s1))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s9 s10))+[GOOD] (define-fun s12 () Bool (<= s1 s4))+[GOOD] (define-fun s13 () Int (ite s12 s4 s1))+[GOOD] (define-fun s14 () Int (abs s4))+[GOOD] (define-fun s15 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s13 s14))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Int (proj_1_SBVTuple2 s15))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s11))+[GOOD] (define-fun s19 () Bool (< s17 s18))+[GOOD] (define-fun s20 () Bool (= s17 s18))+[GOOD] (define-fun s21 () Int (proj_2_SBVTuple2 s15))+[GOOD] (define-fun s22 () Int (proj_2_SBVTuple2 s11))+[GOOD] (define-fun s23 () Bool (< s21 s22))+[GOOD] (define-fun s24 () Bool (and s20 s23))+[GOOD] (define-fun s25 () Bool (or s19 s24))+[GOOD] (define-fun s26 () Bool (=> s16 s25))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s26))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s11))+[RECV] ((s11 (mkSBVTuple2 1 1)))+[SEND] (get-value (s15))+[RECV] ((s15 (mkSBVTuple2 2 2)))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for yg @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 1 :: Integer+ before = (1,1) :: (Integer, Integer)+ then = (2,2) :: (Integer, Integer)+[MEASURE] Mutual group: measure (smax 0 arg1, abs arg1) failed, trying next++EXCEPTION:++*** Data.SBV: Cannot determine a termination measure for mutual recursion group.+***+*** yf :: SBV Integer -> SBV Integer+*** yg :: SBV Integer -> SBV Integer+***+*** The user-provided measure did not work, and auto-guessing also failed.+
+ SBVTestSuite/GoldFiles/recursive17_chainMeasure.gold view
@@ -0,0 +1,299 @@+[MEASURE] Verifying termination measures for: da @(SBV Integer -> SBV Integer), db @(SBV Integer -> SBV Integer), dc @(SBV Integer -> SBV Integer)+[MEASURE] Checking: da @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {da :: SBV Integer -> SBV Integer, db :: SBV Integer -> SBV Integer, dc :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {da @(SBV Integer -> SBV Integer), db @(SBV Integer -> SBV Integer), dc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {da @(SBV Integer -> SBV Integer), db @(SBV Integer -> SBV Integer), dc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for da @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {da @(SBV Integer -> SBV Integer), db @(SBV Integer -> SBV Integer), dc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {da @(SBV Integer -> SBV Integer), db @(SBV Integer -> SBV Integer), dc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for db @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {da @(SBV Integer -> SBV Integer), db @(SBV Integer -> SBV Integer), dc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {da @(SBV Integer -> SBV Integer), db @(SBV Integer -> SBV Integer), dc @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for dc @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: user-provided measure works for all members+[MEASURE] Passed (terminating): da @(SBV Integer -> SBV Integer)+[MEASURE] Checking: db @(SBV Integer -> SBV Integer)+[MEASURE] db @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): db @(SBV Integer -> SBV Integer)+[MEASURE] Checking: dc @(SBV Integer -> SBV Integer)+[MEASURE] dc @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): dc @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |da @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |db @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |dc @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|da @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|db @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int)+ (|dc @(SBV Integer -> SBV Integer)| ((l3_s0 Int)) Int))+ (; Definition of: |da @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |db @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|db @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7)))))))+ ; Definition of: |db @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |dc @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|dc @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))+ ; Definition of: |dc @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |da @(SBV Integer -> SBV Integer)|]+ (let ((l3_s1 0))+ (let ((l3_s3 1))+ (let ((l3_s2 (<= l3_s0 l3_s1)))+ (let ((l3_s4 (- l3_s0 l3_s3)))+ (let ((l3_s5 (|da @(SBV Integer -> SBV Integer)| l3_s4)))+ (let ((l3_s6 (+ l3_s3 l3_s5)))+ (let ((l3_s7 (ite l3_s2 l3_s1 l3_s6)))+ l3_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|da @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive19_selfAndMutual.gold view
@@ -0,0 +1,297 @@+[MEASURE] Verifying termination measures for: sf @(SBV Integer -> SBV Integer), sf @(SBV Integer -> SBV Integer), sg @(SBV Integer -> SBV Integer)+[MEASURE] Checking: sf @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {sf :: SBV Integer -> SBV Integer, sg :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {sf @(SBV Integer -> SBV Integer), sg @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sf @(SBV Integer -> SBV Integer), sg @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Int (abs s4))+[GOOD] (define-fun s11 () Bool (not s3))+[GOOD] (define-fun s12 () Bool (> s9 s10))+[GOOD] (define-fun s13 () Bool (=> s11 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for sf @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {sf @(SBV Integer -> SBV Integer), sg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sf @(SBV Integer -> SBV Integer), sg @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for sg @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: measure abs arg1 works for all members+[MEASURE] Passed (terminating): sf @(SBV Integer -> SBV Integer)+[MEASURE] Checking: sf @(SBV Integer -> SBV Integer)+[MEASURE] sf @(SBV Integer -> SBV Integer): barified = "|sf @(SBV Integer -> SBV Integer)|"+[MEASURE] sf @(SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|sf @(SBV Integer -> SBV Integer)|",1),("|sg @(SBV Integer -> SBV Integer)|",1)]+[MEASURE] sf @(SBV Integer -> SBV Integer): recursive calls found = 1+[MEASURE] sf @(SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {sf @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {sf @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Int (abs s4))+[GOOD] (define-fun s11 () Bool (not s3))+[GOOD] (define-fun s12 () Bool (> s9 s10))+[GOOD] (define-fun s13 () Bool (=> s11 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] sf @(SBV Integer -> SBV Integer): abs arg1 -> OK+[MEASURE] Passed (terminating): sf @(SBV Integer -> SBV Integer)+[MEASURE] Checking: sg @(SBV Integer -> SBV Integer)+[MEASURE] sg @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): sg @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |sf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |sg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|sf @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|sg @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int))+ (; Definition of: |sf @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |sf @(SBV Integer -> SBV Integer)|, |sg @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|sf @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (|sg @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s7 (+ l1_s5 l1_s6)))+ (let ((l1_s8 (ite l1_s2 l1_s1 l1_s7)))+ l1_s8))))))))+ ; Definition of: |sg @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |sf @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|sf @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|sf @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive1_ack.gold view
@@ -0,0 +1,1003 @@+[MEASURE] Verifying termination measures for: ack @(SBV Integer -> SBV Integer -> SBV Integer)+[MEASURE] Checking: ack @(SBV Integer -> SBV Integer -> SBV Integer)+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): barified = "|ack @(SBV Integer -> SBV Integer -> SBV Integer)|"+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|ack @(SBV Integer -> SBV Integer -> SBV Integer)|",2),("|ack @(SBV Integer -> SBV Integer -> SBV Integer)|",2),("|ack @(SBV Integer -> SBV Integer -> SBV Integer)|",2)]+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): recursive calls found = 3+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Bool (>= s14 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Int (abs s7))+[GOOD] (define-fun s16 () Bool (not s4))+[GOOD] (define-fun s17 () Bool (and s6 s16))+[GOOD] (define-fun s18 () Bool (> s14 s15))+[GOOD] (define-fun s19 () Bool (=> s17 s18))+[GOOD] (define-fun s20 () Bool (not s6))+[GOOD] (define-fun s21 () Bool (and s16 s20))+[GOOD] (define-fun s22 () Bool (=> s21 false))+[GOOD] (define-fun s23 () Bool (=> s21 s18))+[GOOD] (define-fun s24 () Bool (and s22 s23))+[GOOD] (define-fun s25 () Bool (and s19 s24))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s25))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 2))+[SEND] (get-value (s15))+[RECV] ((s15 1))+[SEND] (get-value (s14))+[RECV] ((s14 2))+[SEND] (get-value (s15))+[RECV] ((s15 1))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s1))+[RECV] ((s1 1))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s10))+[RECV] ((s10 0))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): abs arg1 failed strict decrease: Falsifiable. Counter-example:+ arg0 = 2 :: Integer+ arg1 = 1 :: Integer+ before = 2 :: Integer+ then[1] = 1 :: Integer+ then[2] = 2 :: Integer+ then[3] = 1 :: Integer+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying next candidate..+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying smax 0 arg1+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Bool (<= s2 s0))+[GOOD] (define-fun s15 () Int (ite s14 s0 s2))+[GOOD] (define-fun s16 () Bool (>= s15 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Bool (<= s2 s0))+[GOOD] (define-fun s15 () Int (ite s14 s0 s2))+[GOOD] (define-fun s16 () Bool (<= s2 s7))+[GOOD] (define-fun s17 () Int (ite s16 s7 s2))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s15 s17))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] (define-fun s22 () Bool (not s6))+[GOOD] (define-fun s23 () Bool (and s18 s22))+[GOOD] (define-fun s24 () Bool (=> s23 false))+[GOOD] (define-fun s25 () Bool (=> s23 s20))+[GOOD] (define-fun s26 () Bool (and s24 s25))+[GOOD] (define-fun s27 () Bool (and s21 s26))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s27))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s15))+[RECV] ((s15 2))+[SEND] (get-value (s17))+[RECV] ((s17 1))+[SEND] (get-value (s15))+[RECV] ((s15 2))+[SEND] (get-value (s17))+[RECV] ((s17 1))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s1))+[RECV] ((s1 1))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s10))+[RECV] ((s10 0))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): smax 0 arg1 failed strict decrease: Falsifiable. Counter-example:+ arg0 = 2 :: Integer+ arg1 = 1 :: Integer+ before = 2 :: Integer+ then[1] = 1 :: Integer+ then[2] = 2 :: Integer+ then[3] = 1 :: Integer+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying next candidate..+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying abs arg2+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s1))+[GOOD] (define-fun s15 () Bool (>= s14 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s1))+[GOOD] (define-fun s15 () Int (abs s3))+[GOOD] (define-fun s16 () Int (abs s9))+[GOOD] (define-fun s17 () Int (abs s10))+[GOOD] (define-fun s18 () Bool (not s4))+[GOOD] (define-fun s19 () Bool (and s6 s18))+[GOOD] (define-fun s20 () Bool (> s14 s15))+[GOOD] (define-fun s21 () Bool (=> s19 s20))+[GOOD] (define-fun s22 () Bool (not s6))+[GOOD] (define-fun s23 () Bool (and s18 s22))+[GOOD] (define-fun s24 () Bool (> s14 s16))+[GOOD] (define-fun s25 () Bool (=> s23 s24))+[GOOD] (define-fun s26 () Bool (> s14 s17))+[GOOD] (define-fun s27 () Bool (=> s23 s26))+[GOOD] (define-fun s28 () Bool (and s25 s27))+[GOOD] (define-fun s29 () Bool (and s21 s28))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s29))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s14))+[RECV] ((s14 1))+[SEND] (get-value (s15))+[RECV] ((s15 1))+[SEND] (get-value (s16))+[RECV] ((s16 2))+[SEND] (get-value (s17))+[RECV] ((s17 1))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s1))+[RECV] ((s1 (- 1)))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s10))+[RECV] ((s10 (- 1)))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): abs arg2 failed strict decrease: Falsifiable. Counter-example:+ arg0 = 1 :: Integer+ arg1 = -1 :: Integer+ before = 1 :: Integer+ then[1] = 1 :: Integer+ then[2] = 2 :: Integer+ then[3] = 1 :: Integer+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying next candidate..+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying smax 0 arg2+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Bool (<= s2 s1))+[GOOD] (define-fun s15 () Int (ite s14 s1 s2))+[GOOD] (define-fun s16 () Bool (>= s15 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s16))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Bool (<= s2 s1))+[GOOD] (define-fun s15 () Int (ite s14 s1 s2))+[GOOD] (define-fun s16 () Bool (<= s2 s3))+[GOOD] (define-fun s17 () Int (ite s16 s3 s2))+[GOOD] (define-fun s18 () Bool (<= s2 s9))+[GOOD] (define-fun s19 () Int (ite s18 s9 s2))+[GOOD] (define-fun s20 () Bool (<= s2 s10))+[GOOD] (define-fun s21 () Int (ite s20 s10 s2))+[GOOD] (define-fun s22 () Bool (not s4))+[GOOD] (define-fun s23 () Bool (and s6 s22))+[GOOD] (define-fun s24 () Bool (> s15 s17))+[GOOD] (define-fun s25 () Bool (=> s23 s24))+[GOOD] (define-fun s26 () Bool (not s6))+[GOOD] (define-fun s27 () Bool (and s22 s26))+[GOOD] (define-fun s28 () Bool (> s15 s19))+[GOOD] (define-fun s29 () Bool (=> s27 s28))+[GOOD] (define-fun s30 () Bool (> s15 s21))+[GOOD] (define-fun s31 () Bool (=> s27 s30))+[GOOD] (define-fun s32 () Bool (and s29 s31))+[GOOD] (define-fun s33 () Bool (and s25 s32))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s33))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s15))+[RECV] ((s15 2))+[SEND] (get-value (s17))+[RECV] ((s17 1))+[SEND] (get-value (s19))+[RECV] ((s19 1))+[SEND] (get-value (s21))+[RECV] ((s21 2))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s1))+[RECV] ((s1 2))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s10))+[RECV] ((s10 2))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): smax 0 arg2 failed strict decrease: Falsifiable. Counter-example:+ arg0 = 1 :: Integer+ arg1 = 2 :: Integer+ before = 2 :: Integer+ then[1] = 1 :: Integer+ then[2] = 1 :: Integer+ then[3] = 2 :: Integer+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying next candidate..+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying abs arg1 + smax 0 arg1 + abs arg2 + smax 0 arg2+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Bool (<= s2 s0))+[GOOD] (define-fun s16 () Int (ite s15 s0 s2))+[GOOD] (define-fun s17 () Int (+ s14 s16))+[GOOD] (define-fun s18 () Int (abs s1))+[GOOD] (define-fun s19 () Int (+ s17 s18))+[GOOD] (define-fun s20 () Bool (<= s2 s1))+[GOOD] (define-fun s21 () Int (ite s20 s1 s2))+[GOOD] (define-fun s22 () Int (+ s19 s21))+[GOOD] (define-fun s23 () Bool (>= s22 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s23))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Bool (<= s2 s0))+[GOOD] (define-fun s16 () Int (ite s15 s0 s2))+[GOOD] (define-fun s17 () Int (+ s14 s16))+[GOOD] (define-fun s18 () Int (abs s1))+[GOOD] (define-fun s19 () Int (+ s17 s18))+[GOOD] (define-fun s20 () Bool (<= s2 s1))+[GOOD] (define-fun s21 () Int (ite s20 s1 s2))+[GOOD] (define-fun s22 () Int (+ s19 s21))+[GOOD] (define-fun s23 () Int (abs s7))+[GOOD] (define-fun s24 () Bool (<= s2 s7))+[GOOD] (define-fun s25 () Int (ite s24 s7 s2))+[GOOD] (define-fun s26 () Int (+ s23 s25))+[GOOD] (define-fun s27 () Int (abs s3))+[GOOD] (define-fun s28 () Int (+ s26 s27))+[GOOD] (define-fun s29 () Bool (<= s2 s3))+[GOOD] (define-fun s30 () Int (ite s29 s3 s2))+[GOOD] (define-fun s31 () Int (+ s28 s30))+[GOOD] (define-fun s32 () Int (abs s9))+[GOOD] (define-fun s33 () Int (+ s17 s32))+[GOOD] (define-fun s34 () Bool (<= s2 s9))+[GOOD] (define-fun s35 () Int (ite s34 s9 s2))+[GOOD] (define-fun s36 () Int (+ s33 s35))+[GOOD] (define-fun s37 () Int (abs s10))+[GOOD] (define-fun s38 () Int (+ s26 s37))+[GOOD] (define-fun s39 () Bool (<= s2 s10))+[GOOD] (define-fun s40 () Int (ite s39 s10 s2))+[GOOD] (define-fun s41 () Int (+ s38 s40))+[GOOD] (define-fun s42 () Bool (not s4))+[GOOD] (define-fun s43 () Bool (and s6 s42))+[GOOD] (define-fun s44 () Bool (> s22 s31))+[GOOD] (define-fun s45 () Bool (=> s43 s44))+[GOOD] (define-fun s46 () Bool (not s6))+[GOOD] (define-fun s47 () Bool (and s42 s46))+[GOOD] (define-fun s48 () Bool (> s22 s36))+[GOOD] (define-fun s49 () Bool (=> s47 s48))+[GOOD] (define-fun s50 () Bool (> s22 s41))+[GOOD] (define-fun s51 () Bool (=> s47 s50))+[GOOD] (define-fun s52 () Bool (and s49 s51))+[GOOD] (define-fun s53 () Bool (and s45 s52))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s53))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s22))+[RECV] ((s22 8))+[SEND] (get-value (s31))+[RECV] ((s31 4))+[SEND] (get-value (s36))+[RECV] ((s36 6))+[SEND] (get-value (s41))+[RECV] ((s41 8))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s1))+[RECV] ((s1 2))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s10))+[RECV] ((s10 (- 6)))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): abs arg1 + smax 0 arg1 + abs arg2 + smax 0 arg2 failed strict decrease: Falsifiable. Counter-example:+ arg0 = 2 :: Integer+ arg1 = 2 :: Integer+ before = 8 :: Integer+ then[1] = 4 :: Integer+ then[2] = 6 :: Integer+ then[3] = 8 :: Integer+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying next candidate..+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying (abs arg1, smax 0 arg1)+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Bool (<= s2 s0))+[GOOD] (define-fun s16 () Int (ite s15 s0 s2))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s14 s16))+[GOOD] (define-fun s18 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s19 () Bool (>= s18 s2))+[GOOD] (define-fun s20 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s21 () Bool (>= s20 s2))+[GOOD] (define-fun s22 () Bool (and s19 s21))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s22))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Bool (<= s2 s0))+[GOOD] (define-fun s16 () Int (ite s15 s0 s2))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s14 s16))+[GOOD] (define-fun s18 () Int (abs s7))+[GOOD] (define-fun s19 () Bool (<= s2 s7))+[GOOD] (define-fun s20 () Int (ite s19 s7 s2))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s18 s20))+[GOOD] (define-fun s22 () Bool (not s4))+[GOOD] (define-fun s23 () Bool (and s6 s22))+[GOOD] (define-fun s24 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s25 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s26 () Bool (< s24 s25))+[GOOD] (define-fun s27 () Bool (= s24 s25))+[GOOD] (define-fun s28 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s29 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s30 () Bool (< s28 s29))+[GOOD] (define-fun s31 () Bool (and s27 s30))+[GOOD] (define-fun s32 () Bool (or s26 s31))+[GOOD] (define-fun s33 () Bool (=> s23 s32))+[GOOD] (define-fun s34 () Bool (not s6))+[GOOD] (define-fun s35 () Bool (and s22 s34))+[GOOD] (define-fun s36 () Bool (=> s35 false))+[GOOD] (define-fun s37 () Bool (=> s35 s32))+[GOOD] (define-fun s38 () Bool (and s36 s37))+[GOOD] (define-fun s39 () Bool (and s33 s38))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s39))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s17))+[RECV] ((s17 (mkSBVTuple2 2 2)))+[SEND] (get-value (s21))+[RECV] ((s21 (mkSBVTuple2 1 1)))+[SEND] (get-value (s17))+[RECV] ((s17 (mkSBVTuple2 2 2)))+[SEND] (get-value (s21))+[RECV] ((s21 (mkSBVTuple2 1 1)))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s1))+[RECV] ((s1 1))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s10))+[RECV] ((s10 0))+[SEND] (get-value (s11))+[RECV] ((s11 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): (abs arg1, smax 0 arg1) failed strict decrease: Falsifiable. Counter-example:+ arg0 = 2 :: Integer+ arg1 = 1 :: Integer+ before = (2,2) :: (Integer, Integer)+ then[1] = (1,1) :: (Integer, Integer)+ then[2] = (2,2) :: (Integer, Integer)+ then[3] = (1,1) :: (Integer, Integer)+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying next candidate..+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): trying (abs arg1, abs arg2)+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Int (abs s1))+[GOOD] (define-fun s16 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s14 s15))+[GOOD] (define-fun s17 () Int (proj_1_SBVTuple2 s16))+[GOOD] (define-fun s18 () Bool (>= s17 s2))+[GOOD] (define-fun s19 () Int (proj_2_SBVTuple2 s16))+[GOOD] (define-fun s20 () Bool (>= s19 s2))+[GOOD] (define-fun s21 () Bool (and s18 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {ack @(SBV Integer -> SBV Integer -> SBV Integer)}: replaying 10 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] (define-fun s3 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s10 () Int) ; tracks user variable "__internal_sbv_s10"+[GOOD] (declare-fun s11 () Int) ; tracks user variable "__internal_sbv_s11"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (<= s0 s2))+[GOOD] (define-fun s5 () Int (+ s1 s3))+[GOOD] (define-fun s6 () Bool (<= s1 s2))+[GOOD] (define-fun s7 () Int (- s0 s3))+[GOOD] (define-fun s9 () Int (- s1 s3))+[GOOD] (define-fun s12 () Int (ite s6 s8 s11))+[GOOD] (define-fun s13 () Int (ite s4 s5 s12))+[GOOD] (define-fun s14 () Int (abs s0))+[GOOD] (define-fun s15 () Int (abs s1))+[GOOD] (define-fun s16 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s14 s15))+[GOOD] (define-fun s17 () Int (abs s7))+[GOOD] (define-fun s18 () Int (abs s3))+[GOOD] (define-fun s19 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s17 s18))+[GOOD] (define-fun s20 () Int (abs s9))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s14 s20))+[GOOD] (define-fun s22 () Int (abs s10))+[GOOD] (define-fun s23 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s17 s22))+[GOOD] (define-fun s24 () Bool (not s4))+[GOOD] (define-fun s25 () Bool (and s6 s24))+[GOOD] (define-fun s26 () Int (proj_1_SBVTuple2 s19))+[GOOD] (define-fun s27 () Int (proj_1_SBVTuple2 s16))+[GOOD] (define-fun s28 () Bool (< s26 s27))+[GOOD] (define-fun s29 () Bool (= s26 s27))+[GOOD] (define-fun s30 () Int (proj_2_SBVTuple2 s19))+[GOOD] (define-fun s31 () Int (proj_2_SBVTuple2 s16))+[GOOD] (define-fun s32 () Bool (< s30 s31))+[GOOD] (define-fun s33 () Bool (and s29 s32))+[GOOD] (define-fun s34 () Bool (or s28 s33))+[GOOD] (define-fun s35 () Bool (=> s25 s34))+[GOOD] (define-fun s36 () Bool (not s6))+[GOOD] (define-fun s37 () Bool (and s24 s36))+[GOOD] (define-fun s38 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s39 () Bool (< s38 s27))+[GOOD] (define-fun s40 () Bool (= s27 s38))+[GOOD] (define-fun s41 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s42 () Bool (< s41 s31))+[GOOD] (define-fun s43 () Bool (and s40 s42))+[GOOD] (define-fun s44 () Bool (or s39 s43))+[GOOD] (define-fun s45 () Bool (=> s37 s44))+[GOOD] (define-fun s46 () Int (proj_1_SBVTuple2 s23))+[GOOD] (define-fun s47 () Bool (< s46 s27))+[GOOD] (define-fun s48 () Bool (= s27 s46))+[GOOD] (define-fun s49 () Int (proj_2_SBVTuple2 s23))+[GOOD] (define-fun s50 () Bool (< s49 s31))+[GOOD] (define-fun s51 () Bool (and s48 s50))+[GOOD] (define-fun s52 () Bool (or s47 s51))+[GOOD] (define-fun s53 () Bool (=> s37 s52))+[GOOD] (define-fun s54 () Bool (and s45 s53))+[GOOD] (define-fun s55 () Bool (and s35 s54))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s55))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] ack @(SBV Integer -> SBV Integer -> SBV Integer): (abs arg1, abs arg2) -> OK+[MEASURE] Passed (terminating): ack @(SBV Integer -> SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 5)+[GOOD] (define-fun s4 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] (declare-fun s1 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |ack @(SBV Integer -> SBV Integer -> SBV Integer)| :: SInteger -> SInteger -> SInteger [Recursive]+[GOOD] (define-fun-rec |ack @(SBV Integer -> SBV Integer -> SBV Integer)| ((l1_s0 Int) (l1_s1 Int)) Int+ (let ((l1_s2 0))+ (let ((l1_s4 1))+ (let ((l1_s3 (<= l1_s0 l1_s2)))+ (let ((l1_s5 (+ l1_s1 l1_s4)))+ (let ((l1_s6 (<= l1_s1 l1_s2)))+ (let ((l1_s7 (- l1_s0 l1_s4)))+ (let ((l1_s8 (|ack @(SBV Integer -> SBV Integer -> SBV Integer)| l1_s7 l1_s4)))+ (let ((l1_s9 (- l1_s1 l1_s4)))+ (let ((l1_s10 (|ack @(SBV Integer -> SBV Integer -> SBV Integer)| l1_s0 l1_s9)))+ (let ((l1_s11 (|ack @(SBV Integer -> SBV Integer -> SBV Integer)| l1_s7 l1_s10)))+ (let ((l1_s12 (ite l1_s6 l1_s8 l1_s11)))+ (let ((l1_s13 (ite l1_s3 l1_s5 l1_s12)))+ l1_s13)))))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (= s0 s2))+[GOOD] (define-fun s5 () Int (|ack @(SBV Integer -> SBV Integer -> SBV Integer)| s4 s0))+[GOOD] (define-fun s6 () Bool (= s1 s5))+[GOOD] (define-fun s7 () Bool (and s3 s6))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s7)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 5))+[SEND] (get-value (s1))+[RECV] ((s1 7))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 5 :: Integer+ s1 = 7 :: Integer
+ SBVTestSuite/GoldFiles/recursive20_mutualTP.gold view
@@ -0,0 +1,221 @@+[MEASURE] checkNewMeasures: 2 to verify+[MEASURE] checkNewMeasures: verifying mf_tp @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {mf_tp :: SBV Integer -> SBV Integer, mg_tp :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {mf_tp @(SBV Integer -> SBV Integer), mg_tp @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {mf_tp @(SBV Integer -> SBV Integer), mg_tp @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for mf_tp @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {mf_tp @(SBV Integer -> SBV Integer), mg_tp @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {mf_tp @(SBV Integer -> SBV Integer), mg_tp @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s2 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for mg_tp @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: measure abs arg1 works for all members+[MEASURE] checkNewMeasures: mf_tp @(SBV Integer -> SBV Integer) verified+[MEASURE] checkNewMeasures: verifying mg_tp @(SBV Integer -> SBV Integer)+[MEASURE] mg_tp @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] checkNewMeasures: mg_tp @(SBV Integer -> SBV Integer) verified+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "__internal_sbv_s0"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |mf_tp @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |mg_tp @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|mf_tp @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|mg_tp @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int))+ (; Definition of: |mf_tp @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |mg_tp @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|mg_tp @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7)))))))+ ; Definition of: |mg_tp @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |mf_tp @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|mf_tp @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (+ l2_s3 l2_s5)))+ (let ((l2_s7 (ite l2_s2 l2_s1 l2_s6)))+ l2_s7)))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] (define-fun s3 () Int (|mf_tp @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s4 () Bool (= s1 s3))+[GOOD] (define-fun s5 () Bool (=> s2 s4))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+; smtProofStep: No context value to push.+Lemma: mutual_at_0+[GOOD] (define-fun s6 () Bool (forall ((l1_s0 Int))+ (let ((l1_s1 0))+ (let ((l1_s2 (= l1_s0 l1_s1)))+ (let ((l1_s3 (|mf_tp @(SBV Integer -> SBV Integer)| l1_s0)))+ (let ((l1_s4 (= l1_s1 l1_s3)))+ (let ((l1_s5 (=> l1_s2 l1_s4)))+ l1_s5)))))))+[GOOD] (define-fun s7 () Bool (not s6))+[GOOD] (assert s7)+[SEND] (check-sat)+[RECV] unsat+ Q.E.D.+*** Solver : Z3+*** Exit code: ExitSuccess+Functions proven terminating: mf_tp, mg_tp
+ SBVTestSuite/GoldFiles/recursive21_allSelfBadCross.gold view
@@ -0,0 +1,613 @@+[MEASURE] Verifying termination measures for: bf21 @(SBV Integer -> SBV Integer), bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)+[MEASURE] Checking: bf21 @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {bf21 :: SBV Integer -> SBV Integer, bg21 :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying measure abs arg1 for all members+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () Bool (>= s10 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s11))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () Int (abs s4))+[GOOD] (define-fun s12 () Int (abs s6))+[GOOD] (define-fun s13 () Bool (not s3))+[GOOD] (define-fun s14 () Bool (> s10 s11))+[GOOD] (define-fun s15 () Bool (=> s13 s14))+[GOOD] (define-fun s16 () Bool (> s10 s12))+[GOOD] (define-fun s17 () Bool (=> s13 s16))+[GOOD] (define-fun s18 () Bool (and s15 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s10))+[RECV] ((s10 2))+[SEND] (get-value (s11))+[RECV] ((s11 1))+[SEND] (get-value (s12))+[RECV] ((s12 3))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s5))+[RECV] ((s5 0))+[SEND] (get-value (s7))+[RECV] ((s7 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf21 @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 2 :: Integer+ before = 2 :: Integer+ then[1] = 1 :: Integer+ then[2] = 3 :: Integer+[MEASURE] Mutual group: measure abs arg1 failed, trying next+[MEASURE] Mutual group: trying measure smax 0 arg1 for all members+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Bool (<= s1 s0))+[GOOD] (define-fun s11 () Int (ite s10 s0 s1))+[GOOD] (define-fun s12 () Bool (>= s11 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Bool (<= s1 s0))+[GOOD] (define-fun s11 () Int (ite s10 s0 s1))+[GOOD] (define-fun s12 () Bool (<= s1 s4))+[GOOD] (define-fun s13 () Int (ite s12 s4 s1))+[GOOD] (define-fun s14 () Bool (<= s1 s6))+[GOOD] (define-fun s15 () Int (ite s14 s6 s1))+[GOOD] (define-fun s16 () Bool (not s3))+[GOOD] (define-fun s17 () Bool (> s11 s13))+[GOOD] (define-fun s18 () Bool (=> s16 s17))+[GOOD] (define-fun s19 () Bool (> s11 s15))+[GOOD] (define-fun s20 () Bool (=> s16 s19))+[GOOD] (define-fun s21 () Bool (and s18 s20))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s21))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s11))+[RECV] ((s11 2))+[SEND] (get-value (s13))+[RECV] ((s13 1))+[SEND] (get-value (s15))+[RECV] ((s15 3))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s5))+[RECV] ((s5 0))+[SEND] (get-value (s7))+[RECV] ((s7 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf21 @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 2 :: Integer+ before = 2 :: Integer+ then[1] = 1 :: Integer+ then[2] = 3 :: Integer+[MEASURE] Mutual group: measure smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure abs arg1 + smax 0 arg1 for all members+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () Bool (<= s1 s0))+[GOOD] (define-fun s12 () Int (ite s11 s0 s1))+[GOOD] (define-fun s13 () Int (+ s10 s12))+[GOOD] (define-fun s14 () Bool (>= s13 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s14))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () Bool (<= s1 s0))+[GOOD] (define-fun s12 () Int (ite s11 s0 s1))+[GOOD] (define-fun s13 () Int (+ s10 s12))+[GOOD] (define-fun s14 () Int (abs s4))+[GOOD] (define-fun s15 () Bool (<= s1 s4))+[GOOD] (define-fun s16 () Int (ite s15 s4 s1))+[GOOD] (define-fun s17 () Int (+ s14 s16))+[GOOD] (define-fun s18 () Int (abs s6))+[GOOD] (define-fun s19 () Bool (<= s1 s6))+[GOOD] (define-fun s20 () Int (ite s19 s6 s1))+[GOOD] (define-fun s21 () Int (+ s18 s20))+[GOOD] (define-fun s22 () Bool (not s3))+[GOOD] (define-fun s23 () Bool (> s13 s17))+[GOOD] (define-fun s24 () Bool (=> s22 s23))+[GOOD] (define-fun s25 () Bool (> s13 s21))+[GOOD] (define-fun s26 () Bool (=> s22 s25))+[GOOD] (define-fun s27 () Bool (and s24 s26))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s27))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s13))+[RECV] ((s13 4))+[SEND] (get-value (s17))+[RECV] ((s17 2))+[SEND] (get-value (s21))+[RECV] ((s21 6))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s5))+[RECV] ((s5 0))+[SEND] (get-value (s7))+[RECV] ((s7 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf21 @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 2 :: Integer+ before = 4 :: Integer+ then[1] = 2 :: Integer+ then[2] = 6 :: Integer+[MEASURE] Mutual group: measure abs arg1 + smax 0 arg1 failed, trying next+[MEASURE] Mutual group: trying measure (abs arg1, smax 0 arg1) for all members+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () Bool (<= s1 s0))+[GOOD] (define-fun s12 () Int (ite s11 s0 s1))+[GOOD] (define-fun s13 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s10 s12))+[GOOD] (define-fun s14 () Int (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Int (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s17 () Bool (>= s16 s1))+[GOOD] (define-fun s18 () Bool (and s15 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Int (abs s0))+[GOOD] (define-fun s11 () Bool (<= s1 s0))+[GOOD] (define-fun s12 () Int (ite s11 s0 s1))+[GOOD] (define-fun s13 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s10 s12))+[GOOD] (define-fun s14 () Int (abs s4))+[GOOD] (define-fun s15 () Bool (<= s1 s4))+[GOOD] (define-fun s16 () Int (ite s15 s4 s1))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s14 s16))+[GOOD] (define-fun s18 () Int (abs s6))+[GOOD] (define-fun s19 () Bool (<= s1 s6))+[GOOD] (define-fun s20 () Int (ite s19 s6 s1))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s18 s20))+[GOOD] (define-fun s22 () Bool (not s3))+[GOOD] (define-fun s23 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s24 () Int (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s25 () Bool (< s23 s24))+[GOOD] (define-fun s26 () Bool (= s23 s24))+[GOOD] (define-fun s27 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s28 () Int (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s29 () Bool (< s27 s28))+[GOOD] (define-fun s30 () Bool (and s26 s29))+[GOOD] (define-fun s31 () Bool (or s25 s30))+[GOOD] (define-fun s32 () Bool (=> s22 s31))+[GOOD] (define-fun s33 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s34 () Bool (< s33 s24))+[GOOD] (define-fun s35 () Bool (= s24 s33))+[GOOD] (define-fun s36 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s37 () Bool (< s36 s28))+[GOOD] (define-fun s38 () Bool (and s35 s37))+[GOOD] (define-fun s39 () Bool (or s34 s38))+[GOOD] (define-fun s40 () Bool (=> s22 s39))+[GOOD] (define-fun s41 () Bool (and s32 s40))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s41))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s13))+[RECV] ((s13 (mkSBVTuple2 2 2)))+[SEND] (get-value (s17))+[RECV] ((s17 (mkSBVTuple2 1 1)))+[SEND] (get-value (s21))+[RECV] ((s21 (mkSBVTuple2 3 3)))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s5))+[RECV] ((s5 0))+[SEND] (get-value (s7))+[RECV] ((s7 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf21 @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 2 :: Integer+ before = (2,2) :: (Integer, Integer)+ then[1] = (1,1) :: (Integer, Integer)+ then[2] = (3,3) :: (Integer, Integer)+[MEASURE] Mutual group: measure (abs arg1, smax 0 arg1) failed, trying next+[MEASURE] Mutual group: trying measure (smax 0 arg1, abs arg1) for all members+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Bool (<= s1 s0))+[GOOD] (define-fun s11 () Int (ite s10 s0 s1))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s11 s12))+[GOOD] (define-fun s14 () Int (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s15 () Bool (>= s14 s1))+[GOOD] (define-fun s16 () Int (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s17 () Bool (>= s16 s1))+[GOOD] (define-fun s18 () Bool (and s15 s17))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf21 @(SBV Integer -> SBV Integer), bg21 @(SBV Integer -> SBV Integer)}: replaying 7 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] (declare-datatypes ((SBVTuple2 2)) ((par (T1 T2)+ ((mkSBVTuple2 (proj_1_SBVTuple2 T1)+ (proj_2_SBVTuple2 T2))))))+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s8 () Int (+ s5 s7))+[GOOD] (define-fun s9 () Int (ite s3 s1 s8))+[GOOD] (define-fun s10 () Bool (<= s1 s0))+[GOOD] (define-fun s11 () Int (ite s10 s0 s1))+[GOOD] (define-fun s12 () Int (abs s0))+[GOOD] (define-fun s13 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s11 s12))+[GOOD] (define-fun s14 () Bool (<= s1 s4))+[GOOD] (define-fun s15 () Int (ite s14 s4 s1))+[GOOD] (define-fun s16 () Int (abs s4))+[GOOD] (define-fun s17 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s15 s16))+[GOOD] (define-fun s18 () Bool (<= s1 s6))+[GOOD] (define-fun s19 () Int (ite s18 s6 s1))+[GOOD] (define-fun s20 () Int (abs s6))+[GOOD] (define-fun s21 () (SBVTuple2 Int Int) ((as mkSBVTuple2 (SBVTuple2 Int Int)) s19 s20))+[GOOD] (define-fun s22 () Bool (not s3))+[GOOD] (define-fun s23 () Int (proj_1_SBVTuple2 s17))+[GOOD] (define-fun s24 () Int (proj_1_SBVTuple2 s13))+[GOOD] (define-fun s25 () Bool (< s23 s24))+[GOOD] (define-fun s26 () Bool (= s23 s24))+[GOOD] (define-fun s27 () Int (proj_2_SBVTuple2 s17))+[GOOD] (define-fun s28 () Int (proj_2_SBVTuple2 s13))+[GOOD] (define-fun s29 () Bool (< s27 s28))+[GOOD] (define-fun s30 () Bool (and s26 s29))+[GOOD] (define-fun s31 () Bool (or s25 s30))+[GOOD] (define-fun s32 () Bool (=> s22 s31))+[GOOD] (define-fun s33 () Int (proj_1_SBVTuple2 s21))+[GOOD] (define-fun s34 () Bool (< s33 s24))+[GOOD] (define-fun s35 () Bool (= s24 s33))+[GOOD] (define-fun s36 () Int (proj_2_SBVTuple2 s21))+[GOOD] (define-fun s37 () Bool (< s36 s28))+[GOOD] (define-fun s38 () Bool (and s35 s37))+[GOOD] (define-fun s39 () Bool (or s34 s38))+[GOOD] (define-fun s40 () Bool (=> s22 s39))+[GOOD] (define-fun s41 () Bool (and s32 s40))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s41))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s13))+[RECV] ((s13 (mkSBVTuple2 2 2)))+[SEND] (get-value (s17))+[RECV] ((s17 (mkSBVTuple2 1 1)))+[SEND] (get-value (s21))+[RECV] ((s21 (mkSBVTuple2 3 3)))+[SEND] (get-value (s0))+[RECV] ((s0 2))+[SEND] (get-value (s5))+[RECV] ((s5 0))+[SEND] (get-value (s7))+[RECV] ((s7 0))+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease failed for bf21 @(SBV Integer -> SBV Integer): Falsifiable. Counter-example:+ arg = 2 :: Integer+ before = (2,2) :: (Integer, Integer)+ then[1] = (1,1) :: (Integer, Integer)+ then[2] = (3,3) :: (Integer, Integer)+[MEASURE] Mutual group: measure (smax 0 arg1, abs arg1) failed, trying next++EXCEPTION:++*** Data.SBV: Cannot determine a termination measure for mutual recursion group.+***+*** bf21 :: SBV Integer -> SBV Integer+*** bg21 :: SBV Integer -> SBV Integer+***+*** Please use 'smtFunctionWithMeasure' to provide explicit measures.+
+ SBVTestSuite/GoldFiles/recursive22_allSelfGoodCross.gold view
@@ -0,0 +1,376 @@+[MEASURE] Verifying termination measures for: bf22 @(SBV Integer -> SBV Integer), bf22 @(SBV Integer -> SBV Integer), bg22 @(SBV Integer -> SBV Integer), bg22 @(SBV Integer -> SBV Integer)+[MEASURE] Checking: bf22 @(SBV Integer -> SBV Integer)+[MEASURE] Checking mutual recursion group: {bf22 :: SBV Integer -> SBV Integer, bg22 :: SBV Integer -> SBV Integer}+[MEASURE] Mutual group: trying user-provided measure for all members+[MEASURE] replayDAG {bf22 @(SBV Integer -> SBV Integer), bg22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf22 @(SBV Integer -> SBV Integer), bg22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Int (abs s4))+[GOOD] (define-fun s11 () Bool (not s3))+[GOOD] (define-fun s12 () Bool (> s9 s10))+[GOOD] (define-fun s13 () Bool (=> s11 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for bf22 @(SBV Integer -> SBV Integer)+[MEASURE] replayDAG {bf22 @(SBV Integer -> SBV Integer), bg22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf22 @(SBV Integer -> SBV Integer), bg22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Int (abs s4))+[GOOD] (define-fun s11 () Bool (not s3))+[GOOD] (define-fun s12 () Bool (> s9 s10))+[GOOD] (define-fun s13 () Bool (=> s11 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Mutual group: decrease verified for bg22 @(SBV Integer -> SBV Integer)+[MEASURE] Mutual group: user-provided measure works for all members+[MEASURE] Passed (terminating): bf22 @(SBV Integer -> SBV Integer)+[MEASURE] Checking: bf22 @(SBV Integer -> SBV Integer)+[MEASURE] bf22 @(SBV Integer -> SBV Integer): verifying with 0 helper(s)+[MEASURE] bf22 @(SBV Integer -> SBV Integer): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {bf22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bf22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Int (abs s4))+[GOOD] (define-fun s11 () Bool (not s3))+[GOOD] (define-fun s12 () Bool (> s9 s10))+[GOOD] (define-fun s13 () Bool (=> s11 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): bf22 @(SBV Integer -> SBV Integer)+[MEASURE] Checking: bg22 @(SBV Integer -> SBV Integer)+[MEASURE] bg22 @(SBV Integer -> SBV Integer): mutual group already verified, skipping+[MEASURE] Passed (terminating): bg22 @(SBV Integer -> SBV Integer)+[MEASURE] Checking: bg22 @(SBV Integer -> SBV Integer)+[MEASURE] bg22 @(SBV Integer -> SBV Integer): verifying with 0 helper(s)+[MEASURE] bg22 @(SBV Integer -> SBV Integer): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {bg22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Bool (>= s9 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s10))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {bg22 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] (declare-fun s6 () Int) ; tracks user variable "__internal_sbv_s6"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s7 () Int (+ s5 s6))+[GOOD] (define-fun s8 () Int (ite s3 s1 s7))+[GOOD] (define-fun s9 () Int (abs s0))+[GOOD] (define-fun s10 () Int (abs s4))+[GOOD] (define-fun s11 () Bool (not s3))+[GOOD] (define-fun s12 () Bool (> s9 s10))+[GOOD] (define-fun s13 () Bool (=> s11 s12))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s13))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): bg22 @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |bf22 @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger, |bg22 @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-funs-rec+ ((|bf22 @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int)+ (|bg22 @(SBV Integer -> SBV Integer)| ((l2_s0 Int)) Int))+ (; Definition of: |bf22 @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |bf22 @(SBV Integer -> SBV Integer)|, |bg22 @(SBV Integer -> SBV Integer)|]+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|bf22 @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (|bg22 @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s7 (+ l1_s5 l1_s6)))+ (let ((l1_s8 (ite l1_s2 l1_s1 l1_s7)))+ l1_s8))))))))+ ; Definition of: |bg22 @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger. [Refers to: |bf22 @(SBV Integer -> SBV Integer)|, |bg22 @(SBV Integer -> SBV Integer)|]+ (let ((l2_s1 0))+ (let ((l2_s3 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (- l2_s0 l2_s3)))+ (let ((l2_s5 (|bg22 @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s6 (|bf22 @(SBV Integer -> SBV Integer)| l2_s4)))+ (let ((l2_s7 (+ l2_s5 l2_s6)))+ (let ((l2_s8 (ite l2_s2 l2_s1 l2_s7)))+ l2_s8))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|bf22 @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s2)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 0))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 0 :: Integer
+ SBVTestSuite/GoldFiles/recursive23_mutualProductive.gold view
@@ -0,0 +1,74 @@+[MEASURE] Verifying termination measures for: pf23 @(SBV Integer -> SBV [Integer]), pg23 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: pf23 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking mutual productive group: {pf23 :: SBV Integer -> SBV [Integer], pg23 :: SBV Integer -> SBV [Integer]}+[MEASURE] Mutual productive group: all members are guarded+[MEASURE] Passed (productive): pf23 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: pg23 @(SBV Integer -> SBV [Integer])+[MEASURE] pg23 @(SBV Integer -> SBV [Integer]): mutual productive group already verified, skipping+[MEASURE] Passed (productive): pg23 @(SBV Integer -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |pf23 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger], |pg23 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]+[GOOD] (define-funs-rec+ ((|pf23 @(SBV Integer -> SBV [Integer])| ((l1_s0 Int)) (Seq Int))+ (|pg23 @(SBV Integer -> SBV [Integer])| ((l2_s0 Int)) (Seq Int)))+ (; Definition of: |pf23 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]. [Refers to: |pg23 @(SBV Integer -> SBV [Integer])|]+ (let ((l1_s1 0))+ (let ((l1_s3 (seq.unit 0)))+ (let ((l1_s5 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (seq.unit l1_s0)))+ (let ((l1_s6 (- l1_s0 l1_s5)))+ (let ((l1_s7 (|pg23 @(SBV Integer -> SBV [Integer])| l1_s6)))+ (let ((l1_s8 (seq.++ l1_s4 l1_s7)))+ (let ((l1_s9 (ite l1_s2 l1_s3 l1_s8)))+ l1_s9)))))))))+ ; Definition of: |pg23 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]. [Refers to: |pf23 @(SBV Integer -> SBV [Integer])|]+ (let ((l2_s1 0))+ (let ((l2_s3 (seq.unit 0)))+ (let ((l2_s5 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (seq.unit l2_s0)))+ (let ((l2_s6 (- l2_s0 l2_s5)))+ (let ((l2_s7 (|pf23 @(SBV Integer -> SBV [Integer])| l2_s6)))+ (let ((l2_s8 (seq.++ l2_s4 l2_s7)))+ (let ((l2_s9 (ite l2_s2 l2_s3 l2_s8)))+ l2_s9)))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () (Seq Int) (|pf23 @(SBV Integer -> SBV [Integer])| s0))+[GOOD] (define-fun s3 () Int (seq.nth s1 s2))+[GOOD] (define-fun s4 () Bool (= s0 s3))+[GOOD] (define-fun s5 () Bool (> s0 s2))+[GOOD] (define-fun s6 () Bool (and s4 s5))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s6)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 1))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 1 :: Integer
+ SBVTestSuite/GoldFiles/recursive24_badMutualProductive.gold view
@@ -0,0 +1,15 @@+[MEASURE] Verifying termination measures for: bad_pf @(SBV Integer -> SBV [Integer]), bad_pg @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: bad_pf @(SBV Integer -> SBV [Integer])+[MEASURE] Checking mutual productive group: {bad_pf :: SBV Integer -> SBV [Integer], bad_pg :: SBV Integer -> SBV [Integer]}++EXCEPTION:++*** Data.SBV: Mutual productive group has unguarded recursive calls.+***+*** bad_pf :: SBV Integer -> SBV [Integer]+*** bad_pg :: SBV Integer -> SBV [Integer]+*** Unguarded: bad_pg :: SBV Integer -> SBV [Integer]+***+*** Every recursive call (self or cross) must be a direct argument to a data constructor.++
+ SBVTestSuite/GoldFiles/recursive25_contractMutualRejected.gold view
@@ -0,0 +1,16 @@+[MEASURE] Verifying termination measures for: cf_mut @(SBV Integer -> SBV Integer), cf_mut @(SBV Integer -> SBV Integer), cg_mut @(SBV Integer -> SBV Integer)+[MEASURE] Checking: cf_mut @(SBV Integer -> SBV Integer)+[MEASURE] cf_mut @(SBV Integer -> SBV Integer) (contract): verifying with 0 helper(s)+[MEASURE] cf_mut @(SBV Integer -> SBV Integer) (contract): 0 helper axiom(s) collected, checking measure+contract+[MEASURE] Passed (terminating): cf_mut @(SBV Integer -> SBV Integer)+[MEASURE] Checking: cf_mut @(SBV Integer -> SBV Integer)++EXCEPTION:++*** Data.SBV: smtFunctionWithContract does not support mutual recursion.+***+*** Function: cf_mut :: SBV Integer -> SBV Integer+***+*** Please use smtFunction or smtFunctionWithMeasure for mutual recursion groups.++
+ SBVTestSuite/GoldFiles/recursive26_selfAndMutualProductive.gold view
@@ -0,0 +1,83 @@+[MEASURE] Verifying termination measures for: spf26 @(SBV Integer -> SBV [Integer]), spf26 @(SBV Integer -> SBV [Integer]), spg26 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: spf26 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking mutual productive group: {spf26 :: SBV Integer -> SBV [Integer], spg26 :: SBV Integer -> SBV [Integer]}+[MEASURE] Mutual productive group: all members are guarded+[MEASURE] Passed (productive): spf26 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: spf26 @(SBV Integer -> SBV [Integer])+[MEASURE] spf26 @(SBV Integer -> SBV [Integer]): productive (all recursive calls are guarded by constructors)+[MEASURE] Passed (productive): spf26 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: spg26 @(SBV Integer -> SBV [Integer])+[MEASURE] spg26 @(SBV Integer -> SBV [Integer]): mutual productive group already verified, skipping+[MEASURE] Passed (productive): spg26 @(SBV Integer -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |spf26 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger], |spg26 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]+[GOOD] (define-funs-rec+ ((|spf26 @(SBV Integer -> SBV [Integer])| ((l1_s0 Int)) (Seq Int))+ (|spg26 @(SBV Integer -> SBV [Integer])| ((l2_s0 Int)) (Seq Int)))+ (; Definition of: |spf26 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]. [Refers to: |spf26 @(SBV Integer -> SBV [Integer])|, |spg26 @(SBV Integer -> SBV [Integer])|]+ (let ((l1_s1 0))+ (let ((l1_s3 (seq.unit 0)))+ (let ((l1_s4 2))+ (let ((l1_s8 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s5 (mod l1_s0 l1_s4)))+ (let ((l1_s6 (= l1_s1 l1_s5)))+ (let ((l1_s7 (seq.unit l1_s0)))+ (let ((l1_s9 (- l1_s0 l1_s8)))+ (let ((l1_s10 (|spf26 @(SBV Integer -> SBV [Integer])| l1_s9)))+ (let ((l1_s11 (seq.++ l1_s7 l1_s10)))+ (let ((l1_s12 (|spg26 @(SBV Integer -> SBV [Integer])| l1_s9)))+ (let ((l1_s13 (seq.++ l1_s7 l1_s12)))+ (let ((l1_s14 (ite l1_s6 l1_s11 l1_s13)))+ (let ((l1_s15 (ite l1_s2 l1_s3 l1_s14)))+ l1_s15)))))))))))))))+ ; Definition of: |spg26 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]. [Refers to: |spf26 @(SBV Integer -> SBV [Integer])|]+ (let ((l2_s1 0))+ (let ((l2_s3 (seq.unit 0)))+ (let ((l2_s5 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s4 (seq.unit l2_s0)))+ (let ((l2_s6 (- l2_s0 l2_s5)))+ (let ((l2_s7 (|spf26 @(SBV Integer -> SBV [Integer])| l2_s6)))+ (let ((l2_s8 (seq.++ l2_s4 l2_s7)))+ (let ((l2_s9 (ite l2_s2 l2_s3 l2_s8)))+ l2_s9)))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () (Seq Int) (|spf26 @(SBV Integer -> SBV [Integer])| s0))+[GOOD] (define-fun s3 () Int (seq.nth s1 s2))+[GOOD] (define-fun s4 () Bool (= s0 s3))+[GOOD] (define-fun s5 () Bool (> s0 s2))+[GOOD] (define-fun s6 () Bool (and s4 s5))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s6)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 1))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 1 :: Integer
+ SBVTestSuite/GoldFiles/recursive27_mutualProductive3.gold view
@@ -0,0 +1,93 @@+[MEASURE] Verifying termination measures for: pa27 @(SBV Integer -> SBV [Integer]), pb27 @(SBV Integer -> SBV [Integer]), pc27 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: pa27 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking mutual productive group: {pa27 :: SBV Integer -> SBV [Integer], pb27 :: SBV Integer -> SBV [Integer], pc27 :: SBV Integer -> SBV [Integer]}+[MEASURE] Mutual productive group: all members are guarded+[MEASURE] Passed (productive): pa27 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: pb27 @(SBV Integer -> SBV [Integer])+[MEASURE] pb27 @(SBV Integer -> SBV [Integer]): mutual productive group already verified, skipping+[MEASURE] Passed (productive): pb27 @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: pc27 @(SBV Integer -> SBV [Integer])+[MEASURE] pc27 @(SBV Integer -> SBV [Integer]): mutual productive group already verified, skipping+[MEASURE] Passed (productive): pc27 @(SBV Integer -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |pa27 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger], |pb27 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger], |pc27 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]+[GOOD] (define-funs-rec+ ((|pa27 @(SBV Integer -> SBV [Integer])| ((l1_s0 Int)) (Seq Int))+ (|pb27 @(SBV Integer -> SBV [Integer])| ((l2_s0 Int)) (Seq Int))+ (|pc27 @(SBV Integer -> SBV [Integer])| ((l3_s0 Int)) (Seq Int)))+ (; Definition of: |pa27 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]. [Refers to: |pb27 @(SBV Integer -> SBV [Integer])|]+ (let ((l1_s1 0))+ (let ((l1_s3 (seq.unit 0)))+ (let ((l1_s5 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (seq.unit l1_s0)))+ (let ((l1_s6 (- l1_s0 l1_s5)))+ (let ((l1_s7 (|pb27 @(SBV Integer -> SBV [Integer])| l1_s6)))+ (let ((l1_s8 (seq.++ l1_s4 l1_s7)))+ (let ((l1_s9 (ite l1_s2 l1_s3 l1_s8)))+ l1_s9)))))))))+ ; Definition of: |pb27 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]. [Refers to: |pc27 @(SBV Integer -> SBV [Integer])|]+ (let ((l2_s1 0))+ (let ((l2_s3 (seq.unit 0)))+ (let ((l2_s4 10))+ (let ((l2_s7 1))+ (let ((l2_s2 (<= l2_s0 l2_s1)))+ (let ((l2_s5 (* l2_s0 l2_s4)))+ (let ((l2_s6 (seq.unit l2_s5)))+ (let ((l2_s8 (- l2_s0 l2_s7)))+ (let ((l2_s9 (|pc27 @(SBV Integer -> SBV [Integer])| l2_s8)))+ (let ((l2_s10 (seq.++ l2_s6 l2_s9)))+ (let ((l2_s11 (ite l2_s2 l2_s3 l2_s10)))+ l2_s11)))))))))))+ ; Definition of: |pc27 @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger]. [Refers to: |pa27 @(SBV Integer -> SBV [Integer])|]+ (let ((l3_s1 0))+ (let ((l3_s3 (seq.unit 0)))+ (let ((l3_s4 100))+ (let ((l3_s7 1))+ (let ((l3_s2 (<= l3_s0 l3_s1)))+ (let ((l3_s5 (* l3_s0 l3_s4)))+ (let ((l3_s6 (seq.unit l3_s5)))+ (let ((l3_s8 (- l3_s0 l3_s7)))+ (let ((l3_s9 (|pa27 @(SBV Integer -> SBV [Integer])| l3_s8)))+ (let ((l3_s10 (seq.++ l3_s6 l3_s9)))+ (let ((l3_s11 (ite l3_s2 l3_s3 l3_s10)))+ l3_s11)))))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () (Seq Int) (|pa27 @(SBV Integer -> SBV [Integer])| s0))+[GOOD] (define-fun s3 () Int (seq.nth s1 s2))+[GOOD] (define-fun s4 () Bool (= s0 s3))+[GOOD] (define-fun s5 () Bool (> s0 s2))+[GOOD] (define-fun s6 () Bool (and s4 s5))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s6)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 1))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 1 :: Integer
+ SBVTestSuite/GoldFiles/recursive28_noTermCheck.gold view
@@ -0,0 +1,53 @@+[MEASURE] ntc28 @(SBV Integer -> SBV Integer): no termination check (smtFunctionNoTermination)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 5)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "__internal_sbv_s0"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |ntc28 @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger [Recursive]+[GOOD] (define-fun-rec |ntc28 @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|ntc28 @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s3 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s2 () Bool (= s0 s1))+[GOOD] (define-fun s3 () Int (|ntc28 @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s4 () Bool (= s1 s3))+[GOOD] (define-fun s5 () Bool (=> s2 s4))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+; smtProofStep: No context value to push.+Lemma: ntc_at_5+[GOOD] (define-fun s6 () Bool (forall ((l1_s0 Int))+ (let ((l1_s1 5))+ (let ((l1_s2 (= l1_s0 l1_s1)))+ (let ((l1_s3 (|ntc28 @(SBV Integer -> SBV Integer)| l1_s0)))+ (let ((l1_s4 (= l1_s1 l1_s3)))+ (let ((l1_s5 (=> l1_s2 l1_s4)))+ l1_s5)))))))+[GOOD] (define-fun s7 () Bool (not s6))+[GOOD] (assert s7)+[SEND] (check-sat)+[RECV] unsat+ Q.E.D. [Modulo: ntc28 termination]+*** Solver : Z3+*** Exit code: ExitSuccess+[Modulo: ntc28 termination] ntc_at_5 :: Ɐn ∷ Integer → Bool
+ SBVTestSuite/GoldFiles/recursive2_enum.gold view
@@ -0,0 +1,158 @@+[MEASURE] Verifying termination measures for: EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])+[MEASURE] Checking: EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])+[MEASURE] EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer]): verifying with 0 helper(s)+[MEASURE] EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer]): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s3 () Int 0)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] (define-fun s14 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "arg2"+[GOOD] (declare-fun s10 () (Seq Int)) ; tracks user variable "__internal_sbv_s10"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Bool (< s0 s2))+[GOOD] (define-fun s6 () Bool (>= s1 s3))+[GOOD] (define-fun s7 () Bool (or s5 s6))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s0))+[GOOD] (define-fun s9 () Int (+ s0 s1))+[GOOD] (define-fun s11 () (Seq Int) (seq.++ s8 s10))+[GOOD] (define-fun s12 () (Seq Int) (ite s7 s4 s11))+[GOOD] (define-fun s13 () Int (- s0 s2))+[GOOD] (define-fun s15 () Int (+ s13 s14))+[GOOD] (define-fun s16 () Bool (<= s3 s15))+[GOOD] (define-fun s17 () Int (ite s16 s15 s3))+[GOOD] (define-fun s18 () Bool (>= s17 s3))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s18))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])}: replaying 8 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s3 () Int 0)+[GOOD] (define-fun s4 () (Seq Int) (as seq.empty (Seq Int)))+[GOOD] (define-fun s14 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg0"+[GOOD] (declare-fun s1 () Int) ; tracks user variable "arg1"+[GOOD] (declare-fun s2 () Int) ; tracks user variable "arg2"+[GOOD] (declare-fun s10 () (Seq Int)) ; tracks user variable "__internal_sbv_s10"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s5 () Bool (< s0 s2))+[GOOD] (define-fun s6 () Bool (>= s1 s3))+[GOOD] (define-fun s7 () Bool (or s5 s6))+[GOOD] (define-fun s8 () (Seq Int) (seq.unit s0))+[GOOD] (define-fun s9 () Int (+ s0 s1))+[GOOD] (define-fun s11 () (Seq Int) (seq.++ s8 s10))+[GOOD] (define-fun s12 () (Seq Int) (ite s7 s4 s11))+[GOOD] (define-fun s13 () Int (- s0 s2))+[GOOD] (define-fun s15 () Int (+ s13 s14))+[GOOD] (define-fun s16 () Bool (<= s3 s15))+[GOOD] (define-fun s17 () Int (ite s16 s15 s3))+[GOOD] (define-fun s18 () Int (- s9 s2))+[GOOD] (define-fun s19 () Int (+ s14 s18))+[GOOD] (define-fun s20 () Bool (<= s3 s19))+[GOOD] (define-fun s21 () Int (ite s20 s19 s3))+[GOOD] (define-fun s22 () Bool (not s7))+[GOOD] (define-fun s23 () Bool (> s17 s21))+[GOOD] (define-fun s24 () Bool (=> s22 s23))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s24))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 5)+[GOOD] (define-fun s2 () Int (- 1))+[GOOD] (define-fun s5 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])| :: SInteger -> SInteger -> SInteger -> [SInteger] [Recursive]+[GOOD] (define-fun-rec |EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])| ((l1_s0 Int) (l1_s1 Int) (l1_s2 Int)) (Seq Int)+ (let ((l1_s4 0))+ (let ((l1_s7 (as seq.empty (Seq Int))))+ (let ((l1_s3 (< l1_s0 l1_s2)))+ (let ((l1_s5 (>= l1_s1 l1_s4)))+ (let ((l1_s6 (or l1_s3 l1_s5)))+ (let ((l1_s8 (seq.unit l1_s0)))+ (let ((l1_s9 (+ l1_s0 l1_s1)))+ (let ((l1_s10 (|EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])| l1_s9 l1_s1 l1_s2)))+ (let ((l1_s11 (seq.++ l1_s8 l1_s10)))+ (let ((l1_s12 (ite l1_s6 l1_s7 l1_s11)))+ l1_s12)))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () (Seq Int) (|EnumSymbolic.Integer.enumFromThenTo.down @(SBV Integer -> SBV Integer -> SBV Integer -> SBV [Integer])| s1 s2 s0))+[GOOD] (define-fun s4 () Int (seq.len s3))+[GOOD] (define-fun s6 () Bool (>= s4 s5))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s6)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 6))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 6 :: Integer
+ SBVTestSuite/GoldFiles/recursive3_badMeasure.gold view
@@ -0,0 +1,94 @@+[MEASURE] Verifying termination measures for: badSum @(SBV Integer -> SBV Integer)+[MEASURE] Checking: badSum @(SBV Integer -> SBV Integer)+[MEASURE] badSum @(SBV Integer -> SBV Integer): verifying with 0 helper(s)+[MEASURE] badSum @(SBV Integer -> SBV Integer): 0 helper axiom(s) collected, checking measure+[MEASURE] replayDAG {badSum @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert false)+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {badSum @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Bool (not s3))+[GOOD] (define-fun s9 () Bool (=> s8 false))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s2))+[RECV] ((s2 1))+[SEND] (get-value (s2))+[RECV] ((s2 1))+[SEND] (get-value (s0))+[RECV] ((s0 1))+[SEND] (get-value (s5))+[RECV] ((s5 0))+*** Solver : Z3+*** Exit code: ExitSuccess++EXCEPTION:++*** Data.SBV: Termination measure does not strictly decrease at a recursive call site.+***+*** Function: badSum :: SBV Integer -> SBV Integer+***+*** Falsifiable. Counter-example:+*** arg = 1 :: Integer+*** before = 1 :: Integer+*** then = 1 :: Integer+***+*** The measure must strictly decrease at every recursive call.+
+ SBVTestSuite/GoldFiles/recursive4_mcCarthy91.gold view
@@ -0,0 +1,175 @@+[MEASURE] Verifying termination measures for: mcCarthy91 @(SBV Integer -> SBV Integer)+[MEASURE] Checking: mcCarthy91 @(SBV Integer -> SBV Integer)+[MEASURE] mcCarthy91 @(SBV Integer -> SBV Integer) (contract): verifying with 0 helper(s)+[MEASURE] mcCarthy91 @(SBV Integer -> SBV Integer) (contract): 0 helper axiom(s) collected, checking measure+contract+[MEASURE] replayDAG {mcCarthy91 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 10)+[GOOD] (define-fun s2 () Int 11)+[GOOD] (define-fun s3 () Int 100)+[GOOD] (define-fun s10 () Int 0)+[GOOD] (define-fun s11 () Int 101)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (> s0 s3))+[GOOD] (define-fun s5 () Int (- s0 s1))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s9 () Int (ite s4 s5 s8))+[GOOD] (define-fun s12 () Int (- s11 s0))+[GOOD] (define-fun s13 () Bool (<= s10 s12))+[GOOD] (define-fun s14 () Int (ite s13 s12 s10))+[GOOD] (define-fun s15 () Bool (>= s14 s10))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {mcCarthy91 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+[MEASURE] replayDAG {mcCarthy91 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+[MEASURE] replayDAG {mcCarthy91 @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 10)+[GOOD] (define-fun s2 () Int 11)+[GOOD] (define-fun s3 () Int 100)+[GOOD] (define-fun s25 () Int 91)+[GOOD] (define-fun s31 () Int 0)+[GOOD] (define-fun s32 () Int 101)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s13 () Int) ; tracks user variable "__internal_sbv_s13"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] (declare-fun s20 () Int) ; tracks user variable "__internal_sbv_s20"+[GOOD] (declare-fun s21 () Int) ; tracks user variable "__internal_sbv_s21"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (> s0 s3))+[GOOD] (define-fun s5 () Int (- s0 s1))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s9 () Int (ite s4 s5 s8))+[GOOD] (define-fun s10 () Bool (> s6 s3))+[GOOD] (define-fun s11 () Int (- s6 s1))+[GOOD] (define-fun s12 () Int (+ s2 s6))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Bool (= s7 s15))+[GOOD] (define-fun s17 () Bool (> s7 s3))+[GOOD] (define-fun s18 () Int (- s7 s1))+[GOOD] (define-fun s19 () Int (+ s2 s7))+[GOOD] (define-fun s22 () Int (ite s17 s18 s21))+[GOOD] (define-fun s23 () Bool (= s8 s22))+[GOOD] (define-fun s24 () Bool (<= s6 s3))+[GOOD] (define-fun s26 () Bool (= s7 s25))+[GOOD] (define-fun s27 () Bool (=> s24 s26))+[GOOD] (define-fun s28 () Bool (<= s7 s3))+[GOOD] (define-fun s29 () Bool (= s8 s25))+[GOOD] (define-fun s30 () Bool (=> s28 s29))+[GOOD] (define-fun s33 () Int (- s32 s0))+[GOOD] (define-fun s34 () Bool (<= s31 s33))+[GOOD] (define-fun s35 () Int (ite s34 s33 s31))+[GOOD] (define-fun s36 () Int (- s32 s6))+[GOOD] (define-fun s37 () Bool (<= s31 s36))+[GOOD] (define-fun s38 () Int (ite s37 s36 s31))+[GOOD] (define-fun s39 () Int (- s32 s7))+[GOOD] (define-fun s40 () Bool (<= s31 s39))+[GOOD] (define-fun s41 () Int (ite s40 s39 s31))+[GOOD] (define-fun s42 () Bool (not s4))+[GOOD] (define-fun s43 () Bool (> s35 s38))+[GOOD] (define-fun s44 () Bool (=> s42 s43))+[GOOD] (define-fun s45 () Bool (> s35 s41))+[GOOD] (define-fun s46 () Bool (=> s42 s45))+[GOOD] (define-fun s47 () Bool (and s44 s46))+[GOOD] (define-fun s48 () Bool (<= s0 s3))+[GOOD] (define-fun s49 () Bool (= s9 s25))+[GOOD] (define-fun s50 () Bool (=> s48 s49))+[GOOD] (define-fun s51 () Bool (and s47 s50))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s16)+[GOOD] (assert s23)+[GOOD] (assert s27)+[GOOD] (assert s30)+[GOOD] (assert (not s51))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] Passed (terminating): mcCarthy91 @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 91)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |mcCarthy91 @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger [Recursive]+[GOOD] (define-fun-rec |mcCarthy91 @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int+ (let ((l1_s1 100))+ (let ((l1_s3 10))+ (let ((l1_s5 11))+ (let ((l1_s2 (> l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s6 (+ l1_s0 l1_s5)))+ (let ((l1_s7 (|mcCarthy91 @(SBV Integer -> SBV Integer)| l1_s6)))+ (let ((l1_s8 (|mcCarthy91 @(SBV Integer -> SBV Integer)| l1_s7)))+ (let ((l1_s9 (ite l1_s2 l1_s4 l1_s8)))+ l1_s9))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|mcCarthy91 @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s3 () Bool (= s1 s2))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s3)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 101))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 101 :: Integer
+ SBVTestSuite/GoldFiles/recursive5_badContract.gold view
@@ -0,0 +1,159 @@+[MEASURE] Verifying termination measures for: mc91bad @(SBV Integer -> SBV Integer)+[MEASURE] Checking: mc91bad @(SBV Integer -> SBV Integer)+[MEASURE] mc91bad @(SBV Integer -> SBV Integer) (contract): verifying with 0 helper(s)+[MEASURE] mc91bad @(SBV Integer -> SBV Integer) (contract): 0 helper axiom(s) collected, checking measure+contract+[MEASURE] replayDAG {mc91bad @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 10)+[GOOD] (define-fun s2 () Int 11)+[GOOD] (define-fun s3 () Int 100)+[GOOD] (define-fun s10 () Int 0)+[GOOD] (define-fun s11 () Int 101)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (> s0 s3))+[GOOD] (define-fun s5 () Int (- s0 s1))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s9 () Int (ite s4 s5 s8))+[GOOD] (define-fun s12 () Int (- s11 s0))+[GOOD] (define-fun s13 () Bool (<= s10 s12))+[GOOD] (define-fun s14 () Int (ite s13 s12 s10))+[GOOD] (define-fun s15 () Bool (>= s14 s10))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {mc91bad @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+[MEASURE] replayDAG {mc91bad @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+[MEASURE] replayDAG {mc91bad @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 10)+[GOOD] (define-fun s2 () Int 11)+[GOOD] (define-fun s3 () Int 100)+[GOOD] (define-fun s24 () Int 0)+[GOOD] (define-fun s27 () Int 101)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s13 () Int) ; tracks user variable "__internal_sbv_s13"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] (declare-fun s20 () Int) ; tracks user variable "__internal_sbv_s20"+[GOOD] (declare-fun s21 () Int) ; tracks user variable "__internal_sbv_s21"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (> s0 s3))+[GOOD] (define-fun s5 () Int (- s0 s1))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s9 () Int (ite s4 s5 s8))+[GOOD] (define-fun s10 () Bool (> s6 s3))+[GOOD] (define-fun s11 () Int (- s6 s1))+[GOOD] (define-fun s12 () Int (+ s2 s6))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Bool (= s7 s15))+[GOOD] (define-fun s17 () Bool (> s7 s3))+[GOOD] (define-fun s18 () Int (- s7 s1))+[GOOD] (define-fun s19 () Int (+ s2 s7))+[GOOD] (define-fun s22 () Int (ite s17 s18 s21))+[GOOD] (define-fun s23 () Bool (= s8 s22))+[GOOD] (define-fun s25 () Bool (= s7 s24))+[GOOD] (define-fun s26 () Bool (= s8 s24))+[GOOD] (define-fun s28 () Int (- s27 s0))+[GOOD] (define-fun s29 () Bool (<= s24 s28))+[GOOD] (define-fun s30 () Int (ite s29 s28 s24))+[GOOD] (define-fun s31 () Int (- s27 s6))+[GOOD] (define-fun s32 () Bool (<= s24 s31))+[GOOD] (define-fun s33 () Int (ite s32 s31 s24))+[GOOD] (define-fun s34 () Int (- s27 s7))+[GOOD] (define-fun s35 () Bool (<= s24 s34))+[GOOD] (define-fun s36 () Int (ite s35 s34 s24))+[GOOD] (define-fun s37 () Bool (not s4))+[GOOD] (define-fun s38 () Bool (> s30 s33))+[GOOD] (define-fun s39 () Bool (=> s37 s38))+[GOOD] (define-fun s40 () Bool (> s30 s36))+[GOOD] (define-fun s41 () Bool (=> s37 s40))+[GOOD] (define-fun s42 () Bool (and s39 s41))+[GOOD] (define-fun s43 () Bool (= s9 s24))+[GOOD] (define-fun s44 () Bool (and s42 s43))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s16)+[GOOD] (assert s23)+[GOOD] (assert s25)+[GOOD] (assert s26)+[GOOD] (assert (not s44))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s30))+[RECV] ((s30 92))+[SEND] (get-value (s33))+[RECV] ((s33 81))+[SEND] (get-value (s36))+[RECV] ((s36 101))+[SEND] (get-value (s0))+[RECV] ((s0 9))+[SEND] (get-value (s7))+[RECV] ((s7 0))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s13))+[RECV] ((s13 0))+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s20))+[RECV] ((s20 0))+[SEND] (get-value (s21))+[RECV] ((s21 0))+*** Solver : Z3+*** Exit code: ExitSuccess++EXCEPTION:++*** Data.SBV: Measure+contract verification failed.+***+*** Function: mc91bad :: SBV Integer -> SBV Integer+***+*** Falsifiable. Counter-example:+*** arg = 9 :: Integer+*** before = 92 :: Integer+*** then[1] = 81 :: Integer+*** then[2] = 101 :: Integer+***+*** The measure must strictly decrease at every recursive call,+*** and the contract must hold for the function's output.+*** The inductive hypothesis provides the contract on recursive call+*** results for inputs with strictly smaller measure.+
+ SBVTestSuite/GoldFiles/recursive6_uselessContract.gold view
@@ -0,0 +1,153 @@+[MEASURE] Verifying termination measures for: mc91triv @(SBV Integer -> SBV Integer)+[MEASURE] Checking: mc91triv @(SBV Integer -> SBV Integer)+[MEASURE] mc91triv @(SBV Integer -> SBV Integer) (contract): verifying with 0 helper(s)+[MEASURE] mc91triv @(SBV Integer -> SBV Integer) (contract): 0 helper axiom(s) collected, checking measure+contract+[MEASURE] replayDAG {mc91triv @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 10)+[GOOD] (define-fun s2 () Int 11)+[GOOD] (define-fun s3 () Int 100)+[GOOD] (define-fun s10 () Int 0)+[GOOD] (define-fun s11 () Int 101)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (> s0 s3))+[GOOD] (define-fun s5 () Int (- s0 s1))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s9 () Int (ite s4 s5 s8))+[GOOD] (define-fun s12 () Int (- s11 s0))+[GOOD] (define-fun s13 () Bool (<= s10 s12))+[GOOD] (define-fun s14 () Int (ite s13 s12 s10))+[GOOD] (define-fun s15 () Bool (>= s14 s10))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s15))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {mc91triv @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+[MEASURE] replayDAG {mc91triv @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+[MEASURE] replayDAG {mc91triv @(SBV Integer -> SBV Integer)}: replaying 6 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 10)+[GOOD] (define-fun s2 () Int 11)+[GOOD] (define-fun s3 () Int 100)+[GOOD] (define-fun s24 () Int 0)+[GOOD] (define-fun s25 () Int 101)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s7 () Int) ; tracks user variable "__internal_sbv_s7"+[GOOD] (declare-fun s8 () Int) ; tracks user variable "__internal_sbv_s8"+[GOOD] (declare-fun s13 () Int) ; tracks user variable "__internal_sbv_s13"+[GOOD] (declare-fun s14 () Int) ; tracks user variable "__internal_sbv_s14"+[GOOD] (declare-fun s20 () Int) ; tracks user variable "__internal_sbv_s20"+[GOOD] (declare-fun s21 () Int) ; tracks user variable "__internal_sbv_s21"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s4 () Bool (> s0 s3))+[GOOD] (define-fun s5 () Int (- s0 s1))+[GOOD] (define-fun s6 () Int (+ s0 s2))+[GOOD] (define-fun s9 () Int (ite s4 s5 s8))+[GOOD] (define-fun s10 () Bool (> s6 s3))+[GOOD] (define-fun s11 () Int (- s6 s1))+[GOOD] (define-fun s12 () Int (+ s2 s6))+[GOOD] (define-fun s15 () Int (ite s10 s11 s14))+[GOOD] (define-fun s16 () Bool (= s7 s15))+[GOOD] (define-fun s17 () Bool (> s7 s3))+[GOOD] (define-fun s18 () Int (- s7 s1))+[GOOD] (define-fun s19 () Int (+ s2 s7))+[GOOD] (define-fun s22 () Int (ite s17 s18 s21))+[GOOD] (define-fun s23 () Bool (= s8 s22))+[GOOD] (define-fun s26 () Int (- s25 s0))+[GOOD] (define-fun s27 () Bool (<= s24 s26))+[GOOD] (define-fun s28 () Int (ite s27 s26 s24))+[GOOD] (define-fun s29 () Int (- s25 s6))+[GOOD] (define-fun s30 () Bool (<= s24 s29))+[GOOD] (define-fun s31 () Int (ite s30 s29 s24))+[GOOD] (define-fun s32 () Int (- s25 s7))+[GOOD] (define-fun s33 () Bool (<= s24 s32))+[GOOD] (define-fun s34 () Int (ite s33 s32 s24))+[GOOD] (define-fun s35 () Bool (not s4))+[GOOD] (define-fun s36 () Bool (> s28 s31))+[GOOD] (define-fun s37 () Bool (=> s35 s36))+[GOOD] (define-fun s38 () Bool (> s28 s34))+[GOOD] (define-fun s39 () Bool (=> s35 s38))+[GOOD] (define-fun s40 () Bool (and s37 s39))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s16)+[GOOD] (assert s23)+[GOOD] (assert (not s40))+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s28))+[RECV] ((s28 101))+[SEND] (get-value (s31))+[RECV] ((s31 90))+[SEND] (get-value (s34))+[RECV] ((s34 101))+[SEND] (get-value (s0))+[RECV] ((s0 0))+[SEND] (get-value (s7))+[RECV] ((s7 0))+[SEND] (get-value (s8))+[RECV] ((s8 0))+[SEND] (get-value (s13))+[RECV] ((s13 0))+[SEND] (get-value (s14))+[RECV] ((s14 0))+[SEND] (get-value (s20))+[RECV] ((s20 0))+[SEND] (get-value (s21))+[RECV] ((s21 0))+*** Solver : Z3+*** Exit code: ExitSuccess++EXCEPTION:++*** Data.SBV: Measure+contract verification failed.+***+*** Function: mc91triv :: SBV Integer -> SBV Integer+***+*** Falsifiable. Counter-example:+*** arg = 0 :: Integer+*** before = 101 :: Integer+*** then[1] = 90 :: Integer+*** then[2] = 101 :: Integer+***+*** The measure must strictly decrease at every recursive call,+*** and the contract must hold for the function's output.+*** The inductive hypothesis provides the contract on recursive call+*** results for inputs with strictly smaller measure.+
+ SBVTestSuite/GoldFiles/recursive7_productive.gold view
@@ -0,0 +1,54 @@+[MEASURE] Verifying termination measures for: rep @(SBV Integer -> SBV Integer -> SBV [Integer])+[MEASURE] Checking: rep @(SBV Integer -> SBV Integer -> SBV [Integer])+[MEASURE] rep @(SBV Integer -> SBV Integer -> SBV [Integer]): productive (all recursive calls are guarded by constructors)+[MEASURE] Passed (productive): rep @(SBV Integer -> SBV Integer -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 3)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |rep @(SBV Integer -> SBV Integer -> SBV [Integer])| :: SInteger -> SInteger -> [SInteger] [Recursive]+[GOOD] (define-fun-rec |rep @(SBV Integer -> SBV Integer -> SBV [Integer])| ((l1_s0 Int) (l1_s1 Int)) (Seq Int)+ (let ((l1_s2 0))+ (let ((l1_s4 (as seq.empty (Seq Int))))+ (let ((l1_s6 1))+ (let ((l1_s3 (<= l1_s0 l1_s2)))+ (let ((l1_s5 (seq.unit l1_s1)))+ (let ((l1_s7 (- l1_s0 l1_s6)))+ (let ((l1_s8 (|rep @(SBV Integer -> SBV Integer -> SBV [Integer])| l1_s7 l1_s1)))+ (let ((l1_s9 (seq.++ l1_s5 l1_s8)))+ (let ((l1_s10 (ite l1_s3 l1_s4 l1_s9)))+ l1_s10))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s2 () (Seq Int) (|rep @(SBV Integer -> SBV Integer -> SBV [Integer])| s1 s0))+[GOOD] (define-fun s3 () Int (seq.len s2))+[GOOD] (define-fun s4 () Bool (= s1 s3))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s4)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 4))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 4 :: Integer
+ SBVTestSuite/GoldFiles/recursive8_badProductive.gold view
@@ -0,0 +1,12 @@+[MEASURE] Verifying termination measures for: bad @(SBV Integer -> SBV Integer)+[MEASURE] Checking: bad @(SBV Integer -> SBV Integer)++EXCEPTION:++*** Data.SBV: Function marked as productive is not guarded-recursive.+***+*** Function: bad :: SBV Integer -> SBV Integer+***+*** Every recursive call must be a direct argument to a data constructor+*** (list cons, ADT constructor, etc.) to ensure productivity.+
+ SBVTestSuite/GoldFiles/recursive9_productive2.gold view
@@ -0,0 +1,56 @@+[MEASURE] Verifying termination measures for: countdown @(SBV Integer -> SBV [Integer])+[MEASURE] Checking: countdown @(SBV Integer -> SBV [Integer])+[MEASURE] countdown @(SBV Integer -> SBV [Integer]): productive (all recursive calls are guarded by constructors)+[MEASURE] Passed (productive): countdown @(SBV Integer -> SBV [Integer])+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-option :pp.max_depth 4294967295)+[GOOD] (set-option :pp.min_alias_size 4294967295)+[GOOD] (set-option :model.inline_def true )+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s2 () Int 0)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |countdown @(SBV Integer -> SBV [Integer])| :: SInteger -> [SInteger] [Recursive]+[GOOD] (define-fun-rec |countdown @(SBV Integer -> SBV [Integer])| ((l1_s0 Int)) (Seq Int)+ (let ((l1_s1 0))+ (let ((l1_s3 (seq.unit 0)))+ (let ((l1_s5 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (seq.unit l1_s0)))+ (let ((l1_s6 (- l1_s0 l1_s5)))+ (let ((l1_s7 (|countdown @(SBV Integer -> SBV [Integer])| l1_s6)))+ (let ((l1_s8 (seq.++ l1_s4 l1_s7)))+ (let ((l1_s9 (ite l1_s2 l1_s3 l1_s8)))+ l1_s9))))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () (Seq Int) (|countdown @(SBV Integer -> SBV [Integer])| s0))+[GOOD] (define-fun s3 () Int (seq.nth s1 s2))+[GOOD] (define-fun s4 () Bool (= s0 s3))+[GOOD] (define-fun s5 () Bool (> s0 s2))+[GOOD] (define-fun s6 () Bool (and s4 s5))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s6)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 1))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 1 :: Integer
+ SBVTestSuite/GoldFiles/smtFuncUniq_captureConflict.gold view
@@ -0,0 +1,9 @@++*** Data.SBV: Function 'bar @(SBV Integer -> SBV Integer)' defined with conflicting bodies.+***+*** Two calls to smtFunction (or related) used the name 'bar @(SBV Integer -> SBV Integer)'+*** but with different definitions. This would generate conflicting+*** SMTLib define-fun-rec declarations.+***+*** Please use a unique name for each distinct function.+
+ SBVTestSuite/GoldFiles/smtFuncUniq_captureTagged.gold view
@@ -0,0 +1,43 @@+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s4 () Int 10)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |bar_two @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-fun |bar_two @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int+ (let ((l1_s1 2))+ (let ((l1_s2 (+ l1_s0 l1_s1)))+ l1_s2)))+[GOOD] ; |bar_three @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-fun |bar_three @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int+ (let ((l1_s1 3))+ (let ((l1_s2 (+ l1_s0 l1_s1)))+ l1_s2)))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|bar_two @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Int (|bar_three @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s3 () Int (+ s1 s2))+[GOOD] (define-fun s5 () Bool (= s3 s4))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s5)+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Unsatisfiable
+ SBVTestSuite/GoldFiles/smtFuncUniq_conflict.gold view
@@ -0,0 +1,9 @@++*** Data.SBV: Function 'f @(SBV Integer -> SBV Integer)' defined with conflicting bodies.+***+*** Two calls to smtFunction (or related) used the name 'f @(SBV Integer -> SBV Integer)'+*** but with different definitions. This would generate conflicting+*** SMTLib define-fun-rec declarations.+***+*** Please use a unique name for each distinct function.+
+ SBVTestSuite/GoldFiles/smtFuncUniq_recursiveConflict.gold view
@@ -0,0 +1,9 @@++*** Data.SBV: Function 'f @(SBV Integer -> SBV Integer)' defined with conflicting bodies.+***+*** Two calls to smtFunction (or related) used the name 'f @(SBV Integer -> SBV Integer)'+*** but with different definitions. This would generate conflicting+*** SMTLib define-fun-rec declarations.+***+*** Please use a unique name for each distinct function.+
+ SBVTestSuite/GoldFiles/smtFuncUniq_recursiveOk.gold view
@@ -0,0 +1,131 @@+[MEASURE] Verifying termination measures for: f @(SBV Integer -> SBV Integer)+[MEASURE] Checking: f @(SBV Integer -> SBV Integer)+[MEASURE] f @(SBV Integer -> SBV Integer): barified = "|f @(SBV Integer -> SBV Integer)|"+[MEASURE] f @(SBV Integer -> SBV Integer): Uninterpreted ops in DAG: [("|f @(SBV Integer -> SBV Integer)|",1)]+[MEASURE] f @(SBV Integer -> SBV Integer): recursive calls found = 1+[MEASURE] f @(SBV Integer -> SBV Integer): trying abs arg1+[MEASURE] replayDAG {f @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Bool (>= s8 s1))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s9))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] replayDAG {f @(SBV Integer -> SBV Integer)}: replaying 5 node(s)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s2 () Int 1)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int) ; tracks user variable "arg"+[GOOD] (declare-fun s5 () Int) ; tracks user variable "__internal_sbv_s5"+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; --- assignments ---+[GOOD] (define-fun s3 () Bool (<= s0 s1))+[GOOD] (define-fun s4 () Int (- s0 s2))+[GOOD] (define-fun s6 () Int (+ s0 s5))+[GOOD] (define-fun s7 () Int (ite s3 s1 s6))+[GOOD] (define-fun s8 () Int (abs s0))+[GOOD] (define-fun s9 () Int (abs s4))+[GOOD] (define-fun s10 () Bool (not s3))+[GOOD] (define-fun s11 () Bool (> s8 s9))+[GOOD] (define-fun s12 () Bool (=> s10 s11))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert (not s12))+[SEND] (check-sat)+[RECV] unsat+*** Solver : Z3+*** Exit code: ExitSuccess+[MEASURE] f @(SBV Integer -> SBV Integer): abs arg1 -> OK+[MEASURE] Passed (terminating): f @(SBV Integer -> SBV Integer)+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s1 () Int 0)+[GOOD] (define-fun s3 () Int 3)+[GOOD] (define-fun s6 () Int 6)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |f @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger [Recursive]+[GOOD] (define-fun-rec |f @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int+ (let ((l1_s1 0))+ (let ((l1_s3 1))+ (let ((l1_s2 (<= l1_s0 l1_s1)))+ (let ((l1_s4 (- l1_s0 l1_s3)))+ (let ((l1_s5 (|f @(SBV Integer -> SBV Integer)| l1_s4)))+ (let ((l1_s6 (+ l1_s0 l1_s5)))+ (let ((l1_s7 (ite l1_s2 l1_s1 l1_s6)))+ l1_s7))))))))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s2 () Bool (>= s0 s1))+[GOOD] (define-fun s4 () Bool (<= s0 s3))+[GOOD] (define-fun s5 () Int (|f @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s7 () Bool (= s5 s6))+[GOOD] (define-fun s8 () Bool (and s4 s7))+[GOOD] (define-fun s9 () Bool (and s2 s8))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s9)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 3))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 3 :: Integer
+ SBVTestSuite/GoldFiles/smtFuncUniq_sameOk.gold view
@@ -0,0 +1,40 @@+** Calling: z3 -nw -in -smt2+[GOOD] ; Automatically generated by SBV. Do not edit.+[GOOD] (set-option :print-success true)+[GOOD] (set-option :global-declarations true)+[GOOD] (set-option :smtlib2_compliant true)+[GOOD] (set-option :diagnostic-output-channel "stdout")+[GOOD] (set-option :produce-models true)+[GOOD] (set-logic ALL) ; has unbounded values, using catch-all.+[GOOD] ; --- tuples ---+[GOOD] ; --- sums ---+[GOOD] ; --- literal constants ---+[GOOD] (define-fun s3 () Int 4)+[GOOD] ; --- top level inputs ---+[GOOD] (declare-fun s0 () Int)+[GOOD] ; --- constant tables ---+[GOOD] ; --- non-constant tables ---+[GOOD] ; --- uninterpreted constants ---+[GOOD] ; --- user defined functions ---+[GOOD] ; |f @(SBV Integer -> SBV Integer)| :: SInteger -> SInteger+[GOOD] (define-fun |f @(SBV Integer -> SBV Integer)| ((l1_s0 Int)) Int+ (let ((l1_s1 1))+ (let ((l1_s2 (+ l1_s0 l1_s1)))+ l1_s2)))+[GOOD] ; --- assignments ---+[GOOD] (define-fun s1 () Int (|f @(SBV Integer -> SBV Integer)| s0))+[GOOD] (define-fun s2 () Int (+ s1 s1))+[GOOD] (define-fun s4 () Bool (= s2 s3))+[GOOD] ; --- delayedEqualities ---+[GOOD] ; --- formula ---+[GOOD] (assert s4)+[SEND] (check-sat)+[RECV] sat+[SEND] (get-value (s0))+[RECV] ((s0 1))+*** Solver : Z3+*** Exit code: ExitSuccess++RESULT:+Satisfiable. Model:+ s0 = 1 :: Integer
+ SBVTestSuite/GoldFiles/tpCache_alias.gold view
@@ -0,0 +1,3 @@+Lemma: nameA Q.E.D.+Lemma: nameB Q.E.D.+Cached: nameC Q.E.D. (a.k.a. nameA, nameB)
+ SBVTestSuite/GoldFiles/tpCache_calcCollapse.gold view
@@ -0,0 +1,4 @@+Lemma: addZero+ Step: 1 Q.E.D.+ Result: Q.E.D.+Cached: addZero Q.E.D.
+ SBVTestSuite/GoldFiles/tpCache_hit.gold view
@@ -0,0 +1,2 @@+Lemma: fact Q.E.D.+Cached: fact Q.E.D.
+ SBVTestSuite/GoldFiles/tpCache_miss.gold view
@@ -0,0 +1,1 @@+Lemma: fact Q.E.D.
+ SBVTestSuite/GoldFiles/tpCache_nested.gold view
@@ -0,0 +1,3 @@+Lemma: inner Q.E.D.+Lemma: outer Q.E.D.+Cached: outer Q.E.D. (a.k.a. inner)
+ SBVTestSuite/GoldFiles/tpCache_statsHit.gold view
@@ -0,0 +1,4 @@+Lemma: addZero+ Step: 1 Q.E.D.+ Result: Q.E.D.+Cached: addZero Q.E.D.
+ SBVTestSuite/GoldFiles/tpCache_statsMiss.gold view
@@ -0,0 +1,3 @@+Lemma: addZero+ Step: 1 Q.E.D.+ Result: Q.E.D.
+ SBVTestSuite/GoldFiles/tpCache_statsNested.gold view
@@ -0,0 +1,4 @@+Lemma: inner Q.E.D.+Lemma: outer Q.E.D.+Cached: inner Q.E.D. (a.k.a. outer)+Cached: outer Q.E.D. (a.k.a. inner)
SBVTestSuite/GoldFiles/tuple_enum.gold view
@@ -23,7 +23,6 @@ )) [GOOD] ; --- literal constants --- [GOOD] (define-fun s3 () Int 1)-[GOOD] (define-fun s6 () (Seq Bool) (seq.unit true)) [GOOD] (define-fun s11 () Int 3) [GOOD] (define-fun s13 () Int 2) [GOOD] (define-fun s16 () E (as C E))@@ -40,6 +39,7 @@ [GOOD] (define-fun s2 () Bool (not s1)) [GOOD] (define-fun s4 () (SBVTuple2 E (Seq Bool)) (seq.nth s0 s3)) [GOOD] (define-fun s5 () (Seq Bool) (proj_2_SBVTuple2 s4))+[GOOD] (define-fun s6 () (Seq Bool) (seq.unit true)) [GOOD] (define-fun s7 () (Seq Bool) (seq.unit s1)) [GOOD] (define-fun s8 () (Seq Bool) (seq.++ s6 s7)) [GOOD] (define-fun s9 () Bool (= s5 s8))
SBVTestSuite/SBVTest.hs view
@@ -47,7 +47,9 @@ import qualified TestSuite.Basics.QRem import qualified TestSuite.Basics.Quantifiers import qualified TestSuite.Basics.Recursive+import qualified TestSuite.Basics.TPCaching import qualified TestSuite.Basics.Set+import qualified TestSuite.Basics.SmtFunctionUnique import qualified TestSuite.Basics.SmallShifts import qualified TestSuite.Basics.SquashReals import qualified TestSuite.Basics.String@@ -170,7 +172,9 @@ , TestSuite.Basics.QRem.tests , TestSuite.Basics.Quantifiers.tests , TestSuite.Basics.Recursive.tests+ , TestSuite.Basics.TPCaching.tests , TestSuite.Basics.Set.tests+ , TestSuite.Basics.SmtFunctionUnique.tests , TestSuite.Basics.SmallShifts.tests , TestSuite.Basics.SquashReals.tests , TestSuite.Basics.String.tests
SBVTestSuite/TestSuite/ADT/Expr.hs view
@@ -283,7 +283,7 @@ _ -> error $ "Unexpected: " ++ show cs f :: SExpr -> SInteger-f e = [sCase|Expr e of+f e = [sCase| e of Var s | s .== literal "a" -> 0 | s .== literal "b" .|| s .== literal "c" -> 1 | sTrue -> 2@@ -318,7 +318,7 @@ _ -> error $ "Unexpected: " ++ show cs g :: SExpr -> SInteger-g e = [sCase|Expr e of+g e = [sCase| e of Var s | s .== literal "a" -> 0 | s .== literal "b" .|| s .== literal "c" -> 1 | sTrue -> 2@@ -350,7 +350,7 @@ t :: SA -> SA t = smtFunction "t" $ \a ->- [sCase|A a of+ [sCase| a of A u -> sA (u+1) B w -> sB (w+2) C a1 a2 -> sC (t a1) (t a2)@@ -364,7 +364,7 @@ -- Mul (Val 0) _ => 0 -- otherwise => identity h :: SExpr -> SExpr-h e = [sCase|Expr e of+h e = [sCase| e of Add (Val i) r | i .== 0 -> r Add l (Val i) | i .== 0 -> l Mul (Val i) r | i .== 1 -> r@@ -394,7 +394,7 @@ -- | A constant-folder using a deeply nested pattern: recognizes Add (Mul (Val a) (Val b)) (Mul (Val c) (Val d)) -- and folds it to Val (a*b + c*d). All four leaf positions use nested Val patterns simultaneously. cfold :: SExpr -> SExpr-cfold e = [sCase|Expr e of+cfold e = [sCase| e of Add (Mul (Val a) (Val b)) (Mul (Val c) (Val d)) -> sVal (a*b + c*d) _ -> e |]@@ -411,7 +411,7 @@ -- Add (Val 0) r => eval r (nested integer literal) -- _ => eval e (fallthrough) p :: SExpr -> SInteger-p e = [sCase|Expr e of+p e = [sCase| e of Val 0 -> 100 Val 1 -> 200 Add (Val 0) r -> eval r
SBVTestSuite/TestSuite/ADT/MutRec.hs view
@@ -83,20 +83,22 @@ where isId s = s `match` (asciiLower * KStar (asciiLetter + digit)) goE :: SList String -> SExpr String val -> SBool- goE = smtFunction "validE" $ \env expr -> [sCase|Expr expr of- Con _ -> sTrue- Var s -> isId s .&& s `SL.elem` env- Add l r -> goE env l .&& goE env r- Mul l r -> goE env l .&& goE env r- |]+ goE = smtFunction "validE"+ $ \env expr -> [sCase| expr of+ Con _ -> sTrue+ Var s -> isId s .&& s `SL.elem` env+ Add l r -> goE env l .&& goE env r+ Mul l r -> goE env l .&& goE env r+ |] goS :: SList String -> SStmt String val -> STuple Bool [String]- goS = smtFunction "validS" $ \env stmt -> [sCase|Stmt stmt of- Assign v e -> tuple (isId v .&& goE env e, v SL..: env)- Seq a b -> let (lv, env') = untuple $ goS env a- (rv, env'') = untuple $ goS env' b- in tuple (lv .&& rv, env'')- |]+ goS = smtFunction "validS"+ $ \env stmt -> [sCase| stmt of+ Assign v e -> tuple (isId v .&& goE env e, v SL..: env)+ Seq a b -> let (lv, env') = untuple $ goS env a+ (rv, env'') = untuple $ goS env' b+ in tuple (lv .&& rv, env'')+ |] tests :: TestTree tests =
SBVTestSuite/TestSuite/ADT/PExpr.hs view
@@ -156,7 +156,7 @@ _ -> error $ "Unexpected: " ++ show cs f :: SExpr String Integer -> SInteger-f e = [sCase|Expr e of+f e = [sCase| e of Var s | s .== literal "a" -> 0 | s .== literal "b" .|| s .== literal "c" -> 1 | sTrue -> 2@@ -175,7 +175,7 @@ -- such that it evaluates to 12 t00 :: FilePath -> IO () t00 rf = runSMTWith z3{verbose=True, redirectVerbose = Just rf} $ do- a :: SExpr String Word16 <- free "a"+ a :: SExpr String Integer <- free "a" constrain $ isValid isId a constrain $ eval a .== 12 @@ -191,7 +191,7 @@ _ -> error $ "Unexpected: " ++ show cs g :: (SymVal val, OrdSymbolic (SBV val), Num (SBV val)) => SExpr String val -> SInteger-g e = [sCase|Expr e of+g e = [sCase| e of Var s | s .== literal "a" -> 0 | s .== literal "b" .|| s .== literal "c" -> 1 | sTrue -> 2@@ -210,7 +210,7 @@ -- Show that g can never produce anything but 0..8 tSat :: Integer -> FilePath -> IO () tSat i rf = runSMTWith z3{verbose=True, redirectVerbose = Just rf} $ do- a :: SExpr String Word16 <- free "a"+ a :: SExpr String Integer <- free "a" constrain $ g a .== literal i query $ do cs <- checkSat@@ -223,7 +223,7 @@ t :: SA -> SA t = smtFunction "t" $ \a ->- [sCase|A a of+ [sCase| a of A u -> sA (u+1) B w -> sB (w+2) C a1 a2 -> sC (t a1) (t a2)
SBVTestSuite/TestSuite/Basics/ArithSolver.hs view
@@ -877,7 +877,7 @@ rs :: [Ratio Integer] rs = [i % d | i <- is, d <- dens]- where is = [-1000000] ++ [-1 .. 1] ++ [10000001]+ where is = [-1000000] ++ [-1 .. 1] ++ [1000001] dens = [5,100,1000000] -- Admittedly paltry test-cases for float/double
SBVTestSuite/TestSuite/Basics/Lambda.hs view
@@ -110,7 +110,8 @@ , \a b -> P.foldr (+) 0 (P.zipWith (+) a b) ) - , goldenCapturedIO "lambda26" $ eval1 ([[1..5], [1..10], [1..20]] :: [[Integer]]) (concat, P.concat)+ -- Disabled due to z3 bug: https://github.com/LeventErkok/sbv/issues/773+ -- , goldenCapturedIO "lambda26" $ eval1 ([[1..5], [1..10], [1..20]] :: [[Integer]]) (concat, P.concat) , goldenCapturedIO "lambda27" $ eval1 [2, 4, 6, 8, 10 :: Integer] (all (\x -> x `sMod` 2 .== 0), P.all (\x -> x `mod` 2 == 0)) , goldenCapturedIO "lambda28" $ eval1 [2, 4, 6, 1, 8, 10 :: Integer] (all (\x -> x `sMod` 2 .== 0), P.all (\x -> x `mod` 2 == 0))@@ -158,7 +159,7 @@ , goldenCapturedIO "lambda52_c" $ runSat (isOdd 21 .==) -- make sure we can pass globals- , goldenCapturedIO "lambda53" $ runSat $ \x -> x .== smtFunction "foo" (+(x::SInteger)) x+ , goldenCapturedIO "lambda53" $ runS $ \x -> x .== smtFunction "foo" (+(x::SInteger)) x -- Make sure we can handle dependency orders , goldenCapturedIO "lambda54" $ runSat $ \x -> let foo = smtFunction "foo" (\a -> bar a + 1)@@ -175,6 +176,23 @@ f3 = smtFunction "f3" (\a -> ite (a .== 0) 0 (1 + (f3 (a-1) + f4 (a-2)))) f4 = smtFunction "f4" (\a -> ite (a .== 0) 0 (1 + (f4 (a-1) + f1 (a-2)))) in f1 x .== (x :: SWord8)+ , goldenCapturedIO "lambda57a" $ runSat $ \x -> let f1 = smtFunction "f1i" (\a -> ite (a .<= 0) 0 (1 + (f1 (a-1) + f2 (a-2))))+ f2 = smtFunction "f2i" (\a -> ite (a .<= 0) 0 (1 + (f2 (a-1) + f3 (a-2))))+ f3 = smtFunction "f3i" (\a -> ite (a .<= 0) 0 (1 + (f3 (a-1) + f4 (a-2))))+ f4 = smtFunction "f4i" (\a -> ite (a .<= 0) 0 (1 + (f4 (a-1) + f1 (a-2))))+ in f1 x .== (x :: SInteger)+ , goldenCapturedIO "lambda57b" $ runSat $ \x -> let m a = 0 `smax` a :: SInteger+ f1 = smtFunctionWithMeasure "f1m" (m, []) (\a -> ite (a .<= 0) 0 (1 + (f1 (a-1) + f2 (a-2))))+ f2 = smtFunctionWithMeasure "f2m" (m, []) (\a -> ite (a .<= 0) 0 (1 + (f2 (a-1) + f3 (a-2))))+ f3 = smtFunctionWithMeasure "f3m" (m, []) (\a -> ite (a .<= 0) 0 (1 + (f3 (a-1) + f4 (a-2))))+ f4 = smtFunctionWithMeasure "f4m" (m, []) (\a -> ite (a .<= 0) 0 (1 + (f4 (a-1) + f1 (a-2))))+ in f1 x .== (x :: SInteger)+ , goldenCapturedIO "lambda57c" $ runSat $ \x -> let m = sFromIntegral :: SWord8 -> SInteger+ f1 = smtFunctionWithMeasure "f1w" (m, []) (\a -> ite (a .== 0) 0 (1 + (f1 (a-1) + f2 (a-2))))+ f2 = smtFunctionWithMeasure "f2w" (m, []) (\a -> ite (a .== 0) 0 (1 + (f2 (a-1) + f3 (a-2))))+ f3 = smtFunctionWithMeasure "f3w" (m, []) (\a -> ite (a .== 0) 0 (1 + (f3 (a-1) + f4 (a-2))))+ f4 = smtFunctionWithMeasure "f4w" (m, []) (\a -> ite (a .== 0) 0 (1 + (f4 (a-1) + f1 (a-2))))+ in f1 x .== (x :: SWord8) -- Quantified axioms , goldenCapturedIO "lambda58" $ record $ \st -> constraintStr st $ \(Forall b) (Exists c) -> sNot b .|| c@@ -263,6 +281,7 @@ , \xs ys -> P.map (\x -> P.map (\y -> x + y) xs) ys ) + {- Disabled due to z3 bug: https://github.com/LeventErkok/sbv/issues/773 , let cls :: SList Integer -> Closure (SList Integer) (SList Integer -> SList Integer) cls ys = Closure { closureEnv = ys , closureFun = \env xs -> xs ++ env@@ -271,6 +290,7 @@ ( \xss ys -> map (cls ys) xss , \xss ys -> P.map (P.++ ys) xss )+ -} ] P.++ qc1 "lambdaQC1" P.sum (foldr ((+) @SInteger) (0::SInteger)) P.++ qc2 "lambdaQC2" (+) (smtFunction "sadd" ((+) :: SInteger -> SInteger -> SInteger))
SBVTestSuite/TestSuite/Basics/Recursive.hs view
@@ -9,6 +9,12 @@ -- Some recursive definitions. ----------------------------------------------------------------------------- +{-# LANGUAGE DataKinds #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+ {-# OPTIONS_GHC -Wall -Werror #-} module TestSuite.Basics.Recursive(tests) where@@ -17,12 +23,24 @@ import Data.SBV.Internals (genMkSymVar, unSBV, VarContext(..)) +import Data.List (isInfixOf)++import qualified Data.SBV.List as L import qualified Data.SBV.Dynamic as D+import Data.SBV.TP (runTPWith, lemma) --- This is recursive and suffers from the termination problem.+import qualified Control.Exception as C++import Documentation.SBV.Examples.Misc.Definitions (ack)+import Documentation.SBV.Examples.TP.McCarthy91 (mcCarthy91)++-- This is recursive and can't be symbolically simulated for arbitrary inputs. -- But we can still prove a few things about it! mgcd :: SWord8 -> SWord8 -> SWord8-mgcd a b = ite (b .== 0) a (mgcd b (a `sMod` b))+mgcd a b = [sCase| b of+ _ | b .== 0 -> a+ _ -> mgcd b (a `sMod` b)+ |] -- Same construction, expressed in terms of the dynamic interface mgcdDyn :: Int -> IO ThmResult@@ -50,11 +68,402 @@ ThmResult Satisfiable{} -> return False _ -> error "checkThm: Unexpected result!" +-- | Test that auto-guess succeeds for an integer-recursive function (abs measure)+autoGuessInteger :: Assertion+autoGuessInteger = assertIsSat $ \(x :: SInteger) -> f x .== x+ where f :: SInteger -> SInteger+ f = smtFunction "autoGuessIntF" $ \x -> ite (x .<= 0) 0 (1 + f (x - 1))++-- | Test that auto-guess succeeds for a list-recursive function (length measure)+autoGuessList :: Assertion+autoGuessList = assertIsSat $ \(xs :: SList Integer) -> myLen xs .>= 0+ where myLen :: SList Integer -> SInteger+ myLen = smtFunction "autoGuessListLen" $ \xs ->+ ite (L.null xs) 0 (1 + myLen (L.tail xs))++-- | Test that auto-guess fails when candidates exist but don't work (Ackermann)+autoGuessFailCandidates :: Assertion+autoGuessFailCandidates = do+ r <- C.try $ sat $ \(x :: SInteger) (y :: SInteger) -> ack' x y .== 0+ case r of+ Left (e :: C.SomeException) -> if "Cannot determine a termination measure" `isInfixOf` show e+ then pure ()+ else assertFailure $ "Unexpected exception: " ++ show e+ Right _ -> assertFailure "Expected error for Ackermann auto-guess"+ where ack' :: SInteger -> SInteger -> SInteger+ ack' = smtFunction "ackermann" $ \m n ->+ ite (m .== 0) (n + 1)+ (ite (n .== 0) (ack' (m - 1) 1)+ (ack' (m - 1) (ack' m (n - 1))))++-- | Test that auto-guess fails when no candidates can be derived (non-integer, non-list args)+autoGuessNoCandidates :: Assertion+autoGuessNoCandidates = do+ r <- C.try $ sat $ \(b :: SBool) -> h b .== 0+ case r of+ Left (e :: C.SomeException) -> if "No measure candidates" `isInfixOf` show e+ then pure ()+ else assertFailure $ "Unexpected exception: " ++ show e+ Right _ -> assertFailure "Expected error for no-candidate auto-guess"+ where h :: SBool -> SInteger+ h = smtFunction "noCandidate" $ \b -> ite b (1 + h (sNot b)) 0++-- | Test that a non-recursive smtFunction without a measure is accepted+nonRecursiveNoMeasure :: Assertion+nonRecursiveNoMeasure = assertIsSat $ \(x :: SInteger) -> g x .== 4+ where g :: SInteger -> SInteger+ g = smtFunction "nonRecG" $ \x -> 2 * x+ -- Test suite tests :: TestTree tests = testGroup "Basics.Recursive"- [ testCase "recursive1" $ assertIsThm $ \x -> mgcd 0 x .== x- , testCase "recursive2" $ assertIsThm $ \x -> mgcd x 0 .== x- , testCase "recursiveDyn1" $ checkThm =<< mgcdDyn 0- , testCase "recursiveDyn2" $ checkThm =<< mgcdDyn 1+ [ testCase "recursive1" $ assertIsThm $ \x -> mgcd 0 x .== x+ , testCase "recursive2" $ assertIsThm $ \x -> mgcd x 0 .== x+ , testCase "recursiveDyn1" $ checkThm =<< mgcdDyn 0+ , testCase "recursiveDyn2" $ checkThm =<< mgcdDyn 1+ , testCase "autoGuessInteger" autoGuessInteger+ , testCase "autoGuessList" autoGuessList+ , testCase "autoGuessFailCandidates" autoGuessFailCandidates+ , testCase "autoGuessNoCandidates" autoGuessNoCandidates+ , testCase "nonRecursiveNoMeasure" nonRecursiveNoMeasure++ -- Test that an explicit measure that doesn't decrease is rejected+ , goldenCapturedIO "recursive3_badMeasure" $ \rf -> do+ let badSum :: SInteger -> SInteger+ badSum = smtFunctionWithMeasure "badSum" (\_ -> 1 :: SInteger, [])+ $ \x -> ite (x .<= 0) 0 (x + badSum (x - 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> badSum x .>= 0+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that lexicographic measure auto-guess works for Ackermann (nested recursion)+ , goldenCapturedIO "recursive1_ack" $ \rf -> do+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \y r -> y .== (5 :: SInteger) .&& r .== ack 1 y+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that explicit measure works for enumFromThenTo.down (descending enumeration)+ , goldenCapturedIO "recursive2_enum" $ \rf -> do+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> L.length [sEnum|(5::SInteger), 4 .. x|] .>= 0+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that contract-based measure works for McCarthy91 (nested recursion)+ , goldenCapturedIO "recursive4_mcCarthy91" $ \rf -> do+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> mcCarthy91 n .== (91 :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that a bad contract is rejected (contract says result is always 0, which is wrong)+ , goldenCapturedIO "recursive5_badContract" $ \rf -> do+ let mc91bad :: SInteger -> SInteger+ mc91bad = smtFunctionWithContract "mc91bad"+ ( \n -> 0 `smax` (101 - n)+ , \_ r -> r .== 0+ , []+ )+ $ \n -> ite (n .> 100) (n - 10) (mc91bad (mc91bad (n + 11)))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> mc91bad n .>= 0+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that a true-but-useless contract is rejected (contract is trivially True,+ -- so the IH provides no information about recursive call results, and the measure+ -- decrease for the outer call can't be proven)+ , goldenCapturedIO "recursive6_uselessContract" $ \rf -> do+ let mc91triv :: SInteger -> SInteger+ mc91triv = smtFunctionWithContract "mc91triv"+ ( \n -> 0 `smax` (101 - n)+ , \_ _ -> sTrue+ , []+ )+ $ \n -> ite (n .> 100) (n - 10) (mc91triv (mc91triv (n + 11)))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> mc91triv n .>= 0+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that a productive function (guarded recursion) is accepted+ , goldenCapturedIO "recursive7_productive" $ \rf -> do+ let rep :: SInteger -> SInteger -> SList Integer+ rep = smtProductiveFunction "rep" $ \n x ->+ ite (n .<= 0) L.nil (x L..: rep (n - 1) x)+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> L.length (rep 3 x) .== 3+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that a non-guarded function marked productive is rejected+ , goldenCapturedIO "recursive8_badProductive" $ \rf -> do+ let bad :: SInteger -> SInteger+ bad = smtProductiveFunction "bad" $ \n -> ite (n .== 0) 0 (1 + bad (n - 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> bad n .>= 0+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that a multi-arg productive function (guarded recursion) is accepted+ , goldenCapturedIO "recursive9_productive2" $ \rf -> do+ let countdown :: SInteger -> SList Integer+ countdown = smtProductiveFunction "countdown" $ \n ->+ ite (n .<= 0) (L.singleton 0) (n L..: countdown (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> L.head (countdown n) .== (n :: SInteger) .&& n .> 0+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test mutual recursion (2-way): mf calls mg, mg calls mf, neither is self-recursive.+ -- No measure check should fire. The SMTLib emission should use define-funs-rec.+ , goldenCapturedIO "recursive10_mutual" $ \rf -> do+ let mf :: SInteger -> SInteger+ mf = smtFunction "mf" $ \n -> ite (n .<= 0) 0 (1 + mg (n - 1))+ mg :: SInteger -> SInteger+ mg = smtFunction "mg" $ \n -> ite (n .<= 0) 0 (1 + mf (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> mf x .== (x :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test chain recursion (3-way): ca calls cb, cb calls cc, cc calls ca.+ -- No measure check should fire. The SMTLib emission should use define-funs-rec.+ , goldenCapturedIO "recursive11_chain" $ \rf -> do+ let ca :: SInteger -> SInteger+ ca = smtFunction "ca" $ \n -> ite (n .<= 0) 0 (1 + cb (n - 1))+ cb :: SInteger -> SInteger+ cb = smtFunction "cb" $ \n -> ite (n .<= 0) 0 (1 + cc (n - 1))+ cc :: SInteger -> SInteger+ cc = smtFunction "cc" $ \n -> ite (n .<= 0) 0 (1 + ca (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> ca x .== (x :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test bad mutual recursion: bf calls bg with (n+1), so no measure can decrease.+ , goldenCapturedIO "recursive12_badMutual" $ \rf -> do+ let bf :: SInteger -> SInteger+ bf = smtFunction "bf" $ \n -> ite (n .<= 0) 0 (1 + bg (n + 1))+ bg :: SInteger -> SInteger+ bg = smtFunction "bg" $ \n -> ite (n .<= 0) 0 (1 + bf (n - 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> bf x .== (x :: SInteger)+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test mutual recursion with explicit measures: ef calls eg, eg calls ef, both decreasing.+ , goldenCapturedIO "recursive13_mutualMeasure" $ \rf -> do+ let ef :: SInteger -> SInteger+ ef = smtFunctionWithMeasure "ef" (abs, [])+ $ \n -> ite (n .<= 0) 0 (1 + eg (n - 1))+ eg :: SInteger -> SInteger+ eg = smtFunctionWithMeasure "eg" (abs, [])+ $ \n -> ite (n .<= 0) 0 (1 + ef (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> ef x .== (x :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test mutual recursion with explicit measure that fails: constant measure doesn't decrease.+ , goldenCapturedIO "recursive14_badMutualMeasure" $ \rf -> do+ let hf :: SInteger -> SInteger+ hf = smtFunctionWithMeasure "hf" (\_ -> 1 :: SInteger, [])+ $ \n -> ite (n .<= 0) 0 (1 + hg (n - 1))+ hg :: SInteger -> SInteger+ hg = smtFunctionWithMeasure "hg" (\_ -> 1 :: SInteger, [])+ $ \n -> ite (n .<= 0) 0 (1 + hf (n - 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> hf x .== (x :: SInteger)+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test mixed mutual recursion: xf has explicit measure, xg uses auto-guess.+ -- xf's user-provided measure (abs n) is tried first and works for the whole group.+ , goldenCapturedIO "recursive15_mixedMutualMeasure" $ \rf -> do+ let xf :: SInteger -> SInteger+ xf = smtFunctionWithMeasure "xf" (abs, [])+ $ \n -> ite (n .<= 0) 0 (1 + xg (n - 1))+ xg :: SInteger -> SInteger+ xg = smtFunction "xg"+ $ \n -> ite (n .<= 0) 0 (1 + xf (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> xf x .== (x :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test bad mixed mutual recursion: yf has explicit measure but yg calls yf with (n+1).+ -- The user-provided measure fails, and auto-guess also fails.+ , goldenCapturedIO "recursive16_badMixedMutualMeasure" $ \rf -> do+ let yf :: SInteger -> SInteger+ yf = smtFunctionWithMeasure "yf" (abs, [])+ $ \n -> ite (n .<= 0) 0 (1 + yg (n - 1))+ yg :: SInteger -> SInteger+ yg = smtFunction "yg"+ $ \n -> ite (n .<= 0) 0 (1 + yf (n + 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> yf x .== (x :: SInteger)+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test 3-way chain with explicit measures: da calls db, db calls dc, dc calls da, all with abs measure.+ , goldenCapturedIO "recursive17_chainMeasure" $ \rf -> do+ let da :: SInteger -> SInteger+ da = smtFunctionWithMeasure "da" (abs, [])+ $ \n -> ite (n .<= 0) 0 (1 + db (n - 1))+ db :: SInteger -> SInteger+ db = smtFunctionWithMeasure "db" (abs, [])+ $ \n -> ite (n .<= 0) 0 (1 + dc (n - 1))+ dc :: SInteger -> SInteger+ dc = smtFunctionWithMeasure "dc" (abs, [])+ $ \n -> ite (n .<= 0) 0 (1 + da (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> da x .== (x :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test mutual recursion with different arg types: tf takes Integer, tg takes a list.+ -- Auto-guess fails because no single measure applies to both signatures.+ , testCase "diffTypeMutual" $ do+ let tf :: SInteger -> SInteger+ tf = smtFunction "tf" $ \n -> ite (n .<= 0) 0 (1 + tg (L.singleton n))+ tg :: SList Integer -> SInteger+ tg = smtFunction "tg" $ \xs -> ite (L.null xs) 0 (tf (L.head xs - 1))+ r <- C.try $ sat $ \(x :: SInteger) -> tf x .== 0+ case r of+ Left (e :: C.SomeException) -> if "Cannot determine a termination measure" `isInfixOf` show e+ then pure ()+ else assertFailure $ "Unexpected exception: " ++ show e+ Right _ -> assertFailure "Expected error for different-type mutual recursion"++ -- Test self-recursive + mutual: sf calls itself AND sg. Both paths should be checked.+ , goldenCapturedIO "recursive19_selfAndMutual" $ \rf -> do+ let sf :: SInteger -> SInteger+ sf = smtFunction "sf" $ \n -> ite (n .<= 0) 0 (sf (n - 1) + sg (n - 1))+ sg :: SInteger -> SInteger+ sg = smtFunction "sg" $ \n -> ite (n .<= 0) 0 (1 + sf (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> sf x .== (x :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test all-self-recursive mutual group with bad cross-calls:+ -- bf and bg both self-recurse (n-1), but cross-call with (n+1).+ -- Self-recursion checks pass, but mutual group check must catch the bad cross-calls.+ , goldenCapturedIO "recursive21_allSelfBadCross" $ \rf -> do+ let bf :: SInteger -> SInteger+ bf = smtFunction "bf21" $ \n -> ite (n .<= 0) 0 (bf (n - 1) + bg (n + 1))+ bg :: SInteger -> SInteger+ bg = smtFunction "bg21" $ \n -> ite (n .<= 0) 0 (bg (n - 1) + bf (n + 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> bf x .== (x :: SInteger)+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test all-self-recursive mutual group with good cross-calls and explicit measures:+ -- Both bf and bg self-recurse and cross-call with (n-1). User-provided abs measure works.+ , goldenCapturedIO "recursive22_allSelfGoodCross" $ \rf -> do+ let bf :: SInteger -> SInteger+ bf = smtFunctionWithMeasure "bf22" (abs, []) $ \n -> ite (n .<= 0) 0 (bf (n - 1) + bg (n - 1))+ bg :: SInteger -> SInteger+ bg = smtFunctionWithMeasure "bg22" (abs, []) $ \n -> ite (n .<= 0) 0 (bg (n - 1) + bf (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> bf x .== (x :: SInteger)+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test mutual recursion via TP proofs (exercises checkNewMeasures in Kernel.hs)+ , goldenCapturedIO "recursive20_mutualTP" $ \rf -> do+ let cfg = z3{verbose=True, redirectVerbose=Just rf}+ mf :: SInteger -> SInteger+ mf = smtFunction "mf_tp" $ \n -> ite (n .<= 0) 0 (1 + mg (n - 1))+ mg :: SInteger -> SInteger+ mg = smtFunction "mg_tp" $ \n -> ite (n .<= 0) 0 (1 + mf (n - 1))+ _ <- runTPWith cfg $+ lemma "mutual_at_0"+ (\(Forall @"n" n) -> n .== 0 .=> mf n .== 0)+ []+ pure ()++ -- Test mutual productive functions (guarded cross-calls): pf and pg build lists via each other.+ , goldenCapturedIO "recursive23_mutualProductive" $ \rf -> do+ let pf :: SInteger -> SList Integer+ pf = smtProductiveFunction "pf23" $ \n ->+ ite (n .<= 0) (L.singleton 0) (n L..: pg (n - 1))+ pg :: SInteger -> SList Integer+ pg = smtProductiveFunction "pg23" $ \n ->+ ite (n .<= 0) (L.singleton 0) (n L..: pf (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> L.head (pf n) .== (n :: SInteger) .&& n .> 0+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test mutual productive functions with unguarded cross-call: bad_pg calls bad_pf without a constructor guard.+ , goldenCapturedIO "recursive24_badMutualProductive" $ \rf -> do+ let bad_pf :: SInteger -> SList Integer+ bad_pf = smtProductiveFunction "bad_pf" $ \n ->+ ite (n .<= 0) (L.singleton 0) (n L..: bad_pg (n - 1))+ bad_pg :: SInteger -> SList Integer+ bad_pg = smtProductiveFunction "bad_pg" $ \n ->+ ite (n .<= 0) (L.singleton 0) (bad_pf (n - 1)) -- not guarded!+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \(n :: SInteger) -> L.head (bad_pf n) .== n+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test that smtFunctionWithContract in a mutual group is rejected.+ , goldenCapturedIO "recursive25_contractMutualRejected" $ \rf -> do+ let cf :: SInteger -> SInteger+ cf = smtFunctionWithContract "cf_mut"+ ( \n -> 0 `smax` (101 - n)+ , \_ r -> r .== 91+ , []+ )+ $ \n -> ite (n .> 100) (n - 10) (cg (n + 11))+ cg :: SInteger -> SInteger+ cg = smtFunction "cg_mut" $ \n -> ite (n .<= 0) 0 (1 + cf (n - 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \(n :: SInteger) -> cf n .== 0+ case r of+ Left (e :: C.SomeException) -> appendFile rf ("\nEXCEPTION:\n" ++ show e ++ "\n")+ Right m -> appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test productive function that is both self-recursive and has cross-refs.+ -- spf calls itself AND spg, both guarded by L..:+ , goldenCapturedIO "recursive26_selfAndMutualProductive" $ \rf -> do+ let spf :: SInteger -> SList Integer+ spf = smtProductiveFunction "spf26" $ \n ->+ ite (n .<= 0) (L.singleton 0)+ (ite (sMod n 2 .== 0) (n L..: spf (n - 1))+ (n L..: spg (n - 1)))+ spg :: SInteger -> SList Integer+ spg = smtProductiveFunction "spg26" $ \n ->+ ite (n .<= 0) (L.singleton 0) (n L..: spf (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> L.head (spf n) .== (n :: SInteger) .&& n .> 0+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test 3-way mutually-recursive productive streams.+ -- pa -> pb -> pc -> pa, all guarded by L..:+ , goldenCapturedIO "recursive27_mutualProductive3" $ \rf -> do+ let pa :: SInteger -> SList Integer+ pa = smtProductiveFunction "pa27" $ \n ->+ ite (n .<= 0) (L.singleton 0) (n L..: pb (n - 1))+ pb :: SInteger -> SList Integer+ pb = smtProductiveFunction "pb27" $ \n ->+ ite (n .<= 0) (L.singleton 0) ((n * 10) L..: pc (n - 1))+ pc :: SInteger -> SList Integer+ pc = smtProductiveFunction "pc27" $ \n ->+ ite (n .<= 0) (L.singleton 0) ((n * 100) L..: pa (n - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \n -> L.head (pa n) .== (n :: SInteger) .&& n .> 0+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Test smtFunctionNoTermination: proofs show [Modulo: <name> termination]+ , goldenCapturedIO "recursive28_noTermCheck" $ \rf -> do+ let f :: SInteger -> SInteger+ f = smtFunctionNoTermination "ntc28" $ \n -> ite (n .<= 0) 0 (1 + f (n - 1))+ p <- runTPWith z3{verbose=True, redirectVerbose=Just rf} $+ lemma "ntc_at_5"+ (\(Forall @"n" n) -> n .== 5 .=> f n .== 5)+ []+ appendFile rf (show p ++ "\n") ]
+ SBVTestSuite/TestSuite/Basics/SmtFunctionUnique.hs view
@@ -0,0 +1,84 @@+-----------------------------------------------------------------------------+-- |+-- Module : TestSuite.Basics.SmtFunctionUnique+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer: erkokl@gmail.com+-- Stability : experimental+--+-- Tests for smtFunction name uniqueness enforcement.+-----------------------------------------------------------------------------++{-# LANGUAGE ScopedTypeVariables #-}++{-# OPTIONS_GHC -Wall -Werror #-}++module TestSuite.Basics.SmtFunctionUnique(tests) where++import Utils.SBVTestFramework++import qualified Control.Exception as C++-- Test suite+tests :: TestTree+tests = testGroup "Basics.SmtFunctionUnique"+ [+ -- Same name, same body: should succeed (idempotent re-registration).+ goldenCapturedIO "smtFuncUniq_sameOk" $ \rf -> do+ let f :: SInteger -> SInteger+ f = smtFunction "f" $ \x -> x + 1+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> f x + f x .== 4+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Same name, different body: should error.+ , goldenCapturedIO "smtFuncUniq_conflict" $ \rf -> do+ let f :: SInteger -> SInteger+ f = smtFunction "f" $ \x -> x + 1+ g :: SInteger -> SInteger+ g = smtFunction "f" $ \x -> x + 2+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> f x + g x .== 5+ case r of+ Left (e :: C.SomeException) -> appendFile rf (show e ++ "\n")+ Right m -> appendFile rf ("\nUNEXPECTED SUCCESS:\n" ++ show m ++ "\n")++ -- Same name, same recursive body: should succeed.+ , goldenCapturedIO "smtFuncUniq_recursiveOk" $ \rf -> do+ let f :: SInteger -> SInteger+ f = smtFunction "f" $ \x -> ite (x .<= 0) 0 (x + f (x - 1))+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> x .>= 0 .&& x .<= 3 .&& f x .== 6+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")++ -- Same name, different recursive body: should error.+ , goldenCapturedIO "smtFuncUniq_recursiveConflict" $ \rf -> do+ let f :: SInteger -> SInteger+ f = smtFunction "f" $ \x -> ite (x .<= 0) 0 (x + f (x - 1))+ g :: SInteger -> SInteger+ g = smtFunction "f" $ \x -> ite (x .<= 0) 1 (x * g (x - 1))+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> f x + g x .== 10+ case r of+ Left (e :: C.SomeException) -> appendFile rf (show e ++ "\n")+ Right m -> appendFile rf ("\nUNEXPECTED SUCCESS:\n" ++ show m ++ "\n")++ -- Same name via parameter capture: bar 2 and bar 3 create different closures+ -- for "bar", which should be detected as a conflict.+ , goldenCapturedIO "smtFuncUniq_captureConflict" $ \rf -> do+ let bar :: SInteger -> SInteger -> SInteger+ bar k = smtFunction "bar" (+ k)+ r <- C.try $ satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> bar 2 x + bar 3 x .== 10+ case r of+ Left (e :: C.SomeException) -> appendFile rf (show e ++ "\n")+ Right m -> appendFile rf ("\nUNEXPECTED SUCCESS:\n" ++ show m ++ "\n")++ -- Fix for the above: use a tag to give each instantiation a unique name.+ , goldenCapturedIO "smtFuncUniq_captureTagged" $ \rf -> do+ let bar :: String -> SInteger -> SInteger -> SInteger+ bar tag k = smtFunction ("bar_" ++ tag) (+ k)+ m <- satWith z3{verbose=True, redirectVerbose=Just rf} $+ \x -> bar "two" 2 x + bar "three" 3 x .== 10+ appendFile rf ("\nRESULT:\n" ++ show m ++ "\n")+ ]
+ SBVTestSuite/TestSuite/Basics/TPCaching.hs view
@@ -0,0 +1,138 @@+-----------------------------------------------------------------------------+-- |+-- Module : TestSuite.Basics.TPCaching+-- Copyright : (c) Levent Erkok+-- License : BSD3+-- Maintainer: erkokl@gmail.com+-- Stability : experimental+--+-- Tests for the TP proof caching mechanism.+-----------------------------------------------------------------------------++{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}++{-# OPTIONS_GHC -Wall -Werror #-}++module TestSuite.Basics.TPCaching(tests) where++import Utils.SBVTestFramework++import Data.SBV.TP (runTPWith, lemma, calc, recall, tpStats, (|-), (=:), qed)++import Control.Monad (void)++import Data.Char (isSpace)+import Data.List (isPrefixOf, dropWhileEnd)++import Control.DeepSeq (($!!))++-- | Strip timing info [0.05s] from the end of output lines.+stripTiming :: String -> String+stripTiming s+ | (_, rest@('[':_)) <- break (== '[') (dropWhileEnd isSpace s)+ , last rest == ']'+ = dropWhileEnd isSpace $ take (length s - length rest) s+ | True+ = s++-- | Filter out the statistics summary line from verbose output.+isStatsLine :: String -> Bool+isStatsLine s = "[SBV:" `isPrefixOf` dropWhile isSpace s++-- | Clean captured verbose output: strip timing and stats.+cleanStatsOutput :: String -> String+cleanStatsOutput = unlines . map stripTiming . filter (not . isStatsLine) . lines++-- Test suite+tests :: TestTree+tests = testGroup "Basics.TPCaching"+ [+ -- Normal mode: recall when cache is empty (cache miss).+ -- The proof runs from scratch; recallWith shows "Lemma:" one-liner.+ goldenCapturedIO "tpCache_miss" $ \rf -> do+ let cfg = z3 { redirectVerbose = Just rf }+ void $ runTPWith cfg $+ recall (lemma "fact" sTrue [])++ -- Normal mode: direct proof then recall (cache hit).+ -- The direct proof shows "Lemma:", the recall shows "Cached:".+ , goldenCapturedIO "tpCache_hit" $ \rf -> do+ let cfg = z3 { redirectVerbose = Just rf }+ void $ runTPWith cfg $ do+ _ <- lemma "fact" sTrue []+ recall (lemma "fact" sTrue [])++ -- Normal mode: same proposition proved under two names, then recalled (aliases).+ -- The recall shows "Cached:" with "(a.k.a. ...)" listing the other name.+ , goldenCapturedIO "tpCache_alias" $ \rf -> do+ let cfg = z3 { redirectVerbose = Just rf }+ void $ runTPWith cfg $ do+ _ <- lemma "nameA" sTrue []+ _ <- lemma "nameB" sTrue []+ recall (lemma "nameC" sTrue [])++ -- Normal mode: calc proof with steps, then recall (cache hit).+ -- The direct proof shows each step; the recall collapses to one line.+ , goldenCapturedIO "tpCache_calcCollapse" $ \rf -> do+ let cfg = z3 { redirectVerbose = Just rf }+ void $ runTPWith cfg $ do+ let addZeroProof = calc "addZero"+ (\(Forall @"x" (x :: SInteger)) -> x + 0 .== x) $+ \x -> [] |- x + 0+ =: (x :: SInteger)+ =: qed+ _ <- addZeroProof+ recall addZeroProof++ -- Normal mode: nested recall.+ -- First run proves inner and outer. Second run (via recall) hits cache for outer.+ , goldenCapturedIO "tpCache_nested" $ \rf -> do+ let cfg = z3 { redirectVerbose = Just rf }+ void $ runTPWith cfg $ do+ let myProof = do _ <- recall (lemma "inner" sTrue [])+ lemma "outer" sTrue []+ _ <- myProof+ recall myProof++ -- Stats mode: recall when cache is empty (cache miss).+ -- In stats mode, recall does NOT suppress inner output, so full proof steps are visible.+ , goldenCapturedIO "tpCache_statsMiss" $ \rf -> do+ let cfg = (tpStats z3) { redirectVerbose = Just rf }+ void $ runTPWith cfg $+ recall (calc "addZero"+ (\(Forall @"x" (x :: SInteger)) -> x + 0 .== x) $+ \x -> [] |- x + 0+ =: (x :: SInteger)+ =: qed)+ contents <- readFile rf+ writeFile rf $!! cleanStatsOutput contents++ -- Stats mode: direct proof then recall (cache hit).+ -- Direct proof shows full steps; recall shows "Cached:" one-liner.+ , goldenCapturedIO "tpCache_statsHit" $ \rf -> do+ let cfg = (tpStats z3) { redirectVerbose = Just rf }+ void $ runTPWith cfg $ do+ let addZeroProof = calc "addZero"+ (\(Forall @"x" (x :: SInteger)) -> x + 0 .== x) $+ \x -> [] |- x + 0+ =: (x :: SInteger)+ =: qed+ _ <- addZeroProof+ recall addZeroProof+ contents <- readFile rf+ writeFile rf $!! cleanStatsOutput contents++ -- Stats mode: nested recall showing inner cache dynamics.+ -- First recall misses (shows full inner proofs). Second recall hits (shows "Cached:").+ , goldenCapturedIO "tpCache_statsNested" $ \rf -> do+ let cfg = (tpStats z3) { redirectVerbose = Just rf }+ void $ runTPWith cfg $ do+ _ <- recall (lemma "inner" sTrue [])+ _ <- lemma "outer" sTrue []+ _ <- recall (lemma "inner" sTrue [])+ recall (lemma "outer" sTrue [])+ contents <- readFile rf+ writeFile rf $!! cleanStatsOutput contents+ ]
SBVTestSuite/TestSuite/Basics/Tuple.hs view
@@ -22,7 +22,8 @@ import Prelude hiding ((!!)) import Data.SBV.Control-import Data.SBV.List ((!!), (.:))+import Data.SBV.List ((!!))+ import Data.SBV.Tuple import qualified Data.SBV.List as L
SBVTestSuite/TestSuite/CompileTests/PCase/PCase01.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,4 +10,4 @@ -- Parse error: EOF t :: SExpr -> Proof SBool-t _e = [pCase|Expr _e of|]+t _e = [pCase| _e of|]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase01.stderr view
@@ -1,8 +1,8 @@ PCase01.hs:13:15: error: [GHC-39584]- " PCase01.hs:13:14: Parse error: EOF+ " PCase01.hs:13:21: Parse error: EOF - " In the quasi-quotation: [pCase|Expr _e of|]+ " In the quasi-quotation: [pCase| _e of|] |-13 | t _e = [pCase|Expr _e of|]- | ^^^^^^^^^^^^+13 | t _e = [pCase| _e of|]+ | ^^^^^^^^
SBVTestSuite/TestSuite/CompileTests/PCase/PCase02.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,4 +10,4 @@ -- Bad syntax t :: SExpr -> Proof SBool-t e = [pCase|Expr e + 1|]+t e = [pCase| e + 1|]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase02.stderr view
@@ -1,13 +1,8 @@ PCase02.hs:13:14: error: [GHC-39584]- " pCase: Failed to parse a proof case-expression.-- Instead of: case expr of alts- Write : [pCase|Type expr of alts|]-- where Type is the underlying concrete type of the expression.+ " PCase02.hs:13:20: Parse error: EOF - " In the quasi-quotation: [pCase|Expr e + 1|]+ " In the quasi-quotation: [pCase| e + 1|] |-13 | t e = [pCase|Expr e + 1|]- | ^^^^^^^^^^^^+13 | t e = [pCase| e + 1|]+ | ^^^^^^^^
SBVTestSuite/TestSuite/CompileTests/PCase/PCase03.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ import Data.SBV.TP -- Not usable in declaration context-[pCase|Expr e of+[pCase| e of Zero -> undefined Num _ -> undefined |]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase03.stderr view
@@ -1,6 +1,6 @@ PCase03.hs:12:8: error: [GHC-39584] pCase: not usable in declaration context |-12 | [pCase|Expr e of- | ^^^^^^^^^...+12 | [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase04.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,8 +8,8 @@ import Data.SBV import Data.SBV.TP --- Unknown type+-- Unknown constructor t :: SExpr -> Proof SBool-t e = [pCase|FExpr e of- Num _ -> undefined+t e = [pCase| e of+ FooBar _ -> undefined |]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase04.stderr view
@@ -1,10 +1,14 @@-PCase04.hs:13:14: error: [GHC-24922]- " FExpr is not in scope at a reify+PCase04.hs:13:14: error: [GHC-39584]+ " pCase: Unknown constructor: FooBar++ Cannot find this constructor in scope.+ Make sure the type is declared and mkSymbolic is called.+ " In the quasi-quotation:- [pCase|FExpr e of- Num _ -> undefined+ [pCase| e of+ FooBar _ -> undefined |] |-13 | t e = [pCase|FExpr e of- | ^^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase05.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Unknown constructor t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Numb _ -> undefined |]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase05.stderr view
@@ -1,11 +1,11 @@ PCase05.hs:13:14: error: [GHC-39584] " PCase05.hs:15:9-14: sCase/pCase: Not in scope: data constructor: Numb " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Numb _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase06.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Pattern guards not supported t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num i | Just 1 <- Just i -> undefined Var _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase06.stderr view
@@ -3,12 +3,12 @@ Just 1 <- Just i " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num i | Just 1 <- Just i -> undefined Var _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase07.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Arity mismatch: Num takes 1 arg, given 2 t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num _ _ -> undefined Var _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase07.stderr view
@@ -6,7 +6,7 @@ Given : 2 " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num _ _ -> undefined Var _ -> undefined@@ -14,6 +14,6 @@ Let _ _ _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase08.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: wildcard at the end catches remaining constructors t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase08.stderr view
@@ -1,1 +1,12 @@-There was no failure during compilation.+PCase08.hs:(18,15)-(22,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num _ -> e .== e =: qed\n\+ \ _ -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)), (isNum e ==> (e .== e =: qed)),+ (sNot ((.||) (isZero e) (isNum e)) ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase09.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Overlapping constructors: unguarded Num after guarded Num t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num i -> undefined Num i | i .> 3 -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase09.stderr view
@@ -5,13 +5,13 @@ PCase09.hs:15:9-13: Num i " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num i -> undefined Num i | i .> 3 -> undefined Var _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase10.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Arity mismatch in nested pattern: Num takes 1, given 2 t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num k -> undefined Var _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase10.stderr view
@@ -5,7 +5,7 @@ Given : 2 " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num k -> undefined Var _ -> undefined@@ -13,6 +13,6 @@ Let _ _ _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase11.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Unknown constructor in nested pattern t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num k -> undefined Var _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase11.stderr view
@@ -1,7 +1,7 @@ PCase11.hs:13:14: error: [GHC-39584] " PCase11.hs:17:9-22: sCase/pCase: Not in scope: data constructor: Numb " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num k -> undefined Var _ -> undefined@@ -9,6 +9,6 @@ Let _ _ _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase12.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: all constructors covered, no guards; use matched fields in proof t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i -> sNum i .== sNum i =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase12.stderr view
@@ -1,1 +1,30 @@-There was no failure during compilation.+PCase12.hs:(18,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase13.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: partial coverage is fine in pCase (no exhaustiveness check) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i -> sNum i .== sNum i =: e .== e =: qed |]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase13.stderr view
@@ -1,1 +1,12 @@-There was no failure during compilation.+PCase13.hs:(18,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i -> sNum i .== sNum i =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase14.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: guard on one constructor; use matched field in proof t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase14.stderr view
@@ -1,1 +1,30 @@-There was no failure during compilation.+PCase14.hs:(18,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ ((.&&) (isNum e) (let i = getNum_1 e in i .> 0)+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase15.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -16,7 +16,7 @@ -- Second arm gets: isNum e .&& sNot (i .> 0) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed | sTrue -> sNum i .== sNum i =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase15.stderr view
@@ -1,1 +1,33 @@-There was no failure during compilation.+PCase15.hs:(19,15)-(26,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed\n\+ \ | sTrue -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ ((.&&) (isNum e) (let i = getNum_1 e in i .> 0)+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ ((.&&) (isNum e) (sNot (let i = getNum_1 e in i .> 0))+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase16.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: nested pattern; use matched fields including nested ones t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase16.stderr view
@@ -1,1 +1,35 @@-There was no failure during compilation.+PCase16.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num i) _ -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&) (isAdd e) (isNum (getAdd_1 e))+ ==>+ (let i = getNum_1 (getAdd_1 e)+ in (sNum i) .== sNum i =: e .== e =: qed)),+ ((.&&) (isAdd e) (sNot (isNum (getAdd_1 e)))+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase17.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Negative: pCase generates cases [...] which has type TPProofRaw, not Proof SBool; -- so using pCase outside a TP proof context is a type error t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed Var _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase17.stderr view
@@ -1,7 +1,22 @@+PCase17.hs:(18,14)-(24,7): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num _ -> e .== e =: qed\n\+ \ Var _ -> e .== e =: qed\n\+ \ Add _ _ -> e .== e =: qed\n\+ \ Let _ _ _ -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)), (isNum e ==> (e .== e =: qed)),+ (isVar e ==> (e .== e =: qed)), (isAdd e ==> (e .== e =: qed)),+ (isLet e ==> (e .== e =: qed))] PCase17.hs:18:14: error: [GHC-83865] " Couldn't match expected type: Proof SBool- with actual type: sbv-13.6:Data.SBV.TP.TP.TPProofGen- (SBV Bool) [sbv-13.6:Data.SBV.TP.TP.Helper] ()+ with actual type: sbv-14.0:Data.SBV.TP.TP.TPProofGen+ (SBV Bool) [sbv-14.0:Data.SBV.TP.TP.Helper] () " In the expression: cases [(isZero e ==> (e .== e =: qed)), (isNum e ==> (e .== e =: qed)),@@ -12,6 +27,6 @@ [(isZero e ==> (e .== e =: qed)), (isNum e ==> (e .== e =: qed)), (isVar e ==> (e .== e =: qed)), ....]) |-18 | t e = [pCase|Expr e of- | ^^^^^^^^^...+18 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase18.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Negative: wildcard with args (e.g. _ _ ->) t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num _ -> undefined Var _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase18.stderr view
@@ -2,7 +2,7 @@ " PCase18.hs:18:17: Parse error in pattern: _ " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num _ -> undefined Var _ -> undefined@@ -10,6 +10,6 @@ _ _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase19.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Negative: overlapping — second group for same constructor after first has sTrue catch-all guard t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num i | i .> 3 -> undefined | sTrue -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase19.stderr view
@@ -5,7 +5,7 @@ PCase19.hs:15:9-13: Num i " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num i | i .> 3 -> undefined | sTrue -> undefined@@ -15,6 +15,6 @@ Let _ _ _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase20.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: {} wildcard patterns; use matched field where available t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Num i | i .> 3 -> sNum i .== sNum i =: e .== e =: qed | sTrue -> sNum i .== sNum i =: e .== e =: qed Zero{} -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase20.stderr view
@@ -1,1 +1,19 @@-There was no failure during compilation.+PCase20.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Num i | i .> 3 -> sNum i .== sNum i =: e .== e =: qed\n\+ \ | sTrue -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Zero{} -> e .== e =: qed\n\+ \ Var{} -> e .== e =: qed\n\+ \ Add{} -> e .== e =: qed\n\+ \ Let{} -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [((.&&) (isNum e) (let i = getNum_1 e in i .> 3)+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ ((.&&) (isNum e) (sNot (let i = getNum_1 e in i .> 3))+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isZero e ==> (e .== e =: qed)), (isVar e ==> (e .== e =: qed)),+ (isAdd e ==> (e .== e =: qed)), (isLet e ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase21.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: deeply nested pattern Add (Add (Num _) j) k; use matched fields t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase21.stderr view
@@ -1,1 +1,39 @@-There was no failure during compilation.+PCase21.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Add (Num _) j) _ -> sAdd j j .== sAdd j j =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ ((.&&) (isAdd (getAdd_1 e)) (isNum (getAdd_1 (getAdd_1 e))))+ ==>+ (let j = getAdd_2 (getAdd_1 e)+ in (sAdd j j) .== sAdd j j =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ (sNot ((.&&) (isAdd (getAdd_1 e)) (isNum (getAdd_1 (getAdd_1 e)))))+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase22.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: nested pattern combined with a guard; use matched fields t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase22.stderr view
@@ -1,1 +1,42 @@-There was no failure during compilation.+PCase22.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num i) _ | i .> 0 -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ ((.&&)+ (isNum (getAdd_1 e)) (let i = getNum_1 (getAdd_1 e) in i .> 0))+ ==>+ (let i = getNum_1 (getAdd_1 e)+ in (sNum i) .== sNum i =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ (sNot+ ((.&&)+ (isNum (getAdd_1 e)) (let i = getNum_1 (getAdd_1 e) in i .> 0)))+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase23.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: nested patterns on both sides; use matched fields t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase23.stderr view
@@ -1,1 +1,38 @@-There was no failure during compilation.+PCase23.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num i) (Num j) -> sNum (i + j) .== sNum (i + j) =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&) (isAdd e) ((.&&) (isNum (getAdd_1 e)) (isNum (getAdd_2 e)))+ ==>+ (let+ i = getNum_1 (getAdd_1 e)+ j = getNum_1 (getAdd_2 e)+ in (sNum (i + j)) .== sNum (i + j) =: e .== e =: qed)),+ ((.&&)+ (isAdd e) (sNot ((.&&) (isNum (getAdd_1 e)) (isNum (getAdd_2 e))))+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase24.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: nested pattern with wildcard inside; use matched fields t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase24.stderr view
@@ -1,1 +1,32 @@-There was no failure during compilation.+PCase24.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num _) _ -> e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&) (isAdd e) (isNum (getAdd_1 e)) ==> (e .== e =: qed)),+ ((.&&) (isAdd e) (sNot (isNum (getAdd_1 e)))+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase25.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: nested pattern using parenthesized constructor; use matched fields t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase25.stderr view
@@ -1,1 +1,35 @@-There was no failure during compilation.+PCase25.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Let _ (Num i) _ -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&) (isLet e) (isNum (getLet_2 e))+ ==>+ (let i = getNum_1 (getLet_2 e)+ in (sNum i) .== sNum i =: e .== e =: qed)),+ ((.&&) (isLet e) (sNot (isNum (getLet_2 e)))+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase26.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: integer literal at top level (Num 1 -> ...) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num 1 -> sNum 1 .== sNum 1 =: e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase26.stderr view
@@ -1,1 +1,33 @@-There was no failure during compilation.+PCase26.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num 1 -> sNum 1 .== sNum 1 =: e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ ((.&&) (isNum e) ((.==) (getNum_1 e) 1)+ ==> ((sNum 1) .== sNum 1 =: e .== e =: qed)),+ ((.&&) (isNum e) (sNot ((.==) (getNum_1 e) 1))+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase27.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: integer literal in nested position (Add (Num 0) j -> ...) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase27.stderr view
@@ -1,1 +1,38 @@-There was no failure during compilation.+PCase27.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num 0) _ -> sNum 0 .== sNum 0 =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ ((.&&) (isNum (getAdd_1 e)) ((.==) (getNum_1 (getAdd_1 e)) 0))+ ==> ((sNum 0) .== sNum 0 =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ (sNot+ ((.&&) (isNum (getAdd_1 e)) ((.==) (getNum_1 (getAdd_1 e)) 0)))+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase28.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: string literal in nested position (Var "x" -> ...) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var "x" -> sVar (literal "x") .== sVar (literal "x") =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase28.stderr view
@@ -1,1 +1,34 @@-There was no failure during compilation.+PCase28.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var \"x\" -> sVar (literal \"x\") .== sVar (literal \"x\") =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ ((.&&) (isVar e) ((.==) (getVar_1 e) (literal "x"))+ ==>+ ((sVar (literal "x")) .== sVar (literal "x") =: e .== e =: qed)),+ ((.&&) (isVar e) (sNot ((.==) (getVar_1 e) (literal "x")))+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase29.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: integer literals on both sides of nested pattern t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase29.stderr view
@@ -1,1 +1,48 @@-There was no failure during compilation.+PCase29.hs:(18,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num 1) (Num 2) -> sAdd (sNum 1) (sNum 2) .== sAdd (sNum 1) (sNum 2) =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ ((.&&)+ (isNum (getAdd_1 e))+ ((.&&)+ ((.==) (getNum_1 (getAdd_1 e)) 1)+ ((.&&) (isNum (getAdd_2 e)) ((.==) (getNum_1 (getAdd_2 e)) 2))))+ ==>+ ((sAdd (sNum 1) (sNum 2)) .== sAdd (sNum 1) (sNum 2) =: e .== e+ =: qed)),+ ((.&&)+ (isAdd e)+ (sNot+ ((.&&)+ (isNum (getAdd_1 e))+ ((.&&)+ ((.==) (getNum_1 (getAdd_1 e)) 1)+ ((.&&) (isNum (getAdd_2 e)) ((.==) (getNum_1 (getAdd_2 e)) 2)))))+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase30.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: Num 1 as only Num arm, no fallback — fine in pCase (no exhaustiveness check) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num 1 -> sNum 1 .== sNum 1 =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase30.stderr view
@@ -1,1 +1,18 @@-There was no failure during compilation.+PCase30.hs:(18,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num 1 -> sNum 1 .== sNum 1 =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add _ _ -> e .== e =: qed\n\+ \ Let _ _ _ -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ ((.&&) (isNum e) ((.==) (getNum_1 e) 1)+ ==> ((sNum 1) .== sNum 1 =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e ==> (e .== e =: qed)), (isLet e ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase31.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: Add (Num 1) j without fallback for Add — fine in pCase (no exhaustiveness check) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase31.stderr view
@@ -1,1 +1,28 @@-There was no failure during compilation.+PCase31.hs:(18,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num 1) _ -> sNum 1 .== sNum 1 =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ ((.&&) (isNum (getAdd_1 e)) ((.==) (getNum_1 (getAdd_1 e)) 1))+ ==> ((sNum 1) .== sNum 1 =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase32.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -16,7 +16,7 @@ -- (sCase would reject this as non-exhaustive; pCase is fine) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase32.stderr view
@@ -1,1 +1,15 @@-There was no failure during compilation.+PCase32.hs:(19,15)-(23,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ ((.&&) (isNum e) (let i = getNum_1 e in i .> 0)+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase33.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -11,7 +11,7 @@ -- Negative in pCase: wildcard mid-list (after two constructors, before more) -- Wildcard makes the remaining matches redundant t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num _ -> undefined _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase33.stderr view
@@ -5,7 +5,7 @@ PCase33.hs:20:9-17: Let _ _ _ " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num _ -> undefined _ -> undefined@@ -14,6 +14,6 @@ Let _ _ _ -> undefined |] |-14 | t e = [pCase|Expr e of- | ^^^^^^^^^...+14 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase34.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Negative in pCase: two wildcards, second is redundant t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num _ -> undefined _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase34.stderr view
@@ -3,13 +3,13 @@ PCase34.hs:17:9: _ " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Num _ -> undefined _ -> undefined _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase35.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -16,7 +16,7 @@ -- (sCase rejects this as "guarded match might fail"; pCase is fine) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i | i .< 3 -> sNum i .== sNum i =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase35.stderr view
@@ -1,1 +1,18 @@-There was no failure during compilation.+PCase35.hs:(19,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i | i .< 3 -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add _ _ -> e .== e =: qed\n\+ \ Let _ _ _ -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ ((.&&) (isNum e) (let i = getNum_1 e in i .< 3)+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e ==> (e .== e =: qed)), (isLet e ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase36.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Negative: guarded wildcard at end with ambiguous type in guard (2 .>= 3) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed Var _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase36.stderr view
@@ -1,7 +1,7 @@ PCase36.hs:18:15: error: [GHC-39584] " PCase36.hs:24:8: pCase: Wildcard match is redundant " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed Var _ -> e .== e =: qed@@ -10,6 +10,6 @@ _ | 2 .>= 3 -> e .== e =: qed |] |-18 | |- [pCase|Expr e of- | ^^^^^^^^^...+18 | |- [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase37.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Negative: all constructors covered + guarded wildcard with ambiguous type in guard (2 .>= 3) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i -> sNum i .== sNum i =: e .== e =: qed Var _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase37.stderr view
@@ -1,7 +1,7 @@ PCase37.hs:18:15: error: [GHC-39584] " PCase37.hs:24:8: pCase: Wildcard match is redundant " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> e .== e =: qed Num i -> sNum i .== sNum i =: e .== e =: qed Var _ -> e .== e =: qed@@ -10,6 +10,6 @@ _ | 2 .>= 3 -> e .== e =: qed |] |-18 | |- [pCase|Expr e of- | ^^^^^^^^^...+18 | |- [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase38.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ import Data.SBV.TP t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Num _ -> undefined Var _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase38.stderr view
@@ -1,7 +1,22 @@+PCase38.hs:(12,14)-(18,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> undefined\n\+ \ Num _ -> undefined\n\+ \ Var _ -> undefined\n\+ \ Add _ _ -> undefined\n\+ \ Let _ _ _ -> undefined\n\+ \ "+ ======>+ cases+ [(isZero e ==> undefined), (isNum e ==> undefined),+ (isVar e ==> undefined), (isAdd e ==> undefined),+ (isLet e ==> undefined)] PCase38.hs:12:14: error: [GHC-83865] " Couldn't match expected type: Proof SBool- with actual type: sbv-13.6:Data.SBV.TP.TP.TPProofGen- a0 [sbv-13.6:Data.SBV.TP.TP.Helper] ()+ with actual type: sbv-14.0:Data.SBV.TP.TP.TPProofGen+ a0 [sbv-14.0:Data.SBV.TP.TP.Helper] () " In the expression: cases [(isZero e ==> undefined), (isNum e ==> undefined),@@ -12,6 +27,6 @@ [(isZero e ==> undefined), (isNum e ==> undefined), (isVar e ==> undefined), ....]) |-12 | t e = [pCase|Expr e of- | ^^^^^^^^^...+12 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase39.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -16,7 +16,7 @@ -- (sCase rejects as non-exhaustive; pCase is fine) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase39.stderr view
@@ -1,1 +1,28 @@-There was no failure during compilation.+PCase39.hs:(19,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Num i) _ -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&) (isAdd e) (isNum (getAdd_1 e))+ ==>+ (let i = getNum_1 (getAdd_1 e)+ in (sNum i) .== sNum i =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase40.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -16,7 +16,7 @@ -- (sCase rejects as non-exhaustive; pCase is fine) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase40.stderr view
@@ -1,1 +1,36 @@-There was no failure during compilation.+PCase40.hs:(19,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num k -> sNum k .== sNum k =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add (Add (Add (Num _) b) c) _ -> sAdd b (sAdd c c) .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let k = getNum_1 e in (sNum k) .== sNum k =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ ((.&&)+ (isAdd e)+ ((.&&)+ (isAdd (getAdd_1 e))+ ((.&&)+ (isAdd (getAdd_1 (getAdd_1 e)))+ (isNum (getAdd_1 (getAdd_1 (getAdd_1 e))))))+ ==>+ (let+ c = getAdd_2 (getAdd_1 e)+ b = getAdd_2 (getAdd_1 (getAdd_1 e))+ in (sAdd b (sAdd c c)) .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase41.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Negative: parse error (else keyword in wrong position) t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined Var s -> ite (s .== "a") undefined else undefined Num _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase41.stderr view
@@ -2,12 +2,12 @@ " PCase41.hs:15:44: Parse error: else " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined Var s -> ite (s .== "a") undefined else undefined Num _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase42.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -16,7 +16,7 @@ -- (same constructor appearing in two separate groups is fine in pCase) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i | i .< 3 -> sNum i .== sNum i =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase42.stderr view
@@ -1,1 +1,33 @@-There was no failure during compilation.+PCase42.hs:(19,15)-(26,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i | i .< 3 -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Num i -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ ((.&&) (isNum e) (let i = getNum_1 e in i .< 3)+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ ((.&&) (isNum e) (sNot (let i = getNum_1 e in i .< 3))+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase43.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: guarded constructor without full coverage (exhaustiveness deferred to proof time) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed Var _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase43.stderr view
@@ -1,1 +1,17 @@-There was no failure during compilation.+PCase43.hs:(18,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num _ -> e .== e =: qed\n\+ \ Var _ -> e .== e =: qed\n\+ \ Add a _ | isZero a -> e .== e =: qed\n\+ \ Let _ _ _ -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)), (isNum e ==> (e .== e =: qed)),+ (isVar e ==> (e .== e =: qed)),+ ((.&&) (isAdd e) (let a = getAdd_1 e in isZero a)+ ==> (e .== e =: qed)),+ (isLet e ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase44.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: wildcard catch-all after multi-arm guarded Var and Num t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Var s | s .== literal "a" -> e .== e =: qed | s .== literal "b" .|| s .== literal "c" -> e .== e =: qed | sTrue -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase44.stderr view
@@ -1,1 +1,48 @@-There was no failure during compilation.+PCase44.hs:(18,15)-(26,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Var s | s .== literal \"a\" -> e .== e =: qed\n\+ \ | s .== literal \"b\" .|| s .== literal \"c\" -> e .== e =: qed\n\+ \ | sTrue -> e .== e =: qed\n\+ \\n\+ \ Num _ | sTrue -> e .== e =: qed\n\+ \\n\+ \ _ -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [((.&&) (isVar e) (let s = getVar_1 e in s .== literal "a")+ ==> (e .== e =: qed)),+ ((.&&)+ (isVar e)+ ((.&&)+ (sNot (let s = getVar_1 e in s .== literal "a"))+ (let s = getVar_1 e in s .== literal "b" .|| s .== literal "c"))+ ==> (e .== e =: qed)),+ ((.&&)+ (isVar e)+ ((.&&)+ (sNot (let s = getVar_1 e in s .== literal "a"))+ (sNot+ (let s = getVar_1 e in s .== literal "b" .|| s .== literal "c")))+ ==> (e .== e =: qed)),+ (isNum e ==> (e .== e =: qed)),+ (sNot+ ((.||)+ ((.||)+ ((.||)+ ((.&&) (isVar e) (let s = getVar_1 e in s .== literal "a"))+ ((.&&)+ (isVar e)+ ((.&&)+ (sNot (let s = getVar_1 e in s .== literal "a"))+ (let s = getVar_1 e in s .== literal "b" .|| s .== literal "c"))))+ ((.&&)+ (isVar e)+ ((.&&)+ (sNot (let s = getVar_1 e in s .== literal "a"))+ (sNot+ (let s = getVar_1 e in s .== literal "b" .|| s .== literal "c")))))+ (isNum e))+ ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase45.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Negative: bound variable i from Num is not used in the RHS t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i -> e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase45.stderr view
@@ -1,6 +1,35 @@+PCase45.hs:(18,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i -> e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e ==> (let i = getNum_1 e in e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in (sAdd a b) .== sAdd a b =: e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))] PCase45.hs:18:15: error: [GHC-40910] [-Wunused-local-binds, Werror=unused-local-binds] Defined but not used: i |-18 | |- [pCase|Expr e of- | ^^^^^^^^^...+18 | |- [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase46.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Negative: bound variables a, b from Add are not used in the RHS t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i -> sNum i .== sNum i =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase46.stderr view
@@ -1,12 +1,42 @@+PCase46.hs:(18,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num i -> sNum i .== sNum i =: e .== e =: qed\n\+ \ Var s -> sVar s .== sVar s =: e .== e =: qed\n\+ \ Add a b -> e .== e =: qed\n\+ \ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (isNum e+ ==> (let i = getNum_1 e in (sNum i) .== sNum i =: e .== e =: qed)),+ (isVar e+ ==> (let s = getVar_1 e in (sVar s) .== sVar s =: e .== e =: qed)),+ (isAdd e+ ==>+ (let+ a = getAdd_1 e+ b = getAdd_2 e+ in e .== e =: qed)),+ (isLet e+ ==>+ (let+ nm = getLet_1 e+ a = getLet_2 e+ b = getLet_3 e+ in (sLet nm a b) .== sLet nm a b =: e .== e =: qed))] PCase46.hs:18:15: error: [GHC-40910] [-Wunused-local-binds, Werror=unused-local-binds] Defined but not used: b |-18 | |- [pCase|Expr e of- | ^^^^^^^^^...+18 | |- [pCase| e of+ | ^^^^^... PCase46.hs:18:15: error: [GHC-40910] [-Wunused-local-binds, Werror=unused-local-binds] Defined but not used: a |-18 | |- [pCase|Expr e of- | ^^^^^^^^^...+18 | |- [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase47.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Negative: Var s before Var "x" — Var s overlaps with Var "x" t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase47.stderr view
@@ -5,7 +5,7 @@ PCase47.hs:21:10-14: Var s " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> e .== e =: qed Num k -> sNum k .== sNum k =: e .== e =: qed Var s -> sVar s .== sVar s =: e .== e =: qed@@ -14,6 +14,6 @@ Let nm a b -> sLet nm a b .== sLet nm a b =: e .== e =: qed |] |-18 | |- [pCase|Expr e of- | ^^^^^^^^^...+18 | |- [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase48.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -16,7 +16,7 @@ -- (sCase would reject as non-exhaustive; pCase is fine) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Var s | s .== literal "a" -> e .== e =: qed | s .== literal "b" .|| s .== literal "c" -> e .== e =: qed | sTrue -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase48.stderr view
@@ -1,1 +1,28 @@-There was no failure during compilation.+PCase48.hs:(19,15)-(25,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Var s | s .== literal \"a\" -> e .== e =: qed\n\+ \ | s .== literal \"b\" .|| s .== literal \"c\" -> e .== e =: qed\n\+ \ | sTrue -> e .== e =: qed\n\+ \\n\+ \ Num _ | sTrue -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [((.&&) (isVar e) (let s = getVar_1 e in s .== literal "a")+ ==> (e .== e =: qed)),+ ((.&&)+ (isVar e)+ ((.&&)+ (sNot (let s = getVar_1 e in s .== literal "a"))+ (let s = getVar_1 e in s .== literal "b" .|| s .== literal "c"))+ ==> (e .== e =: qed)),+ ((.&&)+ (isVar e)+ ((.&&)+ (sNot (let s = getVar_1 e in s .== literal "a"))+ (sNot+ (let s = getVar_1 e in s .== literal "b" .|| s .== literal "c")))+ ==> (e .== e =: qed)),+ (isNum e ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase49.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: guarded wildcard as last arm after explicit constructors t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed _ | sTrue -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase49.stderr view
@@ -1,1 +1,12 @@-There was no failure during compilation.+PCase49.hs:(18,15)-(22,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Zero -> e .== e =: qed\n\+ \ Num _ -> e .== e =: qed\n\+ \ _ | sTrue -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)), (isNum e ==> (e .== e =: qed)),+ (sNot ((.||) (isZero e) (isNum e)) ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase50.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,6 +15,6 @@ -- Positive: wildcard-only, no explicit constructors t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of _ -> e .== e =: qed |]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase50.stderr view
@@ -1,1 +1,8 @@-There was no failure during compilation.+PCase50.hs:(18,15)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ _ -> e .== e =: qed\n\+ \ "+ ======>+ cases [(sTrue ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase51.hs view
@@ -4,7 +4,7 @@ {-# LANGUAGE TypeAbstractions #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -15,7 +15,7 @@ -- Positive: guarded wildcard only, no explicit constructors t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of _ | isZero e -> e .== e =: qed | sTrue -> e .== e =: qed |]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase51.stderr view
@@ -1,1 +1,11 @@-There was no failure during compilation.+PCase51.hs:(18,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ _ | isZero e -> e .== e =: qed\n\+ \ | sTrue -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(isZero e ==> (e .== e =: qed)),+ (sNot (isZero e) ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase52.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -10,7 +10,7 @@ -- Negative: guarded wildcard before explicit constructor matches t :: SExpr -> Proof SBool-t e = [pCase|Expr e of+t e = [pCase| e of Zero -> undefined _ | sTrue -> undefined Num _ -> undefined
SBVTestSuite/TestSuite/CompileTests/PCase/PCase52.stderr view
@@ -3,12 +3,12 @@ PCase52.hs:16:9-13: Num _ " In the quasi-quotation:- [pCase|Expr e of+ [pCase| e of Zero -> undefined _ | sTrue -> undefined Num _ -> undefined |] |-13 | t e = [pCase|Expr e of- | ^^^^^^^^^...+13 | t e = [pCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/PCase/PCase53.hs view
@@ -15,7 +15,7 @@ -- Dump test: simple unguarded, all constructors t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed Var _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase53.stderr view
@@ -1,7 +1,7 @@ PCase53.hs:(18,15)-(24,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Zero -> e .== e =: qed\n\ \ Num _ -> e .== e =: qed\n\ \ Var _ -> e .== e =: qed\n\
SBVTestSuite/TestSuite/CompileTests/PCase/PCase54.hs view
@@ -15,7 +15,7 @@ -- Dump test: multiple guards on same constructor (guard accumulation) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num i | i .< 3 -> e .== e =: qed | i .< 10 -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase54.stderr view
@@ -1,7 +1,7 @@ PCase54.hs:(18,15)-(26,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Zero -> e .== e =: qed\n\ \ Num i | i .< 3 -> e .== e =: qed\n\ \ | i .< 10 -> e .== e =: qed\n\@@ -16,12 +16,16 @@ ((.&&) (isNum e) (let i = getNum_1 e in i .< 3) ==> (e .== e =: qed)), ((.&&)- ((.&&) (isNum e) (sNot (let i = getNum_1 e in i .< 3)))- (let i = getNum_1 e in i .< 10)+ (isNum e)+ ((.&&)+ (sNot (let i = getNum_1 e in i .< 3))+ (let i = getNum_1 e in i .< 10)) ==> (e .== e =: qed)), ((.&&)- ((.&&) (isNum e) (sNot (let i = getNum_1 e in i .< 3)))- (sNot (let i = getNum_1 e in i .< 10))+ (isNum e)+ ((.&&)+ (sNot (let i = getNum_1 e in i .< 3))+ (sNot (let i = getNum_1 e in i .< 10))) ==> (e .== e =: qed)), (isVar e ==> (e .== e =: qed)), (isAdd e ==> (e .== e =: qed)), (isLet e ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase55.hs view
@@ -15,7 +15,7 @@ -- Dump test: wildcard after some constructors (De Morgan negation) t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Zero -> e .== e =: qed Num _ -> e .== e =: qed _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase55.stderr view
@@ -1,7 +1,7 @@ PCase55.hs:(18,15)-(22,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Zero -> e .== e =: qed\n\ \ Num _ -> e .== e =: qed\n\ \ _ -> e .== e =: qed\n\
SBVTestSuite/TestSuite/CompileTests/PCase/PCase56.hs view
@@ -15,7 +15,7 @@ -- Dump test: guarded wildcard + nested pattern on a constructor t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Add (Num i) _ | i .> 0 -> e .== e =: qed Add _ _ -> e .== e =: qed _ | isZero e -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase56.stderr view
@@ -1,7 +1,7 @@ PCase56.hs:(18,15)-(23,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Add (Num i) _ | i .> 0 -> e .== e =: qed\n\ \ Add _ _ -> e .== e =: qed\n\ \ _ | isZero e -> e .== e =: qed\n\
SBVTestSuite/TestSuite/CompileTests/PCase/PCase57.hs view
@@ -15,7 +15,7 @@ -- Dump test: nested pattern variable used in both guard and RHS t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Add (Num i) _ | i .> 0 -> sNum i .== sNum i =: e .== e =: qed Add _ _ -> e .== e =: qed _ -> e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase57.stderr view
@@ -1,7 +1,7 @@ PCase57.hs:(18,15)-(22,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Add (Num i) _ | i .> 0 -> sNum i .== sNum i =: e .== e =: qed\n\ \ Add _ _ -> e .== e =: qed\n\ \ _ -> e .== e =: qed\n\
SBVTestSuite/TestSuite/CompileTests/PCase/PCase58.hs view
@@ -15,7 +15,7 @@ -- Dump test: multiple guarded arms on nested pattern, variable in guard + RHS, wildcard t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Let s (Num i) b | i .> 0 -> sLet s (sNum i) b .== sLet s (sNum i) b =: e .== e =: qed | i .> -5 -> sLet s (sNum i) b .== sLet s (sNum i) b =: e .== e =: qed | sTrue -> sLet s (sNum i) b .== sLet s (sNum i) b =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase58.stderr view
@@ -1,7 +1,7 @@ PCase58.hs:(18,15)-(25,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Let s (Num i) b | i .> 0 -> sLet s (sNum i) b .== sLet s (sNum i) b =: e .== e =: qed\n\ \ | i .> -5 -> sLet s (sNum i) b .== sLet s (sNum i) b =: e .== e =: qed\n\ \ | sTrue -> sLet s (sNum i) b .== sLet s (sNum i) b =: e .== e =: qed\n\@@ -22,14 +22,14 @@ let i = getNum_1 (getLet_2 e) in (sLet s (sNum i) b) .== sLet s (sNum i) b =: e .== e =: qed)), ((.&&)+ (isLet e) ((.&&)- (isLet e) (sNot ((.&&)- (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))))- ((.&&)- (isNum (getLet_2 e))- (let i = getNum_1 (getLet_2 e) in i .> negate 5))+ (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0)))+ ((.&&)+ (isNum (getLet_2 e))+ (let i = getNum_1 (getLet_2 e) in i .> negate 5))) ==> (let s = getLet_1 e@@ -37,17 +37,17 @@ let i = getNum_1 (getLet_2 e) in (sLet s (sNum i) b) .== sLet s (sNum i) b =: e .== e =: qed)), ((.&&)+ (isLet e) ((.&&)+ (sNot+ ((.&&)+ (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))) ((.&&)- (isLet e) (sNot ((.&&)- (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))))- (sNot- ((.&&)- (isNum (getLet_2 e))- (let i = getNum_1 (getLet_2 e) in i .> negate 5))))- (isNum (getLet_2 e))+ (isNum (getLet_2 e))+ (let i = getNum_1 (getLet_2 e) in i .> negate 5)))+ (isNum (getLet_2 e)))) ==> (let s = getLet_1 e@@ -55,17 +55,17 @@ let i = getNum_1 (getLet_2 e) in (sLet s (sNum i) b) .== sLet s (sNum i) b =: e .== e =: qed)), ((.&&)+ (isLet e) ((.&&)+ (sNot+ ((.&&)+ (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))) ((.&&)- (isLet e) (sNot ((.&&)- (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))))- (sNot- ((.&&)- (isNum (getLet_2 e))- (let i = getNum_1 (getLet_2 e) in i .> negate 5))))- (sNot (isNum (getLet_2 e)))+ (isNum (getLet_2 e))+ (let i = getNum_1 (getLet_2 e) in i .> negate 5)))+ (sNot (isNum (getLet_2 e))))) ==> (let s = getLet_1 e@@ -90,38 +90,38 @@ ((.&&) (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))) ((.&&)+ (isLet e) ((.&&)- (isLet e) (sNot ((.&&)- (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))))- ((.&&)- (isNum (getLet_2 e))- (let i = getNum_1 (getLet_2 e) in i .> negate 5))))+ (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0)))+ ((.&&)+ (isNum (getLet_2 e))+ (let i = getNum_1 (getLet_2 e) in i .> negate 5))))) ((.&&)+ (isLet e) ((.&&)+ (sNot+ ((.&&)+ (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))) ((.&&)- (isLet e) (sNot ((.&&)- (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))))- (sNot- ((.&&)- (isNum (getLet_2 e))- (let i = getNum_1 (getLet_2 e) in i .> negate 5))))- (isNum (getLet_2 e))))+ (isNum (getLet_2 e))+ (let i = getNum_1 (getLet_2 e) in i .> negate 5)))+ (isNum (getLet_2 e)))))) ((.&&)+ (isLet e) ((.&&)+ (sNot+ ((.&&)+ (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))) ((.&&)- (isLet e) (sNot ((.&&)- (isNum (getLet_2 e)) (let i = getNum_1 (getLet_2 e) in i .> 0))))- (sNot- ((.&&)- (isNum (getLet_2 e))- (let i = getNum_1 (getLet_2 e) in i .> negate 5))))- (sNot (isNum (getLet_2 e)))))+ (isNum (getLet_2 e))+ (let i = getNum_1 (getLet_2 e) in i .> negate 5)))+ (sNot (isNum (getLet_2 e))))))) ((.&&) (isAdd e) ((.&&) (isNum (getAdd_1 e)) (isNum (getAdd_2 e))))) ==> (e .== e =: qed))]
SBVTestSuite/TestSuite/CompileTests/PCase/PCase59.hs view
@@ -15,7 +15,7 @@ -- Dump test: interleaved constructors (Let/Add/Let), linear processing t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Let s a b | isZero a -> sLet s a b .== sLet s a b =: e .== e =: qed Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed Let s a b -> sLet s a b .== sLet s a b =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase59.stderr view
@@ -1,7 +1,7 @@ PCase59.hs:(18,15)-(25,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Let s a b | isZero a -> sLet s a b .== sLet s a b =: e .== e =: qed\n\ \ Add a b -> sAdd a b .== sAdd a b =: e .== e =: qed\n\ \ Let s a b -> sLet s a b .== sLet s a b =: e .== e =: qed\n\
SBVTestSuite/TestSuite/CompileTests/PCase/PCase60.hs view
@@ -20,7 +20,7 @@ -- - Multiple guarded wildcards at the end t :: TP (Proof (Forall "e" Expr -> SBool)) t = calc "t" (\(Forall @"e" (e :: SExpr)) -> e .== e) $ \e -> []- |- [pCase|Expr e of+ |- [pCase| e of Add (Num i) b | i .> 0 -> sAdd (sNum i) b .== sAdd (sNum i) b =: e .== e =: qed Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed Var s | s .== literal "hey" -> sVar s .== sVar s =: e .== e =: qed
SBVTestSuite/TestSuite/CompileTests/PCase/PCase60.stderr view
@@ -1,7 +1,7 @@ PCase60.hs:(23,15)-(33,9): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp pCase- "Expr e of\n\+ " e of\n\ \ Add (Num i) b | i .> 0 -> sAdd (sNum i) b .== sAdd (sNum i) b =: e .== e =: qed\n\ \ Num i | i .> 0 -> sNum i .== sNum i =: e .== e =: qed\n\ \ Var s | s .== literal \"hey\" -> sVar s .== sVar s =: e .== e =: qed\n\
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase61.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Maybe+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "m" (Maybe Integer) -> SBool))+t = calc "t" (\(Forall @"m" (m :: SMaybe Integer)) -> m .== m) $ \m -> []+ |- [pCase| m of+ Nothing -> m .== m =: qed+ Just _ -> m .== m =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase61.stderr view
@@ -0,0 +1,11 @@+PCase61.hs:(17,15)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " m of\n\+ \ Nothing -> m .== m =: qed\n\+ \ Just _ -> m .== m =: qed\n\+ \ "+ ======>+ cases+ [(Data.SBV.Maybe.isNothing m ==> (m .== m =: qed)),+ (Data.SBV.Maybe.isJust m ==> (m .== m =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase62.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Either+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "e" (Either Integer Bool) -> SBool))+t = calc "t" (\(Forall @"e" (e :: SEither Integer Bool)) -> e .== e) $ \e -> []+ |- [pCase| e of+ Left _ -> e .== e =: qed+ Right _ -> e .== e =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase62.stderr view
@@ -0,0 +1,11 @@+PCase62.hs:(17,15)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " e of\n\+ \ Left _ -> e .== e =: qed\n\+ \ Right _ -> e .== e =: qed\n\+ \ "+ ======>+ cases+ [(Data.SBV.Either.isLeft e ==> (e .== e =: qed)),+ (Data.SBV.Either.isRight e ==> (e .== e =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase63.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with List+module T where++import Prelude hiding (null, head, tail)+import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "xs" [Integer] -> SBool))+t = calc "t" (\(Forall @"xs" (xs :: SList Integer)) -> xs .== xs) $ \xs -> []+ |- [pCase| xs of+ [] -> xs .== xs =: qed+ _ : _ -> xs .== xs =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase63.stderr view
@@ -0,0 +1,14 @@+PCase63.hs:(19,15)-(22,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " xs of\n\+ \ [] -> xs .== xs =: qed\n\+ \ _ : _ -> xs .== xs =: qed\n\+ \ "+ ======>+ cases+ [(Data.SBV.List.null xs ==> (xs .== xs =: qed)),+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((.===) xs (Data.SBV.List.head xs .: Data.SBV.List.tail xs))+ ==> (xs .== xs =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase64.hs view
@@ -0,0 +1,19 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Tuple2+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "p" (Integer, Bool) -> SBool))+t = calc "t" (\(Forall @"p" (p :: STuple Integer Bool)) -> p .== p) $ \p -> []+ |- [pCase| p of+ (_, _) -> p .== p =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase64.stderr view
@@ -0,0 +1,8 @@+PCase64.hs:(17,15)-(19,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " p of\n\+ \ (_, _) -> p .== p =: qed\n\+ \ "+ ======>+ cases [(sTrue ==> (p .== p =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase65.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Maybe, guards on Just+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "m" (Maybe Integer) -> SBool))+t = calc "t" (\(Forall @"m" (m :: SMaybe Integer)) -> m .== m) $ \m -> []+ |- [pCase| m of+ Nothing -> m .== m =: qed+ Just x | x .> 0 -> m .== m =: qed+ | sTrue -> m .== m =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase65.stderr view
@@ -0,0 +1,19 @@+PCase65.hs:(17,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " m of\n\+ \ Nothing -> m .== m =: qed\n\+ \ Just x | x .> 0 -> m .== m =: qed\n\+ \ | sTrue -> m .== m =: qed\n\+ \ "+ ======>+ cases+ [(Data.SBV.Maybe.isNothing m ==> (m .== m =: qed)),+ ((.&&)+ (Data.SBV.Maybe.isJust m)+ (let x = Data.SBV.Maybe.getJust_1 m in x .> 0)+ ==> (m .== m =: qed)),+ ((.&&)+ (Data.SBV.Maybe.isJust m)+ (sNot (let x = Data.SBV.Maybe.getJust_1 m in x .> 0))+ ==> (m .== m =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase66.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with List, guards and wildcard+module T where++import Prelude hiding (null, head, tail)+import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "xs" [Integer] -> SBool))+t = calc "t" (\(Forall @"xs" (xs :: SList Integer)) -> xs .== xs) $ \xs -> []+ |- [pCase| xs of+ [] -> xs .== xs =: qed+ y : _ | y .> 0 -> xs .== xs =: qed+ _ -> xs .== xs =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase66.stderr view
@@ -0,0 +1,26 @@+PCase66.hs:(19,15)-(23,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " xs of\n\+ \ [] -> xs .== xs =: qed\n\+ \ y : _ | y .> 0 -> xs .== xs =: qed\n\+ \ _ -> xs .== xs =: qed\n\+ \ "+ ======>+ cases+ [(Data.SBV.List.null xs ==> (xs .== xs =: qed)),+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((.&&)+ ((.===) xs (Data.SBV.List.head xs .: Data.SBV.List.tail xs))+ (let y = Data.SBV.List.head xs in y .> 0))+ ==> (xs .== xs =: qed)),+ (sNot+ ((.||)+ (Data.SBV.List.null xs)+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((.&&)+ ((.===) xs (Data.SBV.List.head xs .: Data.SBV.List.tail xs))+ (let y = Data.SBV.List.head xs in y .> 0))))+ ==> (xs .== xs =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase67.hs view
@@ -0,0 +1,24 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with List, nested cons pattern with bindings+module T where++import Prelude hiding (null, head, tail, length)+import Data.SBV+import Data.SBV.List (length)+import Data.SBV.TP++t :: TP (Proof (Forall "xs" [Integer] -> SBool))+t = calc "t" (\(Forall @"xs" (xs :: SList Integer)) -> length xs .>= 0) $ \xs -> []+ |- [pCase| xs of+ [] -> length xs .>= 0 =: qed+ _ : (_ : _) -> length xs .>= 0 =: qed+ _ : _ -> length xs .>= 0 =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase67.stderr view
@@ -0,0 +1,34 @@+PCase67.hs:(20,15)-(24,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " xs of\n\+ \ [] -> length xs .>= 0 =: qed\n\+ \ _ : (_ : _) -> length xs .>= 0 =: qed\n\+ \ _ : _ -> length xs .>= 0 =: qed\n\+ \ "+ ======>+ cases+ [(Data.SBV.List.null xs ==> ((length xs) .>= 0 =: qed)),+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((.&&)+ ((.===) xs (Data.SBV.List.head xs .: Data.SBV.List.tail xs))+ ((.&&)+ (sNot (Data.SBV.List.null (Data.SBV.List.tail xs)))+ ((.===)+ (Data.SBV.List.tail xs)+ (Data.SBV.List.head (Data.SBV.List.tail xs)+ .: Data.SBV.List.tail (Data.SBV.List.tail xs)))))+ ==> ((length xs) .>= 0 =: qed)),+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((.&&)+ ((.===) xs (Data.SBV.List.head xs .: Data.SBV.List.tail xs))+ (sNot+ ((.&&)+ (sNot (Data.SBV.List.null (Data.SBV.List.tail xs)))+ ((.===)+ (Data.SBV.List.tail xs)+ (Data.SBV.List.head (Data.SBV.List.tail xs)+ .: Data.SBV.List.tail (Data.SBV.List.tail xs))))))+ ==> ((length xs) .>= 0 =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase68.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Bool constructor patterns+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "b" Bool -> SBool))+t = calc "t" (\(Forall @"b" (b :: SBool)) -> b .== b) $ \b -> []+ |- [pCase| b of+ True -> b .== b =: qed+ False -> b .== b =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase68.stderr view
@@ -0,0 +1,9 @@+PCase68.hs:(17,15)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " b of\n\+ \ True -> b .== b =: qed\n\+ \ False -> b .== b =: qed\n\+ \ "+ ======>+ cases [(b ==> (b .== b =: qed)), (sNot b ==> (b .== b =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase69.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Bool, guard on True+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "b" Bool -> Forall "x" Integer -> SBool))+t = calc "t" (\(Forall @"b" (b :: SBool)) (Forall @"x" (x :: SInteger)) -> b .|| sNot b) $ \b x -> []+ |- [pCase| b of+ True | x .> 0 -> b .|| sNot b =: qed+ | sTrue -> b .|| sNot b =: qed+ False -> b .|| sNot b =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase69.stderr view
@@ -0,0 +1,19 @@+PCase69.hs:(17,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " b of\n\+ \ True | x .> 0 -> b .|| sNot b =: qed\n\+ \ | sTrue -> b .|| sNot b =: qed\n\+ \ False -> b .|| sNot b =: qed\n\+ \ "+ ======>+ cases+ [((.&&) b (x .> 0) ==> (b .|| sNot b =: qed)),+ ((.&&) b (sNot (x .> 0)) ==> (b .|| sNot b =: qed)),+ (sNot b ==> (b .|| sNot b =: qed))]+PCase69.hs:16:57: error: [GHC-40910] [-Wunused-matches, Werror=unused-matches]+ Defined but not used: x+ |+16 | t = calc "t" (\(Forall @"b" (b :: SBool)) (Forall @"x" (x :: SInteger)) -> b .|| sNot b) $ \b x -> []+ | ^+
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase70.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Integer literal patterns and wildcard+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "x" Integer -> SBool))+t = calc "t" (\(Forall @"x" (x :: SInteger)) -> x .== x) $ \x -> []+ |- [pCase| x of+ 0 -> x .== x =: qed+ 1 -> x .== x =: qed+ _ -> x .== x =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase70.stderr view
@@ -0,0 +1,14 @@+PCase70.hs:(17,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " x of\n\+ \ 0 -> x .== x =: qed\n\+ \ 1 -> x .== x =: qed\n\+ \ _ -> x .== x =: qed\n\+ \ "+ ======>+ cases+ [((.==) x 0 ==> (x .== x =: qed)),+ ((.&&) (sNot ((.==) x 0)) ((.==) x 1) ==> (x .== x =: qed)),+ (sNot ((.||) ((.==) x 0) ((.&&) (sNot ((.==) x 0)) ((.==) x 1)))+ ==> (x .== x =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase71.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Char literal patterns and wildcard+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "c" Char -> SBool))+t = calc "t" (\(Forall @"c" (c :: SChar)) -> c .== c) $ \c -> []+ |- [pCase| c of+ 'a' -> c .== c =: qed+ 'b' -> c .== c =: qed+ _ -> c .== c =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase71.stderr view
@@ -0,0 +1,18 @@+PCase71.hs:(17,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " c of\n\+ \ 'a' -> c .== c =: qed\n\+ \ 'b' -> c .== c =: qed\n\+ \ _ -> c .== c =: qed\n\+ \ "+ ======>+ cases+ [((.==) c (literal 'a') ==> (c .== c =: qed)),+ ((.&&) (sNot ((.==) c (literal 'a'))) ((.==) c (literal 'b'))+ ==> (c .== c =: qed)),+ (sNot+ ((.||)+ ((.==) c (literal 'a'))+ ((.&&) (sNot ((.==) c (literal 'a'))) ((.==) c (literal 'b'))))+ ==> (c .== c =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase72.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with String literal patterns and wildcard+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "s" String -> SBool))+t = calc "t" (\(Forall @"s" (s :: SString)) -> s .== s) $ \s -> []+ |- [pCase| s of+ "hello" -> s .== s =: qed+ _ -> s .== s =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase72.stderr view
@@ -0,0 +1,11 @@+PCase72.hs:(17,15)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " s of\n\+ \ \"hello\" -> s .== s =: qed\n\+ \ _ -> s .== s =: qed\n\+ \ "+ ======>+ cases+ [((.==) s (literal "hello") ==> (s .== s =: qed)),+ (sNot ((.==) s (literal "hello")) ==> (s .== s =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase73.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Integer variable binding and guard+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "x" Integer -> SBool))+t = calc "t" (\(Forall @"x" (x :: SInteger)) -> x .== x) $ \x -> []+ |- [pCase| x of+ 0 -> x .== x =: qed+ n | n .> 0 -> x .== x =: qed+ | sTrue -> x .== x =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase73.stderr view
@@ -0,0 +1,17 @@+PCase73.hs:(17,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " x of\n\+ \ 0 -> x .== x =: qed\n\+ \ n | n .> 0 -> x .== x =: qed\n\+ \ | sTrue -> x .== x =: qed\n\+ \ "+ ======>+ cases+ [((.==) x 0 ==> (x .== x =: qed)),+ ((.&&) (sNot ((.==) x 0)) (let n = x in n .> 0)+ ==> (x .== x =: qed)),+ (sNot+ ((.||)+ ((.==) x 0) ((.&&) (sNot ((.==) x 0)) (let n = x in n .> 0)))+ ==> (x .== x =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase74.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Integer, no wildcard (only literals) — should fail with non-exhaustive+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "x" Integer -> SBool))+t = calc "t" (\(Forall @"x" (x :: SInteger)) -> x .== x) $ \x -> []+ |- [pCase| x of+ 0 -> x .== x =: qed+ 1 -> x .== x =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase74.stderr view
@@ -0,0 +1,14 @@+PCase74.hs:17:15: error: [GHC-39584]+ " PCase74.hs:18:10: pCase: Non-exhaustive pattern match.+ All branches are guarded; add an unguarded wildcard or variable+ as the last branch to ensure all cases are covered.++ " In the quasi-quotation:+ [pCase| x of+ 0 -> x .== x =: qed+ 1 -> x .== x =: qed+ |]+ |+17 | |- [pCase| x of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase75.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with Bool non-exhaustive (only True)+-- (sCase would reject as non-exhaustive; pCase is fine)+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "b" Bool -> SBool))+t = calc "t" (\(Forall @"b" (b :: SBool)) -> b .== b) $ \b -> []+ |- [pCase| b of+ True -> b .== b =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase75.stderr view
@@ -0,0 +1,8 @@+PCase75.hs:(18,15)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " b of\n\+ \ True -> b .== b =: qed\n\+ \ "+ ======>+ cases [(b ==> (b .== b =: qed))]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase76.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeAbstractions #-}+{-# LANGUAGE TypeApplications #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: pCase with negative integer literal+module T where++import Data.SBV+import Data.SBV.TP++t :: TP (Proof (Forall "x" Integer -> SBool))+t = calc "t" (\(Forall @"x" (x :: SInteger)) -> x .== x) $ \x -> []+ |- [pCase| x of+ 0 -> x .== x =: qed+ (-1) -> x .== x =: qed+ _ -> x .== x =: qed+ |]
+ SBVTestSuite/TestSuite/CompileTests/PCase/PCase76.stderr view
@@ -0,0 +1,14 @@+PCase76.hs:(17,15)-(21,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ pCase+ " x of\n\+ \ 0 -> x .== x =: qed\n\+ \ (-1) -> x .== x =: qed\n\+ \ _ -> x .== x =: qed\n\+ \ "+ ======>+ cases+ [((.==) x 0 ==> (x .== x =: qed)),+ ((.&&) (sNot ((.==) x 0)) ((.==) x (-1)) ==> (x .== x =: qed)),+ (sNot ((.||) ((.==) x 0) ((.&&) (sNot ((.==) x 0)) ((.==) x (-1))))+ ==> (x .== x =: qed))]
SBVTestSuite/TestSuite/CompileTests/SCase/SCase01.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,4 +8,4 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of|]+t e = [sCase| e of|]
SBVTestSuite/TestSuite/CompileTests/SCase/SCase01.stderr view
@@ -1,8 +1,8 @@ SCase01.hs:11:14: error: [GHC-39584]- " SCase01.hs:11:13: Parse error: EOF+ " SCase01.hs:11:19: Parse error: EOF - " In the quasi-quotation: [sCase|Expr e of|]+ " In the quasi-quotation: [sCase| e of|] |-11 | t e = [sCase|Expr e of|]- | ^^^^^^^^^^^+11 | t e = [sCase| e of|]+ | ^^^^^^^
SBVTestSuite/TestSuite/CompileTests/SCase/SCase02.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i |]
SBVTestSuite/TestSuite/CompileTests/SCase/SCase02.stderr view
@@ -7,11 +7,11 @@ You can use a '_' to match multiple cases. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> i |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase03.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num _ _ -> i Var _ -> 0
SBVTestSuite/TestSuite/CompileTests/SCase/SCase03.stderr view
@@ -6,7 +6,7 @@ Given : 2 " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num _ _ -> i Var _ -> 0@@ -14,6 +14,6 @@ Let _ _ _ -> 3 |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase04.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV -- Rejected at the top level-[sCase|Expr e of+[sCase| e of Zero -> 0 Num i -> i |]
SBVTestSuite/TestSuite/CompileTests/SCase/SCase04.stderr view
@@ -1,6 +1,6 @@ SCase04.hs:11:8: error: [GHC-39584] sCase: not usable in declaration context |-11 | [sCase|Expr e of- | ^^^^^^^^^...+11 | [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase05.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,4 +9,4 @@ -- bad syntax t :: SExpr -> SInteger-t e = [sCase|Expr e + 1|]+t e = [sCase| e + 1|]
SBVTestSuite/TestSuite/CompileTests/SCase/SCase05.stderr view
@@ -1,13 +1,8 @@ SCase05.hs:12:14: error: [GHC-39584]- " sCase: Failed to parse a symbolic case-expression.-- Instead of: case expr of alts- Write : [sCase|Type expr of alts|]-- where Type is the underlying concrete type of the expression.+ " SCase05.hs:12:20: Parse error: EOF - " In the quasi-quotation: [sCase|Expr e + 1|]+ " In the quasi-quotation: [sCase| e + 1|] |-12 | t e = [sCase|Expr e + 1|]- | ^^^^^^^^^^^^+12 | t e = [sCase| e + 1|]+ | ^^^^^^^^
SBVTestSuite/TestSuite/CompileTests/SCase/SCase06.hs view
@@ -1,12 +1,12 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where import Expr import Data.SBV --- bad type+-- Unknown constructor t :: SExpr -> SInteger-t e = [sCase|FExpr e of Num _ -> 1|]+t e = [sCase| e of FooBar _ -> 1|]
SBVTestSuite/TestSuite/CompileTests/SCase/SCase06.stderr view
@@ -1,12 +1,11 @@ SCase06.hs:12:14: error: [GHC-39584]- " sCase: Unknown symbolic ADT: FExpr+ " sCase: Unknown constructor: FooBar - To use a symbolic case expression, declare your ADT, and then:- mkSymbolic [''FExpr]- In a template-haskell context.+ Cannot find this constructor in scope.+ Make sure the type is declared and mkSymbolic is called. - " In the quasi-quotation: [sCase|FExpr e of Num _ -> 1|]+ " In the quasi-quotation: [sCase| e of FooBar _ -> 1|] |-12 | t e = [sCase|FExpr e of Num _ -> 1|]- | ^^^^^^^^^^^^^^^^^^^^^^^+12 | t e = [sCase| e of FooBar _ -> 1|]+ | ^^^^^^^^^^^^^^^^^^^^^
SBVTestSuite/TestSuite/CompileTests/SCase/SCase07.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i | Just 1 <- Just i -> i Var s -> ite (s .== "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase07.stderr view
@@ -3,7 +3,7 @@ Just 1 <- Just i " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i | Just 1 <- Just i -> i Var s -> ite (s .== "a") 1 2@@ -11,6 +11,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase08.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i | Just 1 <- Just i -> i Var s -> ite (s .== "a") 1 else 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase08.stderr view
@@ -2,7 +2,7 @@ " SCase08.hs:14:50: Parse error: else " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i | Just 1 <- Just i -> i Var s -> ite (s .== "a") 1 else 2@@ -10,6 +10,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase09.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i Viar s -> ite (s .== "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase09.stderr view
@@ -1,7 +1,7 @@ SCase09.hs:11:14: error: [GHC-39584] " SCase09.hs:14:16-21: sCase/pCase: Not in scope: data constructor: Viar " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> i Viar s -> ite (s .== "a") 1 2@@ -9,6 +9,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase10.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase10.stderr view
@@ -1,1 +1,28 @@-There was no failure during compilation.+SCase10.hs:(11,14)-(18,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add (Num i) j -> i + t j\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ j -> const (isNum (getAdd_1 e)) j)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ j -> let i = getNum_1 (getAdd_1 e) in i + t j)+ (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase100.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Top-level as-pattern on Maybe+module T where++import Data.SBV++t :: SMaybe Integer -> SInteger+t m = [sCase| m of+ whole@(Just v) -> v + case whole of+ Just w -> w+ Nothing -> 0+ Nothing -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase100.stderr view
@@ -0,0 +1,16 @@+SCase100.hs:(11,14)-(16,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ whole@(Just v) -> v + case whole of\n\+ \ Just w -> w\n\+ \ Nothing -> 0\n\+ \ Nothing -> 0\n\+ \ "+ ======>+ Data.SBV.Maybe.sCaseMaybe+ 0+ (\ v+ -> let whole = m+ in v + Data.SBV.Maybe.sCaseMaybe 0 (\ w -> w) whole)+ m
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase101.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Nested as-pattern on Either inside Maybe+module T where++import Data.SBV++t :: SMaybe (Either Integer Bool) -> SInteger+t m = [sCase| m of+ Just inner@(Left v) -> v + case inner of+ Left w -> w+ Right _ -> 0+ Just (Right _) -> 1+ Nothing -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase101.stderr view
@@ -0,0 +1,31 @@+SCase101.hs:(11,14)-(17,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ Just inner@(Left v) -> v + case inner of\n\+ \ Left w -> w\n\+ \ Right _ -> 0\n\+ \ Just (Right _) -> 1\n\+ \ Nothing -> 0\n\+ \ "+ ======>+ ite+ ((.&&)+ (Data.SBV.Maybe.isJust m)+ ((\ _ -> Data.SBV.Either.isLeft (Data.SBV.Maybe.getJust_1 m))+ (Data.SBV.Maybe.getJust_1 m)))+ ((\ _+ -> let+ inner = Data.SBV.Maybe.getJust_1 m+ v = Data.SBV.Either.getLeft_1 (Data.SBV.Maybe.getJust_1 m)+ in v + Data.SBV.Either.sCaseEither (\ w -> w) (\ _ -> 0) inner)+ (Data.SBV.Maybe.getJust_1 m))+ (ite+ ((.&&)+ (Data.SBV.Maybe.isJust m)+ ((\ _ -> Data.SBV.Either.isRight (Data.SBV.Maybe.getJust_1 m))+ (Data.SBV.Maybe.getJust_1 m)))+ ((\ _ -> 1) (Data.SBV.Maybe.getJust_1 m))+ (ite+ (Data.SBV.Maybe.isNothing m) 0+ (symWithKind "unmatched_sCase_Maybe_6989586621679034927")))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase102.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: As-pattern on wildcard+module T where++import Data.SBV++t :: SMaybe Integer -> SInteger+t m = [sCase| m of+ x@_ -> case x of+ Just v -> v+ Nothing -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase102.stderr view
@@ -0,0 +1,10 @@+SCase102.hs:(11,14)-(15,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ x@_ -> case x of\n\+ \ Just v -> v\n\+ \ Nothing -> 0\n\+ \ "+ ======>+ let x = m in Data.SBV.Maybe.sCaseMaybe 0 (\ v -> v) x
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase103.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: As-pattern with Expr ADT (recursive use of as-bound name)+module T where++import Expr+import Data.SBV++t :: SExpr -> SInteger+t e = [sCase| e of+ whole@(Add a _) -> t a + t whole+ Num k -> k+ _ -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase103.stderr view
@@ -0,0 +1,12 @@+SCase103.hs:(12,14)-(16,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ whole@(Add a _) -> t a + t whole\n\+ \ Num k -> k\n\+ \ _ -> 0\n\+ \ "+ ======>+ sCaseExpr+ 0 (\ k -> k) (\ _ -> 0) (\ a _ -> let whole = e in (t a) + t whole)+ (\ _ _ _ -> 0) e
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase104.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: As-pattern where binding is unused (should be elided)+module T where++import Data.SBV++t :: SMaybe Integer -> SInteger+t m = [sCase| m of+ _unused@(Just v) -> v+ Nothing -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase104.stderr view
@@ -0,0 +1,9 @@+SCase104.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ _unused@(Just v) -> v\n\+ \ Nothing -> 0\n\+ \ "+ ======>+ Data.SBV.Maybe.sCaseMaybe 0 (\ v -> v) m
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase105.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: As-pattern on list cons pattern+module T where++import Data.SBV++t :: SList Integer -> SInteger+t xs = [sCase| xs of+ a : tl@(_ : _) -> a + case tl of+ b : _ -> b+ [] -> 0+ _ : _ -> 0+ [] -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase105.stderr view
@@ -0,0 +1,34 @@+SCase105.hs:(11,15)-(17,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " xs of\n\+ \ a : tl@(_ : _) -> a + case tl of\n\+ \ b : _ -> b\n\+ \ [] -> 0\n\+ \ _ : _ -> 0\n\+ \ [] -> 0\n\+ \ "+ ======>+ ite+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((\ a _+ -> const+ ((.&&)+ (sNot (Data.SBV.List.null (Data.SBV.List.tail xs)))+ ((.===)+ (Data.SBV.List.tail xs)+ (Data.SBV.List.head (Data.SBV.List.tail xs)+ .: Data.SBV.List.tail (Data.SBV.List.tail xs))))+ a)+ (Data.SBV.List.head xs) (Data.SBV.List.tail xs)))+ ((\ a _+ -> let tl = Data.SBV.List.tail xs+ in+ a + ite+ (sNot (Data.SBV.List.null tl))+ ((\ b _ -> b) (Data.SBV.List.head tl) (Data.SBV.List.tail tl)) 0)+ (Data.SBV.List.head xs) (Data.SBV.List.tail xs))+ (ite+ (sNot (Data.SBV.List.null xs))+ ((\ _ _ -> 0) (Data.SBV.List.head xs) (Data.SBV.List.tail xs)) 0)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase106.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: As-pattern on tuple+module T where++import Data.SBV++t :: STuple Integer Bool -> SInteger+t p = [sCase| p of+ whole@(v, b) -> ite b v (case whole of+ (w, _) -> negate w)+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase106.stderr view
@@ -0,0 +1,16 @@+SCase106.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " p of\n\+ \ whole@(v, b) -> ite b v (case whole of\n\+ \ (w, _) -> negate w)\n\+ \ "+ ======>+ (\ v b+ -> let whole = p+ in+ ite+ b v+ ((\ w _ -> negate w)+ (Data.SBV.Tuple._1 whole) (Data.SBV.Tuple._2 whole)))+ (Data.SBV.Tuple._1 p) (Data.SBV.Tuple._2 p)
SBVTestSuite/TestSuite/CompileTests/SCase/SCase11.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i _ -> 3
SBVTestSuite/TestSuite/CompileTests/SCase/SCase11.stderr view
@@ -5,7 +5,7 @@ SCase11.hs:17:16-28: Let _ _a b " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> i _ -> 3@@ -14,6 +14,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase12.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i _ -> 3
SBVTestSuite/TestSuite/CompileTests/SCase/SCase12.stderr view
@@ -3,13 +3,13 @@ SCase12.hs:15:16: _ " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> i _ -> 3 _ -> 5 |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase13.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i Var {} _ -> ite (s .== "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase13.stderr view
@@ -2,7 +2,7 @@ " SCase13.hs:14:30: Parse error in pattern: Var{} " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> i Var {} _ -> ite (s .== "a") 1 2@@ -10,6 +10,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase14.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i Var s _ -> ite (s .== "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase14.stderr view
@@ -6,7 +6,7 @@ Given : 2 " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> i Var s _ -> ite (s .== "a") 1 2@@ -14,6 +14,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase15.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i Var s -> ite (s .== "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase15.stderr view
@@ -2,7 +2,7 @@ " SCase15.hs:16:20: Parse error in pattern: _ " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> i Var s -> ite (s .== "a") 1 2@@ -10,6 +10,6 @@ _ _ -> 3 |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase16.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i | i .< 3 -> i Var s -> ite (s .== "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase16.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i | i .< 3 -> i Var s -> ite (s .== "a") 1 2@@ -13,6 +13,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase17.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i | i .< 3 -> i Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase17.stderr view
@@ -1,1 +1,24 @@-There was no failure during compilation.+SCase17.hs:(11,14)-(18,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num i | i .< 3 -> i\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add a b -> t a + t b\n\+ \ Num i -> i+1\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ ((.&&) (isNum e) ((\ i -> i .< 3) (getNum_1 e)))+ ((\ i -> i) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ (ite+ (isNum e) ((\ i -> i + 1) (getNum_1 e))+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase18.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> 4 Num i | i .< 3 -> i
SBVTestSuite/TestSuite/CompileTests/SCase/SCase18.stderr view
@@ -6,7 +6,7 @@ SCase18.hs:13:16-20: Num i " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> 4 Num i | i .< 3 -> i@@ -15,6 +15,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase19.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> 4 Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase19.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> 4 Var s -> ite (s .== literal "a") 1 2@@ -14,6 +14,6 @@ _ | 2 .>= 3 -> 4 |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase20.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> 4 Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase20.stderr view
@@ -1,7 +1,7 @@ SCase20.hs:11:14: error: [GHC-39584] " SCase20.hs:17:16: sCase: Wildcard match is redundant " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i -> 4 Var s -> ite (s .== literal "a") 1 2@@ -10,6 +10,6 @@ _ -> 4 |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase21.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i | i .> 4 -> 4 Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase21.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i | i .> 4 -> 4 Var s -> ite (s .== literal "a") 1 2@@ -13,6 +13,6 @@ Let _ _a b -> t b |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase22.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i | i .> 4 -> 4 Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase22.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num i | i .> 4 -> 4 Var s -> ite (s .== literal "a") 1 2@@ -14,6 +14,6 @@ _ | 2 .>= 3 -> 5 |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase23.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> 4 Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase23.stderr view
@@ -1,6 +1,20 @@+SCase23.hs:(11,14)-(17,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num i -> 4\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ sCaseExpr+ 0 (\ i -> 4) (\ s -> ite (s .== literal "a") 1 2)+ (\ a b -> (t a) + t b) (\ _ _a b -> t b) e SCase23.hs:11:14: error: [GHC-40910] [-Wunused-matches, Werror=unused-matches] Defined but not used: i |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase24.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num _ -> 4 Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase24.stderr view
@@ -1,1 +1,26 @@-There was no failure during compilation.+SCase24.hs:(11,14)-(18,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num _ -> 4\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add a b | t a .== 4 -> t b\n\+ \ Let _ _a b -> t b\n\+ \ _ -> 2\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ _ -> 4) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ a b -> const ((t a) .== 4) b) (getAdd_1 e) (getAdd_2 e)))+ ((\ a b -> const (t b) a) (getAdd_1 e) (getAdd_2 e))+ (ite+ (isLet e)+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e)) 2))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase25.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV f :: SExpr -> SInteger-f e = [sCase|Expr e of+f e = [sCase| e of Var s | s .== literal "a" -> 0 | s .== literal "b" .|| s .== literal "c" -> 1 | sTrue -> 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase25.stderr view
@@ -1,6 +1,30 @@+SCase25.hs:(11,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Var s | s .== literal \"a\" -> 0\n\+ \ | s .== literal \"b\" .|| s .== literal \"c\" -> 1\n\+ \ | sTrue -> 2\n\+ \\n\+ \ Num i | sTrue -> 3\n\+ \\n\+ \ _ -> 6\n\+ \ "+ ======>+ ite+ ((.&&) (isVar e) ((\ s -> s .== literal "a") (getVar_1 e)))+ ((\ s -> const 0 s) (getVar_1 e))+ (ite+ ((.&&)+ (isVar e)+ ((\ s -> s .== literal "b" .|| s .== literal "c") (getVar_1 e)))+ ((\ s -> const 1 s) (getVar_1 e))+ (ite+ (isVar e) ((\ s -> const 2 s) (getVar_1 e))+ (ite (isNum e) ((\ i -> 3) (getNum_1 e)) 6))) SCase25.hs:11:14: error: [GHC-40910] [-Wunused-matches, Werror=unused-matches] Defined but not used: i |-11 | f e = [sCase|Expr e of- | ^^^^^^^^^...+11 | f e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase26.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where
SBVTestSuite/TestSuite/CompileTests/SCase/SCase27.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where
SBVTestSuite/TestSuite/CompileTests/SCase/SCase28.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Num i | i .> 3 -> 5 | sTrue -> 12
SBVTestSuite/TestSuite/CompileTests/SCase/SCase28.stderr view
@@ -1,1 +1,25 @@-There was no failure during compilation.+SCase28.hs:(11,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Num i | i .> 3 -> 5\n\+ \ | sTrue -> 12\n\+ \\n\+ \ Zero{} -> 0\n\+ \ Var{} -> 0\n\+ \ Add{} -> 0\n\+ \ Let{} -> 0\n\+ \ "+ ======>+ ite+ ((.&&) (isNum e) ((\ i -> i .> 3) (getNum_1 e)))+ ((\ i -> const 5 i) (getNum_1 e))+ (ite+ (isNum e) ((\ i -> const 12 i) (getNum_1 e))+ (ite+ (isZero e) 0+ (ite+ (isVar e) ((\ _ -> 0) (getVar_1 e))+ (ite+ (isAdd e) ((\ _ _ -> 0) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _ _ -> 0) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase29.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -8,7 +8,7 @@ import Data.SBV t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Num i | i > 3 -> 5 | sTrue -> 12 Num i | i > 12 -> 7
SBVTestSuite/TestSuite/CompileTests/SCase/SCase29.stderr view
@@ -6,7 +6,7 @@ SCase29.hs:12:16-20: Num i " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Num i | i > 3 -> 5 | sTrue -> 12 Num i | i > 12 -> 7@@ -17,6 +17,6 @@ Let{} -> 0 |] |-11 | t e = [sCase|Expr e of- | ^^^^^^^^^...+11 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase30.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -17,7 +17,7 @@ mkSymbolic [''A] t :: SA -> SA-t a = [sCase|A a of+t a = [sCase| a of A u -> sA (u+1) B f -> sB (f+2) C a1 a2 -> sC (t a1) (t a2)
SBVTestSuite/TestSuite/CompileTests/SCase/SCase30.stderr view
@@ -1,1 +1,12 @@-There was no failure during compilation.+SCase30.hs:(20,14)-(24,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " a of\n\+ \ A u -> sA (u+1)\n\+ \ B f -> sB (f+2)\n\+ \ C a1 a2 -> sC (t a1) (t a2)\n\+ \ "+ ======>+ sCaseA+ (\ u -> sA (u + 1)) (\ f -> sB (f + 2))+ (\ a1 a2 -> sC (t a1) (t a2)) a
SBVTestSuite/TestSuite/CompileTests/SCase/SCase31.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where
SBVTestSuite/TestSuite/CompileTests/SCase/SCase32.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE TemplateHaskell #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where
SBVTestSuite/TestSuite/CompileTests/SCase/SCase33.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: deeply nested pattern Add (Add (Num i) j) k t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase33.stderr view
@@ -1,1 +1,34 @@-There was no failure during compilation.+SCase33.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add (Add (Num i) j) k -> i + t j + t k\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ k+ -> const+ ((.&&) (isAdd (getAdd_1 e)) (isNum (getAdd_1 (getAdd_1 e)))) k)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ k+ -> let+ j = getAdd_2 (getAdd_1 e)+ i = getNum_1 (getAdd_1 (getAdd_1 e))+ in i + t j + t k)+ (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase34.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: nested pattern combined with a guard t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase34.stderr view
@@ -1,1 +1,32 @@-There was no failure during compilation.+SCase34.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add (Num i) j | i .> 0 -> i + t j\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ j+ -> const+ ((.&&)+ (isNum (getAdd_1 e)) (let i = getNum_1 (getAdd_1 e) in i .> 0))+ j)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ j -> let i = getNum_1 (getAdd_1 e) in i + t j)+ (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase35.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: nested patterns on both sides of Add t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase35.stderr view
@@ -1,1 +1,32 @@-There was no failure during compilation.+SCase35.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add (Num i) (Num j) -> i + j\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ _ -> (.&&) (isNum (getAdd_1 e)) (isNum (getAdd_2 e)))+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ _+ -> let+ i = getNum_1 (getAdd_1 e)+ j = getNum_1 (getAdd_2 e)+ in i + j)+ (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase36.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: nested pattern with wildcard inside the nested constructor t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase36.stderr view
@@ -1,1 +1,27 @@-There was no failure during compilation.+SCase36.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add (Num _) j -> 1 + t j\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ j -> const (isNum (getAdd_1 e)) j)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ j -> 1 + t j) (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase37.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Negative: literal pattern inside nested position is not supported t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase37.stderr view
@@ -1,1 +1,29 @@-There was no failure during compilation.+SCase37.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Add (Num 0) j -> t j\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _a b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ j+ -> const+ ((.&&) (isNum (getAdd_1 e)) ((.==) (getNum_1 (getAdd_1 e)) 0)) j)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ j -> t j) (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _a b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase38.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Negative: nested constructor with wrong arity (Num takes 1 arg, given 2) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase38.stderr view
@@ -5,7 +5,7 @@ Given : 2 " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2@@ -14,6 +14,6 @@ Let _ _a b -> t b |] |-12 | t e = [sCase|Expr e of- | ^^^^^^^^^...+12 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase39.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Negative: nested constructor that is not in scope t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase39.stderr view
@@ -1,7 +1,7 @@ SCase39.hs:12:14: error: [GHC-39584] " SCase39.hs:16:16-29: sCase/pCase: Not in scope: data constructor: Numb " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2@@ -10,6 +10,6 @@ Let _ _a b -> t b |] |-12 | t e = [sCase|Expr e of- | ^^^^^^^^^...+12 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase40.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: nested pattern using parenthesized constructor (ParensP) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase40.stderr view
@@ -1,1 +1,29 @@-There was no failure during compilation.+SCase40.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var s -> ite (s .== literal \"a\") 1 2\n\+ \ Let _ (Num i) b -> i + t b\n\+ \ Let _ a b -> t a + t b\n\+ \ Add a b -> t a + t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ s -> ite (s .== literal "a") 1 2) (getVar_1 e))+ (ite+ ((.&&)+ (isLet e)+ ((\ _ _ b -> const (isNum (getLet_2 e)) b)+ (getLet_1 e) (getLet_2 e) (getLet_3 e)))+ ((\ _ _ b -> let i = getNum_1 (getLet_2 e) in i + t b)+ (getLet_1 e) (getLet_2 e) (getLet_3 e))+ (ite+ (isLet e)+ ((\ _ a b -> (t a) + t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))+ ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase41.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Negative: nested pattern covers only a subset of Add; missing fallback for Add _ _ t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase41.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2@@ -13,6 +13,6 @@ Let _ _a b -> t b |] |-12 | t e = [sCase|Expr e of- | ^^^^^^^^^...+12 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase42.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Negative: deeply nested pattern covers only a subset of the outermost Add; missing fallback t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2
SBVTestSuite/TestSuite/CompileTests/SCase/SCase42.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num k -> k Var s -> ite (s .== literal "a") 1 2@@ -13,6 +13,6 @@ Let _ _a b -> t b |] |-12 | t e = [sCase|Expr e of- | ^^^^^^^^^...+12 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase43.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: integer literal at top level (Num 1 -> ...) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num 1 -> 100 Num k -> k
SBVTestSuite/TestSuite/CompileTests/SCase/SCase43.stderr view
@@ -1,1 +1,24 @@-There was no failure during compilation.+SCase43.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num 1 -> 100\n\+ \ Num k -> k\n\+ \ Var _ -> -1\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _ b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ ((.&&) (isNum e) ((\ _ -> (.==) (getNum_1 e) 1) (getNum_1 e)))+ ((\ _ -> 100) (getNum_1 e))+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ _ -> negate 1) (getVar_1 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _ b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase44.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: integer literal in nested position (Add (Num 0) j -> ...) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var _ -> -1
SBVTestSuite/TestSuite/CompileTests/SCase/SCase44.stderr view
@@ -1,1 +1,29 @@-There was no failure during compilation.+SCase44.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var _ -> -1\n\+ \ Add (Num 0) j -> t j\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _ b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ _ -> negate 1) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ j+ -> const+ ((.&&) (isNum (getAdd_1 e)) ((.==) (getNum_1 (getAdd_1 e)) 0)) j)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ j -> t j) (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _ b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase45.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: string literal in nested position (Var "x" -> ...) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var "x" -> 42
SBVTestSuite/TestSuite/CompileTests/SCase/SCase45.stderr view
@@ -1,1 +1,25 @@-There was no failure during compilation.+SCase45.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var \"x\" -> 42\n\+ \ Var _ -> -1\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _ b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ ((.&&)+ (isVar e) ((\ _ -> (.==) (getVar_1 e) (literal "x")) (getVar_1 e)))+ ((\ _ -> 42) (getVar_1 e))+ (ite+ (isVar e) ((\ _ -> negate 1) (getVar_1 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _ b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase46.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Positive: integer literals on both sides of nested pattern (Add (Num 1) (Num 2) -> ...) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var _ -> -1
SBVTestSuite/TestSuite/CompileTests/SCase/SCase46.stderr view
@@ -1,1 +1,32 @@-There was no failure during compilation.+SCase46.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var _ -> -1\n\+ \ Add (Num 1) (Num 2) -> 99\n\+ \ Add a b -> t a + t b\n\+ \ Let _ _ b -> t b\n\+ \ "+ ======>+ ite+ (isZero e) 0+ (ite+ (isNum e) ((\ k -> k) (getNum_1 e))+ (ite+ (isVar e) ((\ _ -> negate 1) (getVar_1 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ _+ -> (.&&)+ (isNum (getAdd_1 e))+ ((.&&)+ ((.==) (getNum_1 (getAdd_1 e)) 1)+ ((.&&) (isNum (getAdd_2 e)) ((.==) (getNum_1 (getAdd_2 e)) 2))))+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ _ -> 99) (getAdd_1 e) (getAdd_2 e))+ (ite+ (isAdd e) ((\ a b -> (t a) + t b) (getAdd_1 e) (getAdd_2 e))+ ((\ _ _ b -> t b) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase47.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Negative: Num 1 without a fallback for the Num constructor t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num 1 -> 100 Var _ -> -1
SBVTestSuite/TestSuite/CompileTests/SCase/SCase47.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num 1 -> 100 Var _ -> -1@@ -13,6 +13,6 @@ Let _ _ b -> t b |] |-12 | t e = [sCase|Expr e of- | ^^^^^^^^^...+12 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase48.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE QuasiQuotes #-} -{-# OPTIONS_GHC -Wall -Werror #-}+{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-} module T where @@ -9,7 +9,7 @@ -- Negative: Add (Num 1) j without a fallback for the Add constructor t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num k -> k Var _ -> -1
SBVTestSuite/TestSuite/CompileTests/SCase/SCase48.stderr view
@@ -5,7 +5,7 @@ NB. Guarded match might fail. " In the quasi-quotation:- [sCase|Expr e of+ [sCase| e of Zero -> 0 Num k -> k Var _ -> -1@@ -13,6 +13,6 @@ Let _ _ b -> t b |] |-12 | t e = [sCase|Expr e of- | ^^^^^^^^^...+12 | t e = [sCase| e of+ | ^^^^^...
SBVTestSuite/TestSuite/CompileTests/SCase/SCase49.hs view
@@ -9,7 +9,7 @@ -- Dump test: simple unguarded, all constructors, no guards/wildcards/nesting t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i Var _ -> 1
SBVTestSuite/TestSuite/CompileTests/SCase/SCase49.stderr view
@@ -1,7 +1,7 @@ SCase49.hs:(12,14)-(18,8): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp sCase- "Expr e of\n\+ " e of\n\ \ Zero -> 0\n\ \ Num i -> i\n\ \ Var _ -> 1\n\@@ -9,4 +9,4 @@ \ Let _ _ _ -> 3\n\ \ " ======>- sCaseExpr e 0 (\ i -> i) (\ _ -> 1) (\ _ _ -> 2) (\ _ _ _ -> 3)+ sCaseExpr 0 (\ i -> i) (\ _ -> 1) (\ _ _ -> 2) (\ _ _ _ -> 3) e
SBVTestSuite/TestSuite/CompileTests/SCase/SCase50.hs view
@@ -9,7 +9,7 @@ -- Dump test: multiple guards on same constructor (guard accumulation, ite chain) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i | i .< 3 -> i | i .< 10 -> i + 1
SBVTestSuite/TestSuite/CompileTests/SCase/SCase50.stderr view
@@ -1,7 +1,7 @@ SCase50.hs:(12,14)-(20,8): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp sCase- "Expr e of\n\+ " e of\n\ \ Zero -> 0\n\ \ Num i | i .< 3 -> i\n\ \ | i .< 10 -> i + 1\n\@@ -25,6 +25,4 @@ (isVar e) ((\ _ -> 1) (getVar_1 e)) (ite (isAdd e) ((\ _ _ -> 2) (getAdd_1 e) (getAdd_2 e))- (ite- (isLet e) ((\ _ _ _ -> 3) (getLet_1 e) (getLet_2 e) (getLet_3 e))- (sym "unmatched_sCase_Expr_6989586621679081198")))))))+ ((\ _ _ _ -> 3) (getLet_1 e) (getLet_2 e) (getLet_3 e)))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase51.hs view
@@ -9,7 +9,7 @@ -- Dump test: wildcard catch-all after some constructors (ite chain with default) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Zero -> 0 Num i -> i _ -> 99
SBVTestSuite/TestSuite/CompileTests/SCase/SCase51.stderr view
@@ -1,10 +1,10 @@ SCase51.hs:(12,14)-(16,8): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp sCase- "Expr e of\n\+ " e of\n\ \ Zero -> 0\n\ \ Num i -> i\n\ \ _ -> 99\n\ \ " ======>- sCaseExpr e 0 (\ i -> i) (\ _ -> 99) (\ _ _ -> 99) (\ _ _ _ -> 99)+ sCaseExpr 0 (\ i -> i) (\ _ -> 99) (\ _ _ -> 99) (\ _ _ _ -> 99) e
SBVTestSuite/TestSuite/CompileTests/SCase/SCase52.hs view
@@ -9,7 +9,7 @@ -- Dump test: nested pattern with literal (synthetic guards, accessors, let-bindings) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Add (Num 0) j -> t j Add a b -> t a + t b Zero -> 0
SBVTestSuite/TestSuite/CompileTests/SCase/SCase52.stderr view
@@ -1,7 +1,7 @@ SCase52.hs:(12,14)-(19,8): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp sCase- "Expr e of\n\+ " e of\n\ \ Add (Num 0) j -> t j\n\ \ Add a b -> t a + t b\n\ \ Zero -> 0\n\@@ -26,6 +26,4 @@ (isNum e) ((\ i -> i) (getNum_1 e)) (ite (isVar e) ((\ _ -> 1) (getVar_1 e))- (ite- (isLet e) ((\ _ _ _ -> 3) (getLet_1 e) (getLet_2 e) (getLet_3 e))- (sym "unmatched_sCase_Expr_6989586621679081203"))))))+ ((\ _ _ _ -> 3) (getLet_1 e) (getLet_2 e) (getLet_3 e))))))
SBVTestSuite/TestSuite/CompileTests/SCase/SCase53.hs view
@@ -9,7 +9,7 @@ -- Dump test: nested pattern with user guard (combines nesting + guard accumulation) t :: SExpr -> SInteger-t e = [sCase|Expr e of+t e = [sCase| e of Add (Num i) b | i .> 0 -> i + t b | i .> -5 -> t b Add a b -> t a + t b
SBVTestSuite/TestSuite/CompileTests/SCase/SCase53.stderr view
@@ -1,7 +1,7 @@ SCase53.hs:(12,14)-(20,8): Splicing expression ghc-internal:GHC.Internal.TH.Quote.quoteExp sCase- "Expr e of\n\+ " e of\n\ \ Add (Num i) b | i .> 0 -> i + t b\n\ \ | i .> -5 -> t b\n\ \ Add a b -> t a + t b\n\@@ -41,6 +41,4 @@ (isNum e) ((\ i -> i) (getNum_1 e)) (ite (isVar e) ((\ _ -> 1) (getVar_1 e))- (ite- (isLet e) ((\ _ _ _ -> 3) (getLet_1 e) (getLet_2 e) (getLet_3 e))- (sym "unmatched_sCase_Expr_6989586621679081203")))))))+ ((\ _ _ _ -> 3) (getLet_1 e) (getLet_2 e) (getLet_3 e)))))))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase54.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Maybe (no guards)+module T where++import Data.SBV++t :: SMaybe Integer -> SInteger+t m = [sCase| m of+ Nothing -> 0+ Just x -> x + 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase54.stderr view
@@ -0,0 +1,9 @@+SCase54.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ Nothing -> 0\n\+ \ Just x -> x + 1\n\+ \ "+ ======>+ Data.SBV.Maybe.sCaseMaybe 0 (\ x -> x + 1) m
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase55.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Either (no guards)+module T where++import Data.SBV++t :: SEither Integer Bool -> SInteger+t e = [sCase| e of+ Left a -> a+ Right _ -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase55.stderr view
@@ -0,0 +1,9 @@+SCase55.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Left a -> a\n\+ \ Right _ -> 0\n\+ \ "+ ======>+ Data.SBV.Either.sCaseEither (\ a -> a) (\ _ -> 0) e
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase56.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE OverloadedLists #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with List (no guards)+module T where++import Prelude hiding (null, head, tail)+import Data.SBV++t :: SList Integer -> SInteger+t xs = [sCase| xs of+ [] -> 0+ y : ys -> y + t ys+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase56.stderr view
@@ -0,0 +1,12 @@+SCase56.hs:(13,15)-(16,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " xs of\n\+ \ [] -> 0\n\+ \ y : ys -> y + t ys\n\+ \ "+ ======>+ ite+ (Data.SBV.List.null xs) 0+ ((\ y ys -> y + t ys)+ (Data.SBV.List.head xs) (Data.SBV.List.tail xs))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase57.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Tuple2+module T where++import Data.SBV++t :: STuple Integer Bool -> SInteger+t p = [sCase| p of+ (a, _) -> a + 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase57.stderr view
@@ -0,0 +1,8 @@+SCase57.hs:(11,14)-(13,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " p of\n\+ \ (a, _) -> a + 1\n\+ \ "+ ======>+ (\ a _ -> a + 1) (Data.SBV.Tuple._1 p) (Data.SBV.Tuple._2 p)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase58.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE OverloadedLists #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with List, nested cons pattern+module T where++import Prelude hiding (null, head, tail)+import Data.SBV++t :: SList Integer -> SInteger+t xs = [sCase| xs of+ [] -> 0+ a : (b : _) -> a + b+ _ : _ -> 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase58.stderr view
@@ -0,0 +1,28 @@+SCase58.hs:(13,15)-(17,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " xs of\n\+ \ [] -> 0\n\+ \ a : (b : _) -> a + b\n\+ \ _ : _ -> 1\n\+ \ "+ ======>+ ite+ (Data.SBV.List.null xs) 0+ (ite+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((\ a _+ -> const+ ((.&&)+ (sNot (Data.SBV.List.null (Data.SBV.List.tail xs)))+ ((.===)+ (Data.SBV.List.tail xs)+ (Data.SBV.List.head (Data.SBV.List.tail xs)+ .: Data.SBV.List.tail (Data.SBV.List.tail xs))))+ a)+ (Data.SBV.List.head xs) (Data.SBV.List.tail xs)))+ ((\ a _+ -> let b = Data.SBV.List.head (Data.SBV.List.tail xs) in a + b)+ (Data.SBV.List.head xs) (Data.SBV.List.tail xs))+ ((\ _ _ -> 1) (Data.SBV.List.head xs) (Data.SBV.List.tail xs)))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase59.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Maybe, nested Either pattern+module T where++import Data.SBV++t :: SMaybe (Either Integer Bool) -> SInteger+t m = [sCase| m of+ Nothing -> 0+ Just (Left x) -> x+ Just (Right _) -> 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase59.stderr view
@@ -0,0 +1,27 @@+SCase59.hs:(11,14)-(15,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ Nothing -> 0\n\+ \ Just (Left x) -> x\n\+ \ Just (Right _) -> 1\n\+ \ "+ ======>+ ite+ (Data.SBV.Maybe.isNothing m) 0+ (ite+ ((.&&)+ (Data.SBV.Maybe.isJust m)+ ((\ _ -> Data.SBV.Either.isLeft (Data.SBV.Maybe.getJust_1 m))+ (Data.SBV.Maybe.getJust_1 m)))+ ((\ _+ -> let x = Data.SBV.Either.getLeft_1 (Data.SBV.Maybe.getJust_1 m)+ in x)+ (Data.SBV.Maybe.getJust_1 m))+ (ite+ ((.&&)+ (Data.SBV.Maybe.isJust m)+ ((\ _ -> Data.SBV.Either.isRight (Data.SBV.Maybe.getJust_1 m))+ (Data.SBV.Maybe.getJust_1 m)))+ ((\ _ -> 1) (Data.SBV.Maybe.getJust_1 m))+ (symWithKind "unmatched_sCase_Maybe_6989586621679034927")))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase60.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE OverloadedLists #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with List and guards+module T where++import Prelude hiding (null, head, tail)+import Data.SBV++t :: SList Integer -> SInteger+t xs = [sCase| xs of+ [] -> 0+ y : _ | y .== 5 -> 100+ _ : ys -> t ys+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase60.stderr view
@@ -0,0 +1,19 @@+SCase60.hs:(13,15)-(17,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " xs of\n\+ \ [] -> 0\n\+ \ y : _ | y .== 5 -> 100\n\+ \ _ : ys -> t ys\n\+ \ "+ ======>+ ite+ (Data.SBV.List.null xs) 0+ (ite+ ((.&&)+ (sNot (Data.SBV.List.null xs))+ ((\ y _ -> y .== 5)+ (Data.SBV.List.head xs) (Data.SBV.List.tail xs)))+ ((\ y _ -> const 100 y)+ (Data.SBV.List.head xs) (Data.SBV.List.tail xs))+ ((\ _ ys -> t ys) (Data.SBV.List.head xs) (Data.SBV.List.tail xs)))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase61.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Maybe, guards on Just+module T where++import Data.SBV++t :: SMaybe Integer -> SInteger+t m = [sCase| m of+ Nothing -> 0+ Just x | x .> 5 -> x * 2+ Just x -> x+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase61.stderr view
@@ -0,0 +1,17 @@+SCase61.hs:(11,14)-(15,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ Nothing -> 0\n\+ \ Just x | x .> 5 -> x * 2\n\+ \ Just x -> x\n\+ \ "+ ======>+ ite+ (Data.SBV.Maybe.isNothing m) 0+ (ite+ ((.&&)+ (Data.SBV.Maybe.isJust m)+ ((\ x -> x .> 5) (Data.SBV.Maybe.getJust_1 m)))+ ((\ x -> x * 2) (Data.SBV.Maybe.getJust_1 m))+ ((\ x -> x) (Data.SBV.Maybe.getJust_1 m)))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase62.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Either, guards and wildcard+module T where++import Data.SBV++t :: SEither Integer Integer -> SInteger+t e = [sCase| e of+ Left x | x .> 0 -> x+ _ -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase62.stderr view
@@ -0,0 +1,13 @@+SCase62.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Left x | x .> 0 -> x\n\+ \ _ -> 0\n\+ \ "+ ======>+ ite+ ((.&&)+ (Data.SBV.Either.isLeft e)+ ((\ x -> x .> 0) (Data.SBV.Either.getLeft_1 e)))+ ((\ x -> x) (Data.SBV.Either.getLeft_1 e)) 0
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase63.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Tuple3+module T where++import Data.SBV++t :: STuple3 Integer Integer Bool -> SInteger+t p = [sCase| p of+ (a, b, _) -> a + b+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase63.stderr view
@@ -0,0 +1,9 @@+SCase63.hs:(11,14)-(13,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " p of\n\+ \ (a, b, _) -> a + b\n\+ \ "+ ======>+ (\ a b _ -> a + b)+ (Data.SBV.Tuple._1 p) (Data.SBV.Tuple._2 p) (Data.SBV.Tuple._3 p)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase64.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE OverloadedLists #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with List, wildcard only for cons+module T where++import Prelude hiding (null, head, tail)+import Data.SBV++t :: SList Integer -> SBool+t xs = [sCase| xs of+ [] -> sTrue+ _ : _ -> sFalse+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase64.stderr view
@@ -0,0 +1,11 @@+SCase64.hs:(13,15)-(16,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " xs of\n\+ \ [] -> sTrue\n\+ \ _ : _ -> sFalse\n\+ \ "+ ======>+ ite+ (Data.SBV.List.null xs) sTrue+ ((\ _ _ -> sFalse) (Data.SBV.List.head xs) (Data.SBV.List.tail xs))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase65.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with nested tuple inside Maybe+module T where++import Data.SBV++t :: SMaybe (Integer, Bool) -> SInteger+t m = [sCase| m of+ Nothing -> 0+ Just (a, _) -> a+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase65.stderr view
@@ -0,0 +1,13 @@+SCase65.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " m of\n\+ \ Nothing -> 0\n\+ \ Just (a, _) -> a\n\+ \ "+ ======>+ Data.SBV.Maybe.sCaseMaybe+ 0+ (\ _+ -> let a = Data.SBV.Tuple._1 (Data.SBV.Maybe.getJust_1 m) in a)+ m
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase66.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE OverloadedLists #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with nested list inside Either+module T where++import Prelude hiding (null, head, tail)+import Data.SBV++t :: SEither ([] Integer) Bool -> SInteger+t e = [sCase| e of+ Left (x : _) -> x+ Left [] -> 0+ Right _ -> 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase66.stderr view
@@ -0,0 +1,33 @@+SCase66.hs:(13,14)-(17,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Left (x : _) -> x\n\+ \ Left [] -> 0\n\+ \ Right _ -> 1\n\+ \ "+ ======>+ ite+ ((.&&)+ (Data.SBV.Either.isLeft e)+ ((\ _+ -> (.&&)+ (sNot (Data.SBV.List.null (Data.SBV.Either.getLeft_1 e)))+ ((.===)+ (Data.SBV.Either.getLeft_1 e)+ (Data.SBV.List.head (Data.SBV.Either.getLeft_1 e)+ .: Data.SBV.List.tail (Data.SBV.Either.getLeft_1 e))))+ (Data.SBV.Either.getLeft_1 e)))+ ((\ _+ -> let x = Data.SBV.List.head (Data.SBV.Either.getLeft_1 e) in x)+ (Data.SBV.Either.getLeft_1 e))+ (ite+ ((.&&)+ (Data.SBV.Either.isLeft e)+ ((\ _ -> Data.SBV.List.null (Data.SBV.Either.getLeft_1 e))+ (Data.SBV.Either.getLeft_1 e)))+ ((\ _ -> 0) (Data.SBV.Either.getLeft_1 e))+ (ite+ (Data.SBV.Either.isRight e)+ ((\ _ -> 1) (Data.SBV.Either.getRight_1 e))+ (symWithKind "unmatched_sCase_Either_6989586621679034889")))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase67.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Tuple2 with guard+module T where++import Data.SBV++t :: STuple Integer Integer -> SInteger+t p = [sCase| p of+ (a, b) | a .> b -> a+ (_, b) -> b+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase67.stderr view
@@ -0,0 +1,12 @@+SCase67.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " p of\n\+ \ (a, b) | a .> b -> a\n\+ \ (_, b) -> b\n\+ \ "+ ======>+ ite+ ((\ a b -> a .> b) (Data.SBV.Tuple._1 p) (Data.SBV.Tuple._2 p))+ ((\ a b -> const a b) (Data.SBV.Tuple._1 p) (Data.SBV.Tuple._2 p))+ ((\ _ b -> b) (Data.SBV.Tuple._1 p) (Data.SBV.Tuple._2 p))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase68.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with wildcard-only, no guards+module T where++import Data.SBV++t :: SInteger -> SInteger+t x = [sCase| x of+ _ -> x + 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase68.stderr view
@@ -0,0 +1,8 @@+SCase68.hs:(11,14)-(13,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ _ -> x + 1\n\+ \ "+ ======>+ x + 1
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase69.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with guarded wildcards only+module T where++import Data.SBV++t :: SInteger -> SInteger+t x = [sCase| x of+ _ | x .> 0 -> x+ | sTrue -> -x+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase69.stderr view
@@ -0,0 +1,9 @@+SCase69.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ _ | x .> 0 -> x\n\+ \ | sTrue -> -x\n\+ \ "+ ======>+ ite (x .> 0) x (negate x)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase70.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with integer literal pattern and wildcard+module T where++import Data.SBV++t :: SInteger -> SBool+t x = [sCase| x of+ 0 -> sTrue+ _ -> sFalse+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase70.stderr view
@@ -0,0 +1,9 @@+SCase70.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> sTrue\n\+ \ _ -> sFalse\n\+ \ "+ ======>+ ite ((.==) x 0) sTrue sFalse
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase71.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with multiple integer literals and wildcard+module T where++import Data.SBV++t :: SInteger -> SInteger+t x = [sCase| x of+ 0 -> 10+ 1 -> 20+ 2 -> 30+ _ -> x+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase71.stderr view
@@ -0,0 +1,11 @@+SCase71.hs:(11,14)-(16,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> 10\n\+ \ 1 -> 20\n\+ \ 2 -> 30\n\+ \ _ -> x\n\+ \ "+ ======>+ ite ((.==) x 0) 10 (ite ((.==) x 1) 20 (ite ((.==) x 2) 30 x))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase72.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with integer literal and variable binding+module T where++import Data.SBV++t :: SInteger -> SInteger+t x = [sCase| x of+ 0 -> 0+ n -> n + 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase72.stderr view
@@ -0,0 +1,9 @@+SCase72.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> 0\n\+ \ n -> n + 1\n\+ \ "+ ======>+ ite ((.==) x 0) 0 (let n = x in n + 1)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase73.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with char literal patterns+module T where++import Data.SBV++t :: SChar -> SBool+t c = [sCase| c of+ 'a' -> sTrue+ 'b' -> sTrue+ _ -> sFalse+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase73.stderr view
@@ -0,0 +1,12 @@+SCase73.hs:(11,14)-(15,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " c of\n\+ \ 'a' -> sTrue\n\+ \ 'b' -> sTrue\n\+ \ _ -> sFalse\n\+ \ "+ ======>+ ite+ ((.==) c (literal 'a')) sTrue+ (ite ((.==) c (literal 'b')) sTrue sFalse)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase74.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with integer literal and guard+module T where++import Data.SBV++t :: SInteger -> SInteger -> SInteger+t x y = [sCase| x of+ 0 -> y+ _ | x .> y -> x+ | sTrue -> y+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase74.stderr view
@@ -0,0 +1,10 @@+SCase74.hs:(11,16)-(15,10): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> y\n\+ \ _ | x .> y -> x\n\+ \ | sTrue -> y\n\+ \ "+ ======>+ ite ((.==) x 0) y (ite (x .> y) x y)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase75.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with string literal patterns+module T where++import Data.SBV++t :: SString -> SInteger+t s = [sCase| s of+ "hello" -> 1+ "world" -> 2+ _ -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase75.stderr view
@@ -0,0 +1,11 @@+SCase75.hs:(11,14)-(15,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " s of\n\+ \ \"hello\" -> 1\n\+ \ \"world\" -> 2\n\+ \ _ -> 0\n\+ \ "+ ======>+ ite+ ((.==) s (literal "hello")) 1 (ite ((.==) s (literal "world")) 2 0)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase76.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with negative integer literal (uses LitP with negative value)+module T where++import Data.SBV++t :: SInteger -> SBool+t x = [sCase| x of+ 0 -> sTrue+ (-1) -> sTrue+ _ -> sFalse+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase76.stderr view
@@ -0,0 +1,10 @@+SCase76.hs:(11,14)-(15,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> sTrue\n\+ \ (-1) -> sTrue\n\+ \ _ -> sFalse\n\+ \ "+ ======>+ ite ((.==) x 0) sTrue (ite ((.==) x (-1)) sTrue sFalse)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase77.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with integer literal patterns (no dump, just compilation check)+-- Tests that the generated code actually type-checks with SBV types+module T where++import Data.SBV++clamp :: SInteger -> SInteger+clamp x = [sCase| x of+ 0 -> 0+ 1 -> 1+ n -> ite (n .> 0) 100 (-100)+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase77.stderr view
@@ -0,0 +1,12 @@+SCase77.hs:(12,18)-(16,13): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> 0\n\+ \ 1 -> 1\n\+ \ n -> ite (n .> 0) 100 (-100)\n\+ \ "+ ======>+ ite+ ((.==) x 0) 0+ (ite ((.==) x 1) 1 (let n = x in ite (n .> 0) 100 (negate 100)))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase78.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Bool constructor patterns+module T where++import Data.SBV++t :: SBool -> SBool+t x = [sCase| x of+ True -> sTrue+ False -> sFalse+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase78.stderr view
@@ -0,0 +1,9 @@+SCase78.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ True -> sTrue\n\+ \ False -> sFalse\n\+ \ "+ ======>+ ite x sTrue sFalse
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase79.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Bool patterns and guard+module T where++import Data.SBV++t :: SBool -> SInteger -> SInteger+t b x = [sCase| b of+ True | x .> 0 -> x+ True -> 0+ False -> -x+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase79.stderr view
@@ -0,0 +1,10 @@+SCase79.hs:(11,16)-(15,10): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " b of\n\+ \ True | x .> 0 -> x\n\+ \ True -> 0\n\+ \ False -> -x\n\+ \ "+ ======>+ ite ((.&&) b (x .> 0)) x (ite b 0 (negate x))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase80.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase Bool non-exhaustive (only True, no wildcard) — should fail+module T where++import Data.SBV++t :: SBool -> SInteger+t x = [sCase| x of+ True -> 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase80.stderr view
@@ -0,0 +1,16 @@+SCase80.hs:11:14: error: [GHC-39584]+ " sCase: Pattern match(es) are non-exhaustive.+ Not matched : False+ Patterns of type: Bool+ Must match each : True, False++ You can use a '_' to match multiple cases.++ " In the quasi-quotation:+ [sCase| x of+ True -> 1+ |]+ |+11 | t x = [sCase| x of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase81.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase Bool with wildcard catch-all+module T where++import Data.SBV++t :: SBool -> SInteger+t x = [sCase| x of+ True -> 1+ _ -> 0+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase81.stderr view
@@ -0,0 +1,9 @@+SCase81.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ True -> 1\n\+ \ _ -> 0\n\+ \ "+ ======>+ ite x 1 0
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase82.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Word8 integer literal patterns+module T where++import Data.SBV++t :: SWord8 -> SWord8+t x = [sCase| x of+ 0 -> 10+ 1 -> 20+ _ -> x+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase82.stderr view
@@ -0,0 +1,10 @@+SCase82.hs:(12,14)-(16,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> 10\n\+ \ 1 -> 20\n\+ \ _ -> x\n\+ \ "+ ======>+ ite ((.==) x 0) 10 (ite ((.==) x 1) 20 x)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase83.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Int16 integer literals, variable binding, and guard+module T where++import Data.SBV++t :: SInt16 -> SInt16+t x = [sCase| x of+ 0 -> 0+ 1 -> 100+ n | n .> 0 -> n+ | sTrue -> -n+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase83.stderr view
@@ -0,0 +1,16 @@+SCase83.hs:(12,14)-(17,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> 0\n\+ \ 1 -> 100\n\+ \ n | n .> 0 -> n\n\+ \ | sTrue -> -n\n\+ \ "+ ======>+ ite+ ((.==) x 0) 0+ (ite+ ((.==) x 1) 100+ (ite+ (let n = x in n .> 0) (let n = x in n) (let n = x in negate n)))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase84.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase Integer non-exhaustive (all guarded, no catch-all) — should fail+module T where++import Data.SBV++t :: SInteger -> SBool+t x = [sCase| x of+ 0 -> sTrue+ 1 -> sFalse+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase84.stderr view
@@ -0,0 +1,14 @@+SCase84.hs:11:14: error: [GHC-39584]+ " SCase84.hs:12:16: sCase: Non-exhaustive pattern match.+ All branches are guarded; add an unguarded wildcard or variable+ as the last branch to ensure all cases are covered.++ " In the quasi-quotation:+ [sCase| x of+ 0 -> sTrue+ 1 -> sFalse+ |]+ |+11 | t x = [sCase| x of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase85.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase Bool reversed order (False first, then True)+module T where++import Data.SBV++t :: SBool -> SInteger+t x = [sCase| x of+ False -> 0+ True -> 1+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase85.stderr view
@@ -0,0 +1,9 @@+SCase85.hs:(11,14)-(14,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ False -> 0\n\+ \ True -> 1\n\+ \ "+ ======>+ ite (sNot x) 0 1
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase86.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE DataKinds #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase with Word8 and mixed literal/variable/wildcard+module T where++import Data.SBV++t :: SWord8 -> SWord8 -> SWord8+t x y = [sCase| x of+ 0 -> y+ n | n .> y -> n+ | sTrue -> y+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase86.stderr view
@@ -0,0 +1,10 @@+SCase86.hs:(12,16)-(16,10): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " x of\n\+ \ 0 -> y\n\+ \ n | n .> y -> n\n\+ \ | sTrue -> y\n\+ \ "+ ======>+ ite ((.==) x 0) y (ite (let n = x in n .> y) (let n = x in n) y)
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase87.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase String non-exhaustive (only literals, no catch-all) — should fail+module T where++import Data.SBV++t :: SString -> SInteger+t s = [sCase| s of+ "hello" -> 1+ "world" -> 2+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase87.stderr view
@@ -0,0 +1,14 @@+SCase87.hs:11:14: error: [GHC-39584]+ " SCase87.hs:12:16-22: sCase: Non-exhaustive pattern match.+ All branches are guarded; add an unguarded wildcard or variable+ as the last branch to ensure all cases are covered.++ " In the quasi-quotation:+ [sCase| s of+ "hello" -> 1+ "world" -> 2+ |]+ |+11 | t s = [sCase| s of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase88.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Test: sCase Char non-exhaustive (only literals, no catch-all) — should fail+module T where++import Data.SBV++t :: SChar -> SBool+t c = [sCase| c of+ 'x' -> sTrue+ 'y' -> sFalse+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase88.stderr view
@@ -0,0 +1,14 @@+SCase88.hs:11:14: error: [GHC-39584]+ " SCase88.hs:12:16-18: sCase: Non-exhaustive pattern match.+ All branches are guarded; add an unguarded wildcard or variable+ as the last branch to ensure all cases are covered.++ " In the quasi-quotation:+ [sCase| c of+ 'x' -> sTrue+ 'y' -> sFalse+ |]+ |+11 | t c = [sCase| c of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase89.hs view
@@ -0,0 +1,19 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++module T where++import Expr+import Data.SBV++-- Dump test: nested pattern with user guard (combines nesting + guard accumulation)+t :: SExpr -> SInteger+t e = [sCase| e of+ Add (Num i) b | i .> 0 -> i + t b+ | i .> -5 -> t b+ Zero -> 0+ Num i -> i+ Var _ -> 1+ Let _ _ _ -> 3+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase89.stderr view
@@ -0,0 +1,43 @@+SCase89.hs:(12,14)-(19,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Add (Num i) b | i .> 0 -> i + t b\n\+ \ | i .> -5 -> t b\n\+ \ Zero -> 0\n\+ \ Num i -> i\n\+ \ Var _ -> 1\n\+ \ Let _ _ _ -> 3\n\+ \ "+ ======>+ ite+ ((.&&)+ (isAdd e)+ ((\ _ b+ -> const+ ((.&&)+ (isNum (getAdd_1 e)) (let i = getNum_1 (getAdd_1 e) in i .> 0))+ b)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ b -> let i = getNum_1 (getAdd_1 e) in i + t b)+ (getAdd_1 e) (getAdd_2 e))+ (ite+ ((.&&)+ (isAdd e)+ ((\ _ b+ -> const+ ((.&&)+ (isNum (getAdd_1 e))+ (let i = getNum_1 (getAdd_1 e) in i .> negate 5))+ b)+ (getAdd_1 e) (getAdd_2 e)))+ ((\ _ b -> t b) (getAdd_1 e) (getAdd_2 e))+ (ite+ (isZero e) 0+ (ite+ (isNum e) ((\ i -> i) (getNum_1 e))+ (ite+ (isVar e) ((\ _ -> 1) (getVar_1 e))+ (ite+ (isLet e) ((\ _ _ _ -> 3) (getLet_1 e) (getLet_2 e) (getLet_3 e))+ (symWithKind "unmatched_sCase_Expr_6989586621679081395"))))))
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase90.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Nested case expressions. Inner case on Maybe inside outer case on Expr.+module T where++import Expr+import Data.SBV++t :: SExpr -> SMaybe Integer -> SInteger+t e m = [sCase| e of+ Zero -> case m of+ Nothing -> 0+ Just v -> v+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase90.stderr view
@@ -0,0 +1,16 @@+SCase90.hs:(12,16)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> case m of\n\+ \ Nothing -> 0\n\+ \ Just v -> v\n\+ \ Num k -> k\n\+ \ Var _ -> -1\n\+ \ Add a b -> t a m + t b m\n\+ \ Let _ _ b -> t b m\n\+ \ "+ ======>+ sCaseExpr+ (Data.SBV.Maybe.sCaseMaybe 0 (\ v -> v) m) (\ k -> k)+ (\ _ -> negate 1) (\ a b -> (t a m) + t b m) (\ _ _ b -> t b m) e
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase91.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Same-type nesting. Inner case on Expr inside outer case on Expr.+module T where++import Expr+import Data.SBV++t :: SExpr -> SInteger+t e = [sCase| e of+ Zero -> 0+ Num k -> k+ Var _ -> -1+ Add a b -> case a of+ Zero -> t b+ Num k -> k + t b+ Var _ -> t b+ Add _ _ -> t a + t b+ Let _ _ c -> t c + t b+ Let _ _ b -> t b+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase91.stderr view
@@ -0,0 +1,23 @@+SCase91.hs:(12,14)-(23,8): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> 0\n\+ \ Num k -> k\n\+ \ Var _ -> -1\n\+ \ Add a b -> case a of\n\+ \ Zero -> t b\n\+ \ Num k -> k + t b\n\+ \ Var _ -> t b\n\+ \ Add _ _ -> t a + t b\n\+ \ Let _ _ c -> t c + t b\n\+ \ Let _ _ b -> t b\n\+ \ "+ ======>+ sCaseExpr+ 0 (\ k -> k) (\ _ -> negate 1)+ (\ a b+ -> sCaseExpr+ (t b) (\ k -> k + t b) (\ _ -> t b) (\ _ _ -> (t a) + t b)+ (\ _ _ c -> (t c) + t b) a)+ (\ _ _ b -> t b) e
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase92.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Deep nesting (3 levels). Outer Expr, inner Maybe, innermost Either.+module T where++import Expr+import Data.SBV++t :: SExpr -> SMaybe (Either Integer Bool) -> SInteger+t e m = [sCase| e of+ Zero -> case m of+ Nothing -> 0+ Just v -> case v of+ Left x -> x+ Right _ -> 1+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase92.stderr view
@@ -0,0 +1,20 @@+SCase92.hs:(12,16)-(22,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> case m of\n\+ \ Nothing -> 0\n\+ \ Just v -> case v of\n\+ \ Left x -> x\n\+ \ Right _ -> 1\n\+ \ Num k -> k\n\+ \ Var _ -> -1\n\+ \ Add a b -> t a m + t b m\n\+ \ Let _ _ b -> t b m\n\+ \ "+ ======>+ sCaseExpr+ (Data.SBV.Maybe.sCaseMaybe+ 0 (\ v -> Data.SBV.Either.sCaseEither (\ x -> x) (\ _ -> 1) v) m)+ (\ k -> k) (\ _ -> negate 1) (\ a b -> (t a m) + t b m)+ (\ _ _ b -> t b m) e
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase93.hs view
@@ -0,0 +1,22 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Nested case in multiple branches of outer case.+module T where++import Expr+import Data.SBV++t :: SExpr -> SBool -> SInteger+t e b = [sCase| e of+ Zero -> case b of+ True -> 1+ False -> 0+ Num k -> case b of+ True -> k+ False -> -k+ Var _ -> -1+ Add a _ -> t a b+ Let _ _ c -> t c b+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase93.stderr view
@@ -0,0 +1,18 @@+SCase93.hs:(12,16)-(22,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> case b of\n\+ \ True -> 1\n\+ \ False -> 0\n\+ \ Num k -> case b of\n\+ \ True -> k\n\+ \ False -> -k\n\+ \ Var _ -> -1\n\+ \ Add a _ -> t a b\n\+ \ Let _ _ c -> t c b\n\+ \ "+ ======>+ sCaseExpr+ (ite b 1 0) (\ k -> ite b k (negate k)) (\ _ -> negate 1)+ (\ a _ -> t a b) (\ _ _ c -> t c b) e
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase94.hs view
@@ -0,0 +1,20 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Nested case with wildcard in inner case.+module T where++import Expr+import Data.SBV++t :: SExpr -> SMaybe Integer -> SInteger+t e m = [sCase| e of+ Zero -> case m of+ Just v -> v+ _ -> 0+ Num k -> k+ _ -> case m of+ Nothing -> -1+ _ -> 42+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase94.stderr view
@@ -0,0 +1,18 @@+SCase94.hs:(12,16)-(20,9): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> case m of\n\+ \ Just v -> v\n\+ \ _ -> 0\n\+ \ Num k -> k\n\+ \ _ -> case m of\n\+ \ Nothing -> -1\n\+ \ _ -> 42\n\+ \ "+ ======>+ sCaseExpr+ (Data.SBV.Maybe.sCaseMaybe 0 (\ v -> v) m) (\ k -> k)+ (\ _ -> Data.SBV.Maybe.sCaseMaybe (negate 1) (\ _ -> 42) m)+ (\ _ _ -> Data.SBV.Maybe.sCaseMaybe (negate 1) (\ _ -> 42) m)+ (\ _ _ _ -> Data.SBV.Maybe.sCaseMaybe (negate 1) (\ _ -> 42) m) e
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase95.hs view
@@ -0,0 +1,19 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Negative: Non-exhaustive inner case (missing Nothing).+module T where++import Expr+import Data.SBV++t :: SExpr -> SMaybe Integer -> SInteger+t e m = [sCase| e of+ Zero -> case m of+ Just v -> v+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase95.stderr view
@@ -0,0 +1,21 @@+SCase95.hs:12:16: error: [GHC-39584]+ " sCase: Pattern match(es) are non-exhaustive.+ Not matched : Nothing+ Patterns of type: Maybe+ Must match each : Nothing, Just++ You can use a '_' to match multiple cases.++ " In the quasi-quotation:+ [sCase| e of+ Zero -> case m of+ Just v -> v+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]+ |+12 | t e m = [sCase| e of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase96.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Negative: Overlapping patterns in inner case (duplicate Just).+module T where++import Expr+import Data.SBV++t :: SExpr -> SMaybe Integer -> SInteger+t e m = [sCase| e of+ Zero -> case m of+ Nothing -> 0+ Just v -> v+ Just _ -> 42+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase96.stderr view
@@ -0,0 +1,22 @@+SCase96.hs:12:16: error: [GHC-39584]+ " sCase: Overlapping case constructors:+ Type : Maybe+ Constructor: Just _+ Overlaps with:+ SCase96.hs:(12,16)-(21,10): Just v++ " In the quasi-quotation:+ [sCase| e of+ Zero -> case m of+ Nothing -> 0+ Just v -> v+ Just _ -> 42+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]+ |+12 | t e m = [sCase| e of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase97.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Negative: Inner case on ADT without mkSymbolic.+module T where++import Expr+import Data.SBV++data Color = Red | Green | Blue++t :: SExpr -> Color -> SInteger+t e c = [sCase| e of+ Zero -> case c of+ Red -> 0+ Green -> 1+ Blue -> 2+ Num k -> k+ Var _ -> -1+ Add a b -> t a c + t b c+ Let _ _ b -> t b c+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase97.stderr view
@@ -0,0 +1,17 @@+SCase97.hs:14:16: error: [GHC-79890]+ " Red is not in the type environment at a reify+ " In the quasi-quotation:+ [sCase| e of+ Zero -> case c of+ Red -> 0+ Green -> 1+ Blue -> 2+ Num k -> k+ Var _ -> -1+ Add a b -> t a c + t b c+ Let _ _ b -> t b c+ |]+ |+14 | t e c = [sCase| e of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase98.hs view
@@ -0,0 +1,19 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Negative: Non-exhaustive guarded inner case (missing Nothing, guard might fail).+module T where++import Expr+import Data.SBV++t :: SExpr -> SMaybe Integer -> SInteger+t e m = [sCase| e of+ Zero -> case m of+ Just v | v .> 0 -> v+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase98.stderr view
@@ -0,0 +1,19 @@+SCase98.hs:12:16: error: [GHC-39584]+ " sCase: Non-exhaustive match:+ Type : Maybe+ Constructor: Just v | v .> 0+ NB. Guarded match might fail.++ " In the quasi-quotation:+ [sCase| e of+ Zero -> case m of+ Just v | v .> 0 -> v+ Num k -> k+ Var _ -> -1+ Add a b -> t a m + t b m+ Let _ _ b -> t b m+ |]+ |+12 | t e m = [sCase| e of+ | ^^^^^...+
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase99.hs view
@@ -0,0 +1,24 @@+{-# LANGUAGE QuasiQuotes #-}++{-# OPTIONS_GHC -Wall -Werror -ddump-splices #-}++-- Positive: Deep nesting (4 levels). Outer Expr, inner Maybe, inner Either, innermost Bool.+module T where++import Expr+import Data.SBV++t :: SExpr -> SMaybe (Either Integer Bool) -> SBool -> SInteger+t e m b = [sCase| e of+ Zero -> case m of+ Nothing -> 0+ Just v -> case v of+ Left x -> case b of+ True -> x+ False -> -x+ Right _ -> 1+ Num k -> k+ Var _ -> -1+ Add a _ -> t a m b+ Let _ _ c -> t c m b+ |]
+ SBVTestSuite/TestSuite/CompileTests/SCase/SCase99.stderr view
@@ -0,0 +1,26 @@+SCase99.hs:(12,18)-(24,11): Splicing expression+ ghc-internal:GHC.Internal.TH.Quote.quoteExp+ sCase+ " e of\n\+ \ Zero -> case m of\n\+ \ Nothing -> 0\n\+ \ Just v -> case v of\n\+ \ Left x -> case b of\n\+ \ True -> x\n\+ \ False -> -x\n\+ \ Right _ -> 1\n\+ \ Num k -> k\n\+ \ Var _ -> -1\n\+ \ Add a _ -> t a m b\n\+ \ Let _ _ c -> t c m b\n\+ \ "+ ======>+ sCaseExpr+ (Data.SBV.Maybe.sCaseMaybe+ 0+ (\ v+ -> Data.SBV.Either.sCaseEither+ (\ x -> ite b x (negate x)) (\ _ -> 1) v)+ m)+ (\ k -> k) (\ _ -> negate 1) (\ a _ -> t a m b)+ (\ _ _ c -> t c m b) e
SBVTestSuite/Utils/SBVTestFramework.hs view
@@ -41,7 +41,7 @@ import Control.Monad.Trans (liftIO) import qualified Data.ByteString.Lazy.Char8 as LBC-import System.Directory (removeFile)+import System.Directory (getCurrentDirectory, removeFile) import Test.Tasty (testGroup, TestTree, TestName) import Test.Tasty.HUnit ((@?), Assertion, testCase, AssertionPredicable, assertFailure)@@ -305,7 +305,17 @@ ++ concat [" -package " ++ pkg | pkg <- packages] compile path = withSystemTempDirectory "SBVTempDir" $ \tmpDir -> do- (exitCode, sOut, sErr) <- readProcessInDir testDir "ghc" (words (args tmpDir) ++ [path]) ""+ -- Use the inplace package DB from dist-newstyle so we pick up+ -- the locally-built sbv (built by cabal test) without needing+ -- a separate 'cabal install --lib' step.+ projRoot <- getCurrentDirectory+ let cabalFile = projRoot </> "sbv.cabal"+ ver <- extractVersion <$> readFile cabalFile+ sbvDBs <- glob (projRoot </> "dist-newstyle/build/*/ghc-*/sbv-" ++ ver ++ "/package.conf.inplace")+ let pkgDbArgs = case sbvDBs of+ (db:_) -> ["-package-db", db]+ [] -> []+ (exitCode, sOut, sErr) <- readProcessInDir testDir "ghc" (pkgDbArgs ++ words (args tmpDir) ++ [path]) "" -- If the source uses -ddump-splices, include stdout (where GHC dumps splices) -- Filter to only keep "Splicing expression" blocks, stripping temp paths and preamble src <- readFile (testDir </> path)@@ -321,5 +331,12 @@ isSpliceLine l = "Splicing expression" `isInfixOf` l skipLine l = "Loaded package environment" `isInfixOf` l || "Compiling" `isInfixOf` l++ -- Extract the version string from sbv.cabal+ extractVersion = go . lines+ where go [] = error "mkCompileTest: Cannot find Version in sbv.cabal"+ go (l:ls) = case words l of+ ["Version", ":", v] -> v+ _ -> go ls {- HLint ignore module "Reduce duplication" -}
sbv.cabal view
@@ -1,7 +1,7 @@ Cabal-Version: 2.2 Name : sbv-Version : 13.6+Version : 14.0 Category : Formal Methods, Theorem Provers, Bit vectors, Symbolic Computation, Math, SMT Synopsis : SMT Based Verification: Symbolic Haskell theorem prover using SMT solving. Description : Express properties about Haskell programs and automatically prove them using SMT@@ -36,7 +36,8 @@ default-language: Haskell2010 ghc-options : -Wall build-depends : base >= 4.19.2 && < 5- other-extensions: BangPatterns+ other-extensions: AllowAmbiguousTypes+ BangPatterns CPP ConstraintKinds DataKinds@@ -244,8 +245,10 @@ , Documentation.SBV.Examples.TP.Basics , Documentation.SBV.Examples.TP.BinarySearch , Documentation.SBV.Examples.TP.CaseSplit- , Documentation.SBV.Examples.TP.ConstFold , Documentation.SBV.Examples.TP.Coins+ , Documentation.SBV.Examples.TP.Collatz+ , Documentation.SBV.Examples.TP.ConstFold+ , Documentation.SBV.Examples.TP.Countdown , Documentation.SBV.Examples.TP.Fibonacci , Documentation.SBV.Examples.TP.GCD , Documentation.SBV.Examples.TP.InsertionSort@@ -255,6 +258,8 @@ , Documentation.SBV.Examples.TP.McCarthy91 , Documentation.SBV.Examples.TP.Majority , Documentation.SBV.Examples.TP.MergeSort+ , Documentation.SBV.Examples.TP.MutualCorecursion+ , Documentation.SBV.Examples.TP.NatStream , Documentation.SBV.Examples.TP.Numeric , Documentation.SBV.Examples.TP.Peano , Documentation.SBV.Examples.TP.PigeonHole@@ -293,6 +298,7 @@ , Data.SBV.Core.Sized , Data.SBV.Core.SizedFloats , Data.SBV.Core.Symbolic+ , Data.SBV.Core.TH , Data.SBV.Control.BaseIO , Data.SBV.Control.Query , Data.SBV.Control.Types@@ -385,7 +391,9 @@ , TestSuite.Basics.QRem , TestSuite.Basics.Quantifiers , TestSuite.Basics.Recursive+ , TestSuite.Basics.TPCaching , TestSuite.Basics.Set+ , TestSuite.Basics.SmtFunctionUnique , TestSuite.Basics.SmallShifts , TestSuite.Basics.SquashReals , TestSuite.Basics.String