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

Delay applyExpr until after elaboration #732

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
58a951a
elab-strict
ranjitjhala Jan 15, 2025
c3a8a08
delay applyExpr until elaboration is finished
vrindisbacher Jan 17, 2025
ac79d5c
More strict mode that makes a seemingly large difference
vrindisbacher Jan 17, 2025
9f55cca
Use ReaderT instead of State monad in visitor
vrindisbacher Jan 18, 2025
1a12686
specialized visitor for trans since acc is unit
vrindisbacher Jan 18, 2025
36ae1ca
Fix traversal order for transE on expressions
vrindisbacher Jan 20, 2025
140ae73
renaming visitable -> foldable and specialized visitor for trans to V…
vrindisbacher Jan 20, 2025
eddd41f
add union to CheckM and start to take apply out of elab
vrindisbacher Jan 24, 2025
d9ab837
Extract unify to unifyUF
vrindisbacher Jan 30, 2025
acb4f46
rip out all applies and applyExpr from elab
vrindisbacher Jan 30, 2025
3c64ac1
hack together some union method for sorts
vrindisbacher Jan 31, 2025
3b592cc
fixup mistake
vrindisbacher Jan 31, 2025
3cac458
Change union for FObj and FTC
vrindisbacher Jan 31, 2025
1111410
insert directly on free variables
vrindisbacher Jan 31, 2025
8300b80
add check that we aren't unifying a type variable with itself
vrindisbacher Jan 31, 2025
1bde2dc
change unite
vrindisbacher Feb 3, 2025
f79afbc
add applyExprUF
vrindisbacher Feb 3, 2025
c676973
add a bunch of missing unifyUFs
vrindisbacher Feb 3, 2025
4b055d9
add more missing uf
vrindisbacher Feb 3, 2025
5985fa9
Found mystery
vrindisbacher Feb 3, 2025
24ca915
make sure union find is saved correctly
vrindisbacher Feb 4, 2025
78f6048
remove debug prints
vrindisbacher Feb 4, 2025
d3b71f5
avoiding unifying self in sub sorts
vrindisbacher Feb 4, 2025
61e1370
Cleanup
vrindisbacher Feb 4, 2025
2c148da
make sure unified type variables are not unified in a looping manner
vrindisbacher Feb 4, 2025
43c55bf
More cleanup
vrindisbacher Feb 4, 2025
39c85c5
wip
vrindisbacher Feb 4, 2025
8165447
remove checkNumeric for type variables and unify them instead
vrindisbacher Feb 4, 2025
f783b09
patch check book sort
vrindisbacher Feb 4, 2025
c2fb110
refactor union find
vrindisbacher Feb 5, 2025
8482e28
rip out some things
vrindisbacher Feb 5, 2025
9d80a47
fix check numeric
vrindisbacher Feb 5, 2025
6de29b5
rip out unecessary cases in checRelTy
vrindisbacher Feb 5, 2025
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
1 change: 1 addition & 0 deletions liquid-fixpoint.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ library
Language.Fixpoint.Solver.UniqifyKVars
Language.Fixpoint.Solver.Worklist
Language.Fixpoint.SortCheck
Language.Fixpoint.Union
Language.Fixpoint.Types
Language.Fixpoint.Types.Config
Language.Fixpoint.Types.Constraints
Expand Down
22 changes: 11 additions & 11 deletions src/Language/Fixpoint/Horn/Transformations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ elimKs' (k:ks) (noside, side) = elimKs' (trace ("solved kvar " <> F.showpp k <>
-- exists in the positive positions (which will stay exists when we go to
-- prenex) may give us a lot of trouble during _quantifier elimination_
-- tx :: F.Symbol -> [[Bind]] -> Pred -> Pred
-- tx k bss = trans (defaultVisitor { txExpr = existentialPackage, ctxExpr = ctxKV }) M.empty ()
-- tx k bss = trans (defaultFolder { txExpr = existentialPackage, ctxExpr = ctxKV }) M.empty ()
-- where
-- splitBinds xs = unzip $ (\(Bind x t p) -> ((x,t),p)) <$> xs
-- cubeSol su (Bind _ _ (Reft eqs):xs)
Expand All @@ -564,16 +564,16 @@ elimKs' (k:ks) (noside, side) = elimKs' (trace ("solved kvar " <> F.showpp k <>
-- ctxKV m _ = m

-- Visitor only visit Exprs in Pred!
instance V.Visitable Pred where
visit v c (PAnd ps) = PAnd <$> mapM (visit v c) ps
visit v c (Reft e) = Reft <$> visit v c e
visit _ _ var = pure var

instance V.Visitable (Cstr a) where
visit v c (CAnd cs) = CAnd <$> mapM (visit v c) cs
visit v c (Head p a) = Head <$> visit v c p <*> pure a
visit v ctx (All (Bind x t p l) c) = All <$> (Bind x t <$> visit v ctx p <*> pure l) <*> visit v ctx c
visit v ctx (Any (Bind x t p l) c) = All <$> (Bind x t <$> visit v ctx p <*> pure l) <*> visit v ctx c
instance V.Foldable Pred where
foldE v c (PAnd ps) = PAnd <$> mapM (foldE v c) ps
foldE v c (Reft e) = Reft <$> foldE v c e
foldE _ _ var = pure var

instance V.Foldable (Cstr a) where
foldE v c (CAnd cs) = CAnd <$> mapM (foldE v c) cs
foldE v c (Head p a) = Head <$> foldE v c p <*> pure a
foldE v ctx (All (Bind x t p l) c) = All <$> (Bind x t <$> foldE v ctx p <*> pure l) <*> foldE v ctx c
foldE v ctx (Any (Bind x t p l) c) = All <$> (Bind x t <$> foldE v ctx p <*> pure l) <*> foldE v ctx c

------------------------------------------------------------------------------
-- | Quantifier elimination for use with implicit solver
Expand Down
12 changes: 0 additions & 12 deletions src/Language/Fixpoint/Solver/Sanitize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ sanitize cfg = banIrregularData
>=> banConstraintFreeVars cfg
>=> Misc.fM addLiterals
>=> Misc.fM (eliminateEta cfg)
>=> Misc.fM cancelCoercion


--------------------------------------------------------------------------------
-- | 'dropAdtMeasures' removes all the measure definitions that correspond to
Expand Down Expand Up @@ -83,16 +81,6 @@ addLiterals si = si { F.dLits = F.unionSEnv (F.dLits si) lits'
where
lits' = M.fromList [ (F.symbol x, F.strSort) | x <- symConsts si ]



cancelCoercion :: F.SInfo a -> F.SInfo a
cancelCoercion = mapExpr (trans (defaultVisitor { txExpr = go }) () ())
where
go _ (F.ECoerc t1 t2 (F.ECoerc t2' t1' e))
| t1 == t1' && t2 == t2'
= e
go _ e = e

--------------------------------------------------------------------------------
-- | `eliminateEta` converts equations of the form f x = g x into f = g
--------------------------------------------------------------------------------
Expand Down
Loading
Loading