Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventErkok committed Sep 13, 2024
1 parent f39d499 commit a1c21a6
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions Data/SBV/Core/Operations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,15 @@ svEqual a b
-- | Implication. Only for booleans.
svImplies :: SVal -> SVal -> SVal
svImplies a b
| isConcreteZero a -- false implies everything
|| isConcreteOne b -- true is implied by everything
= svTrue
| any (\x -> kindOf x /= KBool) [a, b]
= bad
| True
= liftSym2B (mkSymOpSC (eqOpt trueSV) Implies) rationalCheck bad imp bad bad bad bad bad bad bad bad bad bad bad a b
where bad = error $ "Data.SBV.svImplies: Unexpected arguments: " ++ show (a, kindOf a, b, kindOf b)
imp :: Integer -> Integer -> Bool
imp 0 0 = True
imp 0 1 = True
imp 1 0 = False
imp 1 1 = True
imp x y = error $ "Data.SBV.svImplies: Called on unreduced arguments: " ++ show (x, y, a, kindOf a, b, kindOf b)
| any (\x -> kindOf x /= KBool) [a, b] = error $ "Data.SBV.svImplies: Unexpected arguments: " ++ show (a, kindOf a, b, kindOf b)
| isConcreteZero a = svTrue -- F -> _ = T
| isConcreteOne b = svTrue -- _ -> T = T
| isConcreteOne a && isConcreteZero b = svFalse -- T -> F = F
| isConcreteOne a && isConcreteOne b = svTrue -- T -> T = T
| True = SVal KBool $ Right $ cache c
where c st = do sva <- svToSV st a
svb <- svToSV st b
newExpr st KBool (SBVApp Implies [sva, svb])

-- | Inequality.
svNotEqual :: SVal -> SVal -> SVal
Expand Down

0 comments on commit a1c21a6

Please sign in to comment.