Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up propsSubset through stAppIndex check #1829

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ]
-- For each x, check if x exists in ps2 by checking term identity using stAppIndex
-- If the check succeeds, return True. 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
pennyannn marked this conversation as resolved.
Show resolved Hide resolved
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