Skip to content

Commit

Permalink
Further simplify the overflow checker
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventErkok committed Aug 7, 2024
1 parent 47ac449 commit 05539b3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions attic/overflow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ textbook x y = prod2N ./= sFromIntegral prodN
prodN = x * y

test :: forall proxy n. (BVIsNonZero n, KnownNat n, BVIsNonZero (n+1), KnownNat (n+1), BVIsNonZero (n+n), KnownNat (n+n)) => proxy n -> IO ()
test _ = do print =<< comp ("At " ++ show nv ++ " bits, against builtin:") bvMulO (bvsmulO :: SInt n -> SInt n -> SBool)
print =<< comp ("At " ++ show nv ++ " bits, against textbook:") textbook (bvsmulO :: SInt n -> SInt n -> SBool)
where nv = natVal (Proxy @n)
comp w f g = do putStrLn $ "Proving: " ++ w ++ ", N = " ++ show (natVal (Proxy @n))
proveWith bitwuzla{timing = PrintTiming} $ do
x <- sInt "x"
y <- sInt "x"
pure $ f x y .== g x y
test _ = do print =<< check "Against builtin" bvMulO
print =<< check "Against textbook" textbook
where check w f = do putStrLn $ "Proving: " ++ w ++ ", N = " ++ show (natVal (Proxy @n))
proveWith bitwuzla $ do
x <- sInt "x"
y <- sInt "x"
pure $ f x y .== (bvsmulO :: SInt n -> SInt n -> SBool) x y

main :: IO ()
main = do test (Proxy @1)
Expand Down

0 comments on commit 05539b3

Please sign in to comment.