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

Interpreter only on LHS #1899

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion liquid-fixpoint
Submodule liquid-fixpoint updated 53 files
+11 −11 bin/Fixpoint.hs
+2 −0 liquid-fixpoint.cabal
+27 −27 src/Language/Fixpoint/Congruence/Closure.hs
+18 −18 src/Language/Fixpoint/Congruence/Types.hs
+2 −2 src/Language/Fixpoint/Defunctionalize.hs
+3 −3 src/Language/Fixpoint/Graph/Deps.hs
+4 −4 src/Language/Fixpoint/Graph/Partition.hs
+3 −3 src/Language/Fixpoint/Horn/Info.hs
+4 −4 src/Language/Fixpoint/Horn/Parse.hs
+3 −3 src/Language/Fixpoint/Horn/Solve.hs
+53 −53 src/Language/Fixpoint/Horn/Types.hs
+19 −19 src/Language/Fixpoint/Misc.hs
+2 −2 src/Language/Fixpoint/Parse.hs
+1 −1 src/Language/Fixpoint/Smt/Interface.hs
+13 −13 src/Language/Fixpoint/Smt/Serialize.hs
+27 −27 src/Language/Fixpoint/Smt/Theories.hs
+10 −10 src/Language/Fixpoint/Solver.hs
+3 −2 src/Language/Fixpoint/Solver/EnvironmentReduction.hs
+89 −89 src/Language/Fixpoint/Solver/Extensionality.hs
+6 −6 src/Language/Fixpoint/Solver/GradualSolution.hs
+206 −206 src/Language/Fixpoint/Solver/Instantiate.hs
+580 −0 src/Language/Fixpoint/Solver/Interpreter.hs
+2 −2 src/Language/Fixpoint/Solver/Monad.hs
+47 −0 src/Language/Fixpoint/Solver/Normalize.hs
+180 −235 src/Language/Fixpoint/Solver/PLE.hs
+1 −1 src/Language/Fixpoint/Solver/Prettify.hs
+2 −2 src/Language/Fixpoint/Solver/Rewrite.hs
+21 −21 src/Language/Fixpoint/Solver/Sanitize.hs
+69 −69 src/Language/Fixpoint/Solver/Solution.hs
+43 −9 src/Language/Fixpoint/Solver/Solve.hs
+2 −2 src/Language/Fixpoint/Solver/Stats.hs
+65 −65 src/Language/Fixpoint/SortCheck.hs
+1 −1 src/Language/Fixpoint/Types/Binary.hs
+7 −5 src/Language/Fixpoint/Types/Config.hs
+50 −50 src/Language/Fixpoint/Types/Constraints.hs
+1 −1 src/Language/Fixpoint/Types/Environments.hs
+5 −5 src/Language/Fixpoint/Types/Errors.hs
+20 −6 src/Language/Fixpoint/Types/Names.hs
+1 −1 src/Language/Fixpoint/Types/PrettyPrint.hs
+13 −13 src/Language/Fixpoint/Types/Refinements.hs
+27 −27 src/Language/Fixpoint/Types/Solutions.hs
+42 −42 src/Language/Fixpoint/Types/Sorts.hs
+4 −4 src/Language/Fixpoint/Types/Spans.hs
+2 −2 src/Language/Fixpoint/Types/Substitutions.hs
+49 −49 src/Language/Fixpoint/Types/Templates.hs
+9 −9 src/Language/Fixpoint/Types/Theories.hs
+4 −4 src/Language/Fixpoint/Types/Triggers.hs
+12 −12 src/Language/Fixpoint/Types/Utils.hs
+22 −22 src/Language/Fixpoint/Types/Visitor.hs
+1 −1 src/Language/Fixpoint/Utils/Files.hs
+34 −34 src/Language/Fixpoint/Utils/Trie.hs
+2 −2 tests/test.hs
+8 −8 unix/Language/Fixpoint/Utils/Progress.hs
8 changes: 7 additions & 1 deletion src/Language/Haskell/Liquid/Constraint/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ caseEnv γ x _ (DataAlt c) ys pIs = do
let ys'' = F.symbol <$> filter (not . if allowTC then GM.isEmbeddedDictVar else GM.isEvVar) ys
let r1 = dataConReft c ys''
let r2 = dataConMsReft rtd ys''
let xt = (xt0 `F.meet` rtd) `strengthen` (uTop (r1 `F.meet` r2))
xt <- markDataConType ((xt0 `F.meet` rtd) `strengthen` (uTop (r1 `F.meet` r2)))
let cbs = safeZip "cconsCase" (x':ys') (xt0 : yts)
cγ' <- addBinders γ x' cbs
addBinders cγ' x' [(x', xt)]
Expand All @@ -1192,6 +1192,12 @@ caseEnv γ x acs a _ _ = do
cγ <- addBinders γ x' [(x', xt')]
return cγ


markDataConType :: (TyConable c, F.Reftable (f1 F.Reft), Functor f1)
=> RType c tv (f1 F.Reft) -> CG (RType c tv (f1 F.Reft))
markDataConType t@(RApp _ _ _ _) = (shiftVV t . F.dataconSymbol) <$> fresh
markDataConType t = return t

--------------------------------------------------------------------------------
-- | `projectTypes` masks (i.e. true's out) all types EXCEPT those
-- at given indices; it is used to simplify the environment used
Expand Down
1 change: 1 addition & 0 deletions src/Language/Haskell/Liquid/Constraint/ToFixpoint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fixConfig tgt cfg = def
, FC.oldPLE = oldPLE cfg
, FC.rwTerminationCheck = rwTerminationCheck cfg
, FC.noLazyPLE = noLazyPLE cfg
, FC.useInterpreter = useInterpreter cfg
, FC.fuel = fuel cfg
, FC.noEnvironmentReduction = not (environmentReduction cfg)
, FC.inlineANFBindings = inlineANFBindings cfg
Expand Down
3 changes: 3 additions & 0 deletions src/Language/Haskell/Liquid/Types/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,9 @@ instance F.Fixpoint RTyCon where
instance F.Fixpoint BTyCon where
toFix = text . F.symbolString . F.val . btc_tc

instance F.PPrint Cinfo where
pprintTidy _ = text . show

instance F.Fixpoint Cinfo where
toFix = text . showPpr . ci_loc

Expand Down
7 changes: 7 additions & 0 deletions src/Language/Haskell/Liquid/UX/CmdLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,12 @@ config = cmdArgsMode $ Config {
&= explicit
&= name "no-environment-reduction"
&= help "Don't perform environment reduction"
, useInterpreter
= def
&= explicit
&= help "Interpretation of reflected functions"
&= name "interpreter"

, inlineANFBindings
= False
&= explicit
Expand Down Expand Up @@ -702,6 +708,7 @@ defConfig = Config
, environmentReduction = False
, noEnvironmentReduction = False
, inlineANFBindings = False
, useInterpreter = False
}


Expand Down
1 change: 1 addition & 0 deletions src/Language/Haskell/Liquid/UX/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ data Config = Config
, maxMatchDepth :: Int
, maxAppDepth :: Int
, maxArgsDepth :: Int
, useInterpreter :: Bool
, rwTerminationCheck :: Bool -- ^ Enable termination checking for rewriting
, skipModule :: Bool -- ^ Skip this module entirely (don't even compile any specs in it)
, noLazyPLE :: Bool
Expand Down
19 changes: 19 additions & 0 deletions tests/interpreter/neg/Fib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{-# LANGUAGE GADTs #-}

{-@ LIQUID "--no-termination" @-}
{-@ LIQUID "--reflection" @-}
{-@ LIQUID "--ple" @-}
{-@ LIQUID "--interpreter" @-}

module Fib where


{-@ thm :: () -> {fib 7 = 24} @-}
thm :: () -> ()
thm _ = ()

{-@ reflect fib @-}
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib i = fib (i-1) + fib (i-2)
24 changes: 24 additions & 0 deletions tests/interpreter/pos/Fib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{-# LANGUAGE GADTs #-}

{-@ LIQUID "--no-termination" @-}
{-@ LIQUID "--reflection" @-}
{-@ LIQUID "--ple" @-}
{-@ LIQUID "--interpreter" @-}

module Fib where


{-@ thm10 :: () -> {fib 10 = 55} @-}
thm10 :: () -> ()
thm10 _ = ()

{-@ thm7 :: () -> {fib 7 = 13} @-}
thm7 :: () -> ()
thm7 _ = ()


{-@ reflect fib @-}
fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib i = fib (i-1) + fib (i-2)
28 changes: 28 additions & 0 deletions tests/interpreter/pos/LambdaToy.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{-# LANGUAGE GADTs #-}

{-@ LIQUID "--no-termination" @-}
{-@ LIQUID "--reflection" @-}
{-@ LIQUID "--ple" @-}
{-@ LIQUID "--interpreter" @-}

module LambdaToy where

{-@ reflect isPred @-}
{-@ isPred :: e:Expr -> { b:Bool | (isTerm e => b) } @-}
isPred :: Expr -> Bool -- (outside of refinements of course)
isPred (Bc _) = True
isPred (App e e') = isTerm e && isTerm e'




data Expr = Bc Bool -- True, False
| App Expr Expr -- e e' applications
{-@ type Term = { e:Expr | isTerm e } @-}

{-@ reflect isTerm @-} -- a legal program term is an expression that does not contain Conj
{-@ isTerm :: e:Expr -> { b:Bool | b => isPred e } @-}
isTerm :: Expr -> Bool -- (outside of refinements of course)
isTerm (Bc _) = True
isTerm (App e e') = isTerm e && isTerm e'

2 changes: 2 additions & 0 deletions tests/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ microTests = group "Micro"
, mkMicroNeg "absref-neg" "tests/absref/neg"
-- , mkMicroPos "import-lib" "tests/import/lib" -- NOT disabled; but via CHECK-IMPORTS
, mkMicroPos "import-cli" "tests/import/client"
, mkMicroPos "interpreter-pos" "tests/interpreter/pos"
, mkMicroNeg "interpreter-neg" "tests/interpreter/neg"
, mkMicroPos "class-pos" "tests/classes/pos"
, mkMicroNeg "class-neg" "tests/classes/neg"
, mkMicroPos "ple-pos" "tests/ple/pos"
Expand Down