Skip to content

Commit

Permalink
Merge pull request #706 from ucsd-progsys/fd/related-symbols
Browse files Browse the repository at this point in the history
Export relatedSymbols and make it a bit more general
  • Loading branch information
facundominguez authored Sep 25, 2024
2 parents 9809266 + e9bed64 commit 4233197
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## NEXT

- Expose relatedSymbols from EnvironmentReduction. Needed for improving error
messages in LH
[#2346](https://github.com/ucsd-progsys/liquidhaskell/issues/2346).
- Support extensionality in PLE [#704](https://github.com/ucsd-progsys/liquid-fixpoint/pull/704)

## 0.9.6.3.1 (2024-08-21)

Expand Down
10 changes: 6 additions & 4 deletions src/Language/Fixpoint/Solver/EnvironmentReduction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Language.Fixpoint.Solver.EnvironmentReduction
( reduceEnvironments
, simplifyBindings
, dropLikelyIrrelevantBindings
, relatedSymbols
, inlineInExpr
, inlineInSortedReft
, mergeDuplicatedBindings
Expand Down Expand Up @@ -744,7 +745,8 @@ dropLikelyIrrelevantBindings
-> HashMap Symbol SortedReft
dropLikelyIrrelevantBindings ss env = HashMap.filterWithKey relevant env
where
relatedSyms = relatedSymbols ss env
directlyUses = HashMap.map (exprSymbolsSet . reftPred . sr_reft) env
relatedSyms = relatedSymbols ss directlyUses
relevant s _sr =
(not (capitalizedSym s) || prefixOfSym s /= s) && s `HashSet.member` relatedSyms
capitalizedSym = Text.all isUpper . Text.take 1 . symbolText
Expand All @@ -760,10 +762,10 @@ dropLikelyIrrelevantBindings ss env = HashMap.filterWithKey relevant env
-- @a@ uses @b@. Because the predicate of @c@ relates @b@ with @d@,
-- @d@ can also influence the validity of the predicate of @a@, and therefore
-- we include both @b@, @c@, and @d@ in the set of related symbols.
relatedSymbols :: HashSet Symbol -> HashMap Symbol SortedReft -> HashSet Symbol
relatedSymbols ss0 env = go HashSet.empty ss0
relatedSymbols
:: HashSet Symbol -> HashMap Symbol (HashSet Symbol) -> HashSet Symbol
relatedSymbols ss0 directlyUses = go HashSet.empty ss0
where
directlyUses = HashMap.map (exprSymbolsSet . reftPred . sr_reft) env
usedBy = HashMap.fromListWith HashSet.union
[ (x, HashSet.singleton s)
| (s, xs) <- HashMap.toList directlyUses
Expand Down

0 comments on commit 4233197

Please sign in to comment.