Skip to content

Commit

Permalink
Speed up propsSubset through stAppIndex check
Browse files Browse the repository at this point in the history
  • Loading branch information
pennyannn committed Mar 2, 2023
1 parent 9acd534 commit b53bc1b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/SAWScript/Proof.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,17 @@ psStats = _psStats
-- forall x in ps1, exists y in ps2 where x == y
propsSubset :: SharedContext -> [Prop] -> [Prop] -> IO Bool
propsSubset sc ps1 ps2 =
and <$> sequence [ propsElem sc x ps2 | x <- ps1 ]
-- First, check if x exists in ps2 by checking term identity using stAppIndex
-- If the check succeeds, return, otherwise use propsElem to do the more expensive
-- convertibility check.
and <$> sequence [ if idSubset (unProp x) then pure True else propsElem sc x ps2 | x <- ps1 ]
where
ps2Ids = foldr (\x idents -> case (unProp x) of
STApp{ stAppIndex = ident } -> Set.insert ident idents
_ -> idents)
Set.empty ps2
idSubset STApp{ stAppIndex = ident } = Set.member ident ps2Ids
idSubset _ = False

-- exists y in ps where x == y
propsElem :: SharedContext -> Prop -> [Prop] -> IO Bool
Expand Down

0 comments on commit b53bc1b

Please sign in to comment.